5 #include "PropIDUtils.h"
7 #include "Common/IntToString.h"
8 #include "Common/StringConvert.h"
10 #include "Windows/FileFind.h"
11 #include "Windows/PropVariantConversions.h"
13 #include "../../PropID.h"
15 using namespace NWindows;
17 static UString ConvertUInt32ToString(UInt32 value)
20 ConvertUInt64ToString(value, buffer);
24 static void ConvertUInt32ToHex(UInt32 value, wchar_t *s)
26 for (int i = 0; i < 8; i++)
30 s[7 - i] = (wchar_t)((t < 10) ? (L'0' + t) : (L'A' + (t - 10)));
35 UString ConvertPropertyToString(const PROPVARIANT &propVariant, PROPID propID, bool full)
39 case kpidCreationTime:
40 case kpidLastWriteTime:
41 case kpidLastAccessTime:
43 if (propVariant.vt != VT_FILETIME)
44 return UString(); // It is error;
45 FILETIME localFileTime;
46 if (propVariant.filetime.dwHighDateTime == 0 &&
47 propVariant.filetime.dwLowDateTime == 0)
49 if (!::FileTimeToLocalFileTime(&propVariant.filetime, &localFileTime))
50 return UString(); // It is error;
51 return ConvertFileTimeToString(localFileTime, true, full);
55 if(propVariant.vt != VT_UI4)
58 ConvertUInt32ToHex(propVariant.ulVal, temp);
63 if(propVariant.vt != VT_UI4)
66 UInt32 attributes = propVariant.ulVal;
67 if (NFile::NFind::NAttributes::IsReadOnly(attributes)) result += L'R';
68 if (NFile::NFind::NAttributes::IsHidden(attributes)) result += L'H';
69 if (NFile::NFind::NAttributes::IsSystem(attributes)) result += L'S';
70 if (NFile::NFind::NAttributes::IsDirectory(attributes)) result += L'D';
71 if (NFile::NFind::NAttributes::IsArchived(attributes)) result += L'A';
72 if (NFile::NFind::NAttributes::IsCompressed(attributes)) result += L'C';
73 if (NFile::NFind::NAttributes::IsEncrypted(attributes)) result += L'E';
76 case kpidDictionarySize:
78 if(propVariant.vt != VT_UI4)
80 UInt32 size = propVariant.ulVal;
81 if (size % (1 << 20) == 0)
82 return ConvertUInt32ToString(size >> 20) + L"MB";
83 if (size % (1 << 10) == 0)
84 return ConvertUInt32ToString(size >> 10) + L"KB";
85 return ConvertUInt32ToString(size);
88 return ConvertPropVariantToString(propVariant);