Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(717)

Side by Side Diff: third_party/lzma/v4_65/files/CPP/7zip/UI/Common/PropIDUtils.cpp

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // PropIDUtils.cpp
2
3 #include "StdAfx.h"
4
5 #include "PropIDUtils.h"
6
7 #include "Common/IntToString.h"
8 #include "Common/StringConvert.h"
9
10 #include "Windows/FileFind.h"
11 #include "Windows/PropVariantConversions.h"
12
13 #include "../../PropID.h"
14
15 using namespace NWindows;
16
17 static UString ConvertUInt32ToString(UInt32 value)
18 {
19 wchar_t buffer[32];
20 ConvertUInt64ToString(value, buffer);
21 return buffer;
22 }
23
24 static void ConvertUInt32ToHex(UInt32 value, wchar_t *s)
25 {
26 for (int i = 0; i < 8; i++)
27 {
28 int t = value & 0xF;
29 value >>= 4;
30 s[7 - i] = (wchar_t)((t < 10) ? (L'0' + t) : (L'A' + (t - 10)));
31 }
32 s[8] = L'\0';
33 }
34
35 UString ConvertPropertyToString(const PROPVARIANT &propVariant, PROPID propID, b ool full)
36 {
37 switch(propID)
38 {
39 case kpidCTime:
40 case kpidATime:
41 case kpidMTime:
42 {
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)
48 return UString();
49 if (!::FileTimeToLocalFileTime(&propVariant.filetime, &localFileTime))
50 return UString(); // It is error;
51 return ConvertFileTimeToString(localFileTime, true, full);
52 }
53 case kpidCRC:
54 {
55 if(propVariant.vt != VT_UI4)
56 break;
57 wchar_t temp[12];
58 ConvertUInt32ToHex(propVariant.ulVal, temp);
59 return temp;
60 }
61 case kpidAttrib:
62 {
63 if(propVariant.vt != VT_UI4)
64 break;
65 UString result;
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::IsDir(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';
74 return result;
75 }
76 case kpidDictionarySize:
77 {
78 if(propVariant.vt != VT_UI4)
79 break;
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);
86 }
87 }
88 return ConvertPropVariantToString(propVariant);
89 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698