mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-06 15:14:59 -06:00
17.00
This commit is contained in:
@@ -117,7 +117,7 @@ bool ClipboardSetText(HWND owner, const UString &s)
|
||||
bool res;
|
||||
res = ClipboardSetData(CF_UNICODETEXT, (const wchar_t *)s, (s.Len() + 1) * sizeof(wchar_t));
|
||||
#ifndef _UNICODE
|
||||
AString a = UnicodeStringToMultiByte(s, CP_ACP);
|
||||
AString a (UnicodeStringToMultiByte(s, CP_ACP));
|
||||
if (ClipboardSetData(CF_TEXT, (const char *)a, (a.Len() + 1) * sizeof(char)))
|
||||
res = true;
|
||||
a = UnicodeStringToMultiByte(s, CP_OEMCP);
|
||||
|
||||
@@ -115,7 +115,7 @@ INT_PTR MyPropertySheet(const CObjectVector<CPageInfo> &pagesInfo, HWND hwndPare
|
||||
sheet.dwFlags = PSH_PROPSHEETPAGE;
|
||||
sheet.hwndParent = hwndParent;
|
||||
sheet.hInstance = g_hInstance;
|
||||
AString titleA = GetSystemString(title);
|
||||
AString titleA (GetSystemString(title));
|
||||
sheet.pszCaption = titleA;
|
||||
sheet.nPages = pagesInfo.Size();
|
||||
sheet.nStartPage = 0;
|
||||
|
||||
@@ -97,12 +97,11 @@ FString GetModuleDirPrefix()
|
||||
{
|
||||
int pos = s.ReverseFind_PathSepar();
|
||||
if (pos >= 0)
|
||||
{
|
||||
s.DeleteFrom(pos + 1);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return FTEXT(".") FSTRING_PATH_SEPARATOR;
|
||||
if (s.IsEmpty())
|
||||
s = "." STRING_PATH_SEPARATOR;
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -53,8 +53,8 @@ UString MyFormatMessage(DWORD errorCode)
|
||||
s[7 - i] = (char)((t < 10) ? ('0' + t) : ('A' + (t - 10)));
|
||||
}
|
||||
s[8] = 0;
|
||||
m.AddAscii("Error #");
|
||||
m.AddAscii(s);
|
||||
m += "Error #";
|
||||
m += s;
|
||||
}
|
||||
else if (m.Len() >= 2
|
||||
&& m[m.Len() - 1] == 0x0A
|
||||
|
||||
@@ -345,7 +345,7 @@ bool CreateComplexDir(CFSTR _path)
|
||||
|
||||
#endif
|
||||
|
||||
FString path = _path;
|
||||
FString path (_path);
|
||||
|
||||
int pos = path.ReverseFind_PathSepar();
|
||||
if (pos >= 0 && (unsigned)pos == path.Len() - 1)
|
||||
@@ -355,7 +355,7 @@ bool CreateComplexDir(CFSTR _path)
|
||||
path.DeleteBack();
|
||||
}
|
||||
|
||||
const FString path2 = path;
|
||||
const FString path2 (path);
|
||||
pos = path.Len();
|
||||
|
||||
for (;;)
|
||||
@@ -452,11 +452,11 @@ bool RemoveDirWithSubItems(const FString &path)
|
||||
|
||||
if (needRemoveSubItems)
|
||||
{
|
||||
FString s = path;
|
||||
FString s (path);
|
||||
s.Add_PathSepar();
|
||||
unsigned prefixSize = s.Len();
|
||||
s += FCHAR_ANY_MASK;
|
||||
NFind::CEnumerator enumerator(s);
|
||||
const unsigned prefixSize = s.Len();
|
||||
NFind::CEnumerator enumerator;
|
||||
enumerator.SetDirPrefix(s);
|
||||
NFind::CFileInfo fi;
|
||||
while (enumerator.Next(fi))
|
||||
{
|
||||
@@ -580,18 +580,18 @@ static bool CreateTempFile(CFSTR prefix, bool addRandom, FString &path, NIO::COu
|
||||
path = prefix;
|
||||
if (addRandom)
|
||||
{
|
||||
FChar s[16];
|
||||
UInt32 value = d;
|
||||
char s[16];
|
||||
UInt32 val = d;
|
||||
unsigned k;
|
||||
for (k = 0; k < 8; k++)
|
||||
{
|
||||
unsigned t = value & 0xF;
|
||||
value >>= 4;
|
||||
s[k] = (FChar)((t < 10) ? ('0' + t) : ('A' + (t - 10)));
|
||||
unsigned t = val & 0xF;
|
||||
val >>= 4;
|
||||
s[k] = (char)((t < 10) ? ('0' + t) : ('A' + (t - 10)));
|
||||
}
|
||||
s[k] = '\0';
|
||||
if (outFile)
|
||||
path += FChar('.');
|
||||
path += '.';
|
||||
path += s;
|
||||
UInt32 step = GetTickCount() + 2;
|
||||
if (step == 0)
|
||||
@@ -600,7 +600,7 @@ static bool CreateTempFile(CFSTR prefix, bool addRandom, FString &path, NIO::COu
|
||||
}
|
||||
addRandom = true;
|
||||
if (outFile)
|
||||
path += FTEXT(".tmp");
|
||||
path += ".tmp";
|
||||
if (NFind::DoesFileOrDirExist(path))
|
||||
{
|
||||
SetLastError(ERROR_ALREADY_EXISTS);
|
||||
|
||||
@@ -227,7 +227,7 @@ bool CStreamInfo::IsMainStream() const throw()
|
||||
UString CStreamInfo::GetReducedName() const
|
||||
{
|
||||
// remove ":$DATA" postfix, but keep postfix, if Name is "::$DATA"
|
||||
UString s = Name;
|
||||
UString s (Name);
|
||||
if (s.Len() > 6 + 1 && StringsAreEqualNoCase_Ascii(s.RightPtr(6), ":$DATA"))
|
||||
s.DeleteFrom(s.Len() - 6);
|
||||
return s;
|
||||
@@ -453,7 +453,7 @@ bool CFileInfo::Find(CFSTR path)
|
||||
if (colonPos >= 0 && path[(unsigned)colonPos + 1] != 0)
|
||||
{
|
||||
UString streamName = fs2us(path + (unsigned)colonPos);
|
||||
FString filePath = path;
|
||||
FString filePath (path);
|
||||
filePath.DeleteFrom(colonPos);
|
||||
/* we allow both cases:
|
||||
name:stream
|
||||
@@ -462,7 +462,7 @@ bool CFileInfo::Find(CFSTR path)
|
||||
const unsigned kPostfixSize = 6;
|
||||
if (streamName.Len() <= kPostfixSize
|
||||
|| !StringsAreEqualNoCase_Ascii(streamName.RightPtr(kPostfixSize), ":$DATA"))
|
||||
streamName += L":$DATA";
|
||||
streamName += ":$DATA";
|
||||
|
||||
bool isOk = true;
|
||||
|
||||
@@ -559,9 +559,9 @@ bool CFileInfo::Find(CFSTR path)
|
||||
{
|
||||
if (NName::FindSepar(path + prefixSize) < 0)
|
||||
{
|
||||
FString s = path;
|
||||
FString s (path);
|
||||
s.Add_PathSepar();
|
||||
s += FCHAR_ANY_MASK;
|
||||
s += '*'; // CHAR_ANY_MASK
|
||||
|
||||
bool isOK = false;
|
||||
if (finder.FindFirst(s, *this))
|
||||
@@ -618,6 +618,12 @@ bool DoesFileOrDirExist(CFSTR name)
|
||||
}
|
||||
|
||||
|
||||
void CEnumerator::SetDirPrefix(const FString &dirPrefix)
|
||||
{
|
||||
_wildcard = dirPrefix;
|
||||
_wildcard += '*';
|
||||
}
|
||||
|
||||
bool CEnumerator::NextAny(CFileInfo &fi)
|
||||
{
|
||||
if (_findFile.IsHandleAllocated())
|
||||
|
||||
@@ -134,7 +134,7 @@ class CEnumerator
|
||||
|
||||
bool NextAny(CFileInfo &fileInfo);
|
||||
public:
|
||||
CEnumerator(const FString &wildcard): _wildcard(wildcard) {}
|
||||
void SetDirPrefix(const FString &dirPrefix);
|
||||
bool Next(CFileInfo &fileInfo);
|
||||
bool Next(CFileInfo &fileInfo, bool &found);
|
||||
};
|
||||
|
||||
@@ -74,7 +74,7 @@ static const UInt32 kReparseFlags_Microsoft = ((UInt32)1 << 31);
|
||||
#define Set16(p, v) SetUi16(p, v)
|
||||
#define Set32(p, v) SetUi32(p, v)
|
||||
|
||||
static const wchar_t *k_LinkPrefix = L"\\??\\";
|
||||
static const wchar_t * const k_LinkPrefix = L"\\??\\";
|
||||
static const unsigned k_LinkPrefix_Size = 4;
|
||||
|
||||
static const bool IsLinkPrefix(const wchar_t *s)
|
||||
@@ -83,7 +83,7 @@ static const bool IsLinkPrefix(const wchar_t *s)
|
||||
}
|
||||
|
||||
/*
|
||||
static const wchar_t *k_VolumePrefix = L"Volume{";
|
||||
static const wchar_t * const k_VolumePrefix = L"Volume{";
|
||||
static const bool IsVolumeName(const wchar_t *s)
|
||||
{
|
||||
return IsString1PrefixedByString2(s, k_VolumePrefix);
|
||||
@@ -332,7 +332,7 @@ bool CReparseAttr::IsVolume() const
|
||||
|
||||
UString CReparseAttr::GetPath() const
|
||||
{
|
||||
UString s = SubsName;
|
||||
UString s (SubsName);
|
||||
if (IsLinkPrefix(s))
|
||||
{
|
||||
s.ReplaceOneCharAtPos(1, '\\');
|
||||
@@ -376,7 +376,7 @@ bool GetReparseData(CFSTR path, CByteBuffer &reparseData, BY_HANDLE_FILE_INFORMA
|
||||
|
||||
static bool CreatePrefixDirOfFile(CFSTR path)
|
||||
{
|
||||
FString path2 = path;
|
||||
FString path2 (path);
|
||||
int pos = path2.ReverseFind_PathSepar();
|
||||
if (pos < 0)
|
||||
return true;
|
||||
|
||||
@@ -87,8 +87,8 @@ bool IsAltPathPrefix(CFSTR s) throw()
|
||||
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
|
||||
const wchar_t *kSuperPathPrefix = L"\\\\?\\";
|
||||
static const wchar_t *kSuperUncPrefix = L"\\\\?\\UNC\\";
|
||||
const char * const kSuperPathPrefix = "\\\\?\\";
|
||||
static const char * const kSuperUncPrefix = "\\\\?\\UNC\\";
|
||||
|
||||
#define IS_DEVICE_PATH(s) (IS_SEPAR((s)[0]) && IS_SEPAR((s)[1]) && (s)[2] == '.' && IS_SEPAR((s)[3]))
|
||||
#define IS_SUPER_PREFIX(s) (IS_SEPAR((s)[0]) && IS_SEPAR((s)[1]) && (s)[2] == '?' && IS_SEPAR((s)[3]))
|
||||
@@ -109,7 +109,7 @@ bool IsDevicePath(CFSTR s) throw()
|
||||
/*
|
||||
// actually we don't know the way to open device file in WinCE.
|
||||
unsigned len = MyStringLen(s);
|
||||
if (len < 5 || len > 5 || memcmp(s, FTEXT("DSK"), 3 * sizeof(FChar)) != 0)
|
||||
if (len < 5 || len > 5 || !IsString1PrefixedByString2(s, "DSK"))
|
||||
return false;
|
||||
if (s[4] != ':')
|
||||
return false;
|
||||
@@ -123,7 +123,7 @@ bool IsDevicePath(CFSTR s) throw()
|
||||
unsigned len = MyStringLen(s);
|
||||
if (len == 6 && s[5] == ':')
|
||||
return true;
|
||||
if (len < 18 || len > 22 || memcmp(s + kDevicePathPrefixSize, FTEXT("PhysicalDrive"), 13 * sizeof(FChar)) != 0)
|
||||
if (len < 18 || len > 22 || !IsString1PrefixedByString2(s + kDevicePathPrefixSize, "PhysicalDrive"))
|
||||
return false;
|
||||
for (unsigned i = 17; i < len; i++)
|
||||
if (s[i] < '0' || s[i] > '9')
|
||||
@@ -191,14 +191,12 @@ bool IsSuperPath(CFSTR s) throw() { return IS_SUPER_PREFIX(s); }
|
||||
bool IsSuperOrDevicePath(CFSTR s) throw() { return IS_SUPER_OR_DEVICE_PATH(s); }
|
||||
#endif // USE_UNICODE_FSTRING
|
||||
|
||||
/*
|
||||
bool IsDrivePath_SuperAllowed(CFSTR s)
|
||||
bool IsDrivePath_SuperAllowed(CFSTR s) throw()
|
||||
{
|
||||
if (IsSuperPath(s))
|
||||
s += kSuperPathPrefixSize;
|
||||
return IsDrivePath(s);
|
||||
}
|
||||
*/
|
||||
|
||||
bool IsDriveRootPath_SuperAllowed(CFSTR s) throw()
|
||||
{
|
||||
@@ -212,7 +210,7 @@ bool IsAbsolutePath(const wchar_t *s) throw()
|
||||
return IS_SEPAR(s[0]) || IsDrivePath2(s);
|
||||
}
|
||||
|
||||
int FindAltStreamColon(CFSTR path)
|
||||
int FindAltStreamColon(CFSTR path) throw()
|
||||
{
|
||||
unsigned i = 0;
|
||||
if (IsDrivePath2(path))
|
||||
@@ -274,7 +272,7 @@ static unsigned GetRootPrefixSize_Of_SuperPath(CFSTR s)
|
||||
return kSuperPathPrefixSize + pos + 1;
|
||||
}
|
||||
|
||||
unsigned GetRootPrefixSize(CFSTR s)
|
||||
unsigned GetRootPrefixSize(CFSTR s) throw()
|
||||
{
|
||||
if (IS_DEVICE_PATH(s))
|
||||
return kDevicePathPrefixSize;
|
||||
@@ -285,7 +283,7 @@ unsigned GetRootPrefixSize(CFSTR s)
|
||||
|
||||
#endif // USE_UNICODE_FSTRING
|
||||
|
||||
static unsigned GetRootPrefixSize_Of_NetworkPath(const wchar_t *s)
|
||||
static unsigned GetRootPrefixSize_Of_NetworkPath(const wchar_t *s) throw()
|
||||
{
|
||||
// Network path: we look "server\path\" as root prefix
|
||||
int pos = FindSepar(s);
|
||||
@@ -297,7 +295,7 @@ static unsigned GetRootPrefixSize_Of_NetworkPath(const wchar_t *s)
|
||||
return pos + pos2 + 2;
|
||||
}
|
||||
|
||||
static unsigned GetRootPrefixSize_Of_SimplePath(const wchar_t *s)
|
||||
static unsigned GetRootPrefixSize_Of_SimplePath(const wchar_t *s) throw()
|
||||
{
|
||||
if (IsDrivePath(s))
|
||||
return kDrivePrefixSize;
|
||||
@@ -309,7 +307,7 @@ static unsigned GetRootPrefixSize_Of_SimplePath(const wchar_t *s)
|
||||
return (size == 0) ? 0 : 2 + size;
|
||||
}
|
||||
|
||||
static unsigned GetRootPrefixSize_Of_SuperPath(const wchar_t *s)
|
||||
static unsigned GetRootPrefixSize_Of_SuperPath(const wchar_t *s) throw()
|
||||
{
|
||||
if (IS_UNC_WITH_SLASH(s + kSuperPathPrefixSize))
|
||||
{
|
||||
@@ -628,7 +626,7 @@ static bool GetSuperPathBase(CFSTR s, UString &res)
|
||||
|
||||
unsigned fixedSizeStart = 0;
|
||||
unsigned fixedSize = 0;
|
||||
const wchar_t *superMarker = NULL;
|
||||
const char *superMarker = NULL;
|
||||
if (IsSuperPath(curDir))
|
||||
{
|
||||
fixedSize = GetRootPrefixSize_Of_SuperPath(curDir);
|
||||
|
||||
@@ -23,7 +23,7 @@ bool IsAltPathPrefix(CFSTR s) throw(); /* name: */
|
||||
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
|
||||
extern const wchar_t *kSuperPathPrefix; /* \\?\ */
|
||||
extern const char * const kSuperPathPrefix; /* \\?\ */
|
||||
const unsigned kDevicePathPrefixSize = 4;
|
||||
const unsigned kSuperPathPrefixSize = 4;
|
||||
const unsigned kSuperUncPathPrefixSize = kSuperPathPrefixSize + 4;
|
||||
@@ -42,7 +42,7 @@ unsigned GetNetworkServerPrefixSize(CFSTR s) throw();
|
||||
|
||||
bool IsNetworkShareRootPath(CFSTR s) throw(); /* \\?\UNC\SERVER\share or \\SERVER\share or with slash */
|
||||
|
||||
// bool IsDrivePath_SuperAllowed(CFSTR s) throw(); // first chars are drive chars like "a:\" or "\\?\a:\"
|
||||
bool IsDrivePath_SuperAllowed(CFSTR s) throw(); // first chars are drive chars like "a:\" or "\\?\a:\"
|
||||
bool IsDriveRootPath_SuperAllowed(CFSTR s) throw(); // exact drive root path "a:\" or "\\?\a:\"
|
||||
|
||||
bool IsDrivePath2(const wchar_t *s) throw(); // first 2 chars are drive chars like "a:"
|
||||
@@ -71,7 +71,7 @@ unsigned GetRootPrefixSize(CFSTR s) throw();
|
||||
|
||||
#endif
|
||||
|
||||
int FindAltStreamColon(CFSTR path);
|
||||
int FindAltStreamColon(CFSTR path) throw();
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
|
||||
@@ -364,8 +364,8 @@ DWORD AddConnection2(const CResourceW &resource, LPCWSTR password, LPCWSTR userN
|
||||
}
|
||||
CResource resourceA;
|
||||
ConvertResourceWToResource(resource, resourceA);
|
||||
CSysString passwordA = GetSystemString(password);
|
||||
CSysString userNameA = GetSystemString(userName);
|
||||
const CSysString passwordA (GetSystemString(password));
|
||||
const CSysString userNameA (GetSystemString(userName));
|
||||
return AddConnection2(resourceA,
|
||||
password ? (LPCTSTR)passwordA: 0,
|
||||
userName ? (LPCTSTR)userNameA: 0,
|
||||
|
||||
@@ -15,9 +15,9 @@ namespace NWindows {
|
||||
#ifndef UNDER_CE
|
||||
static UString GetQuotedString(const UString &s)
|
||||
{
|
||||
UString s2 = L'\"';
|
||||
UString s2 ('\"');
|
||||
s2 += s;
|
||||
s2 += L'\"';
|
||||
s2 += '\"';
|
||||
return s2;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -91,7 +91,7 @@ CPropVariant& CPropVariant::operator=(BSTR bstrSrc)
|
||||
return *this;
|
||||
}
|
||||
|
||||
static const char *kMemException = "out of memory";
|
||||
static const char * const kMemException = "out of memory";
|
||||
|
||||
CPropVariant& CPropVariant::operator=(LPCOLESTR lpszSrc)
|
||||
{
|
||||
|
||||
@@ -80,6 +80,8 @@ public:
|
||||
CPropVariant& operator=(const UString &s);
|
||||
CPropVariant& operator=(const UString2 &s);
|
||||
CPropVariant& operator=(const char *s);
|
||||
CPropVariant& operator=(const AString &s)
|
||||
{ return (*this)=(const char *)s; }
|
||||
|
||||
CPropVariant& operator=(bool bSrc) throw();
|
||||
CPropVariant& operator=(Byte value) throw();
|
||||
|
||||
@@ -9,21 +9,24 @@
|
||||
|
||||
#define UINT_TO_STR_2(c, val) { s[0] = (c); s[1] = (char)('0' + (val) / 10); s[2] = (char)('0' + (val) % 10); s += 3; }
|
||||
|
||||
bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime, bool includeSeconds) throw()
|
||||
bool ConvertUtcFileTimeToString(const FILETIME &utc, char *s, int level) throw()
|
||||
{
|
||||
*s = 0;
|
||||
FILETIME ft;
|
||||
if (!FileTimeToLocalFileTime(&utc, &ft))
|
||||
return false;
|
||||
|
||||
SYSTEMTIME st;
|
||||
if (!BOOLToBool(FileTimeToSystemTime(&ft, &st)))
|
||||
{
|
||||
*s = 0;
|
||||
return false;
|
||||
}
|
||||
unsigned val = st.wYear;
|
||||
if (val >= 10000)
|
||||
{
|
||||
*s++ = (char)('0' + val / 10000);
|
||||
val %= 10000;
|
||||
}
|
||||
|
||||
{
|
||||
unsigned val = st.wYear;
|
||||
if (val >= 10000)
|
||||
{
|
||||
*s++ = (char)('0' + val / 10000);
|
||||
val %= 10000;
|
||||
}
|
||||
s[3] = (char)('0' + val % 10); val /= 10;
|
||||
s[2] = (char)('0' + val % 10); val /= 10;
|
||||
s[1] = (char)('0' + val % 10);
|
||||
@@ -32,40 +35,66 @@ bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime, bool
|
||||
}
|
||||
UINT_TO_STR_2('-', st.wMonth);
|
||||
UINT_TO_STR_2('-', st.wDay);
|
||||
if (includeTime)
|
||||
|
||||
if (level > kTimestampPrintLevel_DAY)
|
||||
{
|
||||
UINT_TO_STR_2(' ', st.wHour);
|
||||
UINT_TO_STR_2(':', st.wMinute);
|
||||
if (includeSeconds)
|
||||
|
||||
if (level >= kTimestampPrintLevel_SEC)
|
||||
{
|
||||
UINT_TO_STR_2(':', st.wSecond);
|
||||
/*
|
||||
*s++ = '.';
|
||||
unsigned val = st.wMilliseconds;
|
||||
s[2] = (char)('0' + val % 10); val /= 10;
|
||||
s[1] = (char)('0' + val % 10);
|
||||
s[0] = (char)('0' + val / 10);
|
||||
s += 3;
|
||||
*/
|
||||
|
||||
if (level > kTimestampPrintLevel_SEC)
|
||||
{
|
||||
*s++ = '.';
|
||||
/*
|
||||
{
|
||||
unsigned val = st.wMilliseconds;
|
||||
s[2] = (char)('0' + val % 10); val /= 10;
|
||||
s[1] = (char)('0' + val % 10);
|
||||
s[0] = (char)('0' + val / 10);
|
||||
s += 3;
|
||||
}
|
||||
*s++ = ' ';
|
||||
*/
|
||||
|
||||
{
|
||||
unsigned numDigits = 7;
|
||||
UInt32 val = (UInt32)((((UInt64)ft.dwHighDateTime << 32) + ft.dwLowDateTime) % 10000000);
|
||||
for (unsigned i = numDigits; i != 0;)
|
||||
{
|
||||
i--;
|
||||
s[i] = (char)('0' + val % 10); val /= 10;
|
||||
}
|
||||
if (numDigits > (unsigned)level)
|
||||
numDigits = (unsigned)level;
|
||||
s += numDigits;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*s = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConvertFileTimeToString(const FILETIME &ft, wchar_t *dest, bool includeTime, bool includeSeconds) throw()
|
||||
|
||||
bool ConvertUtcFileTimeToString(const FILETIME &ft, wchar_t *dest, int level) throw()
|
||||
{
|
||||
char s[32];
|
||||
ConvertFileTimeToString(ft, s, includeTime, includeSeconds);
|
||||
bool res = ConvertUtcFileTimeToString(ft, s, level);
|
||||
for (unsigned i = 0;; i++)
|
||||
{
|
||||
unsigned char c = s[i];
|
||||
dest[i] = c;
|
||||
if (c == 0)
|
||||
return;
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
void ConvertPropVariantToShortString(const PROPVARIANT &prop, char *dest) throw()
|
||||
{
|
||||
*dest = 0;
|
||||
@@ -77,7 +106,7 @@ void ConvertPropVariantToShortString(const PROPVARIANT &prop, char *dest) throw(
|
||||
case VT_UI2: ConvertUInt32ToString(prop.uiVal, dest); return;
|
||||
case VT_UI4: ConvertUInt32ToString(prop.ulVal, dest); return;
|
||||
case VT_UI8: ConvertUInt64ToString(prop.uhVal.QuadPart, dest); return;
|
||||
case VT_FILETIME: ConvertFileTimeToString(prop.filetime, dest, true, true); return;
|
||||
case VT_FILETIME: ConvertUtcFileTimeToString(prop.filetime, dest); return;
|
||||
// case VT_I1: return ConvertInt64ToString(prop.cVal, dest); return;
|
||||
case VT_I2: ConvertInt64ToString(prop.iVal, dest); return;
|
||||
case VT_I4: ConvertInt64ToString(prop.lVal, dest); return;
|
||||
@@ -98,7 +127,7 @@ void ConvertPropVariantToShortString(const PROPVARIANT &prop, wchar_t *dest) thr
|
||||
case VT_UI2: ConvertUInt32ToString(prop.uiVal, dest); return;
|
||||
case VT_UI4: ConvertUInt32ToString(prop.ulVal, dest); return;
|
||||
case VT_UI8: ConvertUInt64ToString(prop.uhVal.QuadPart, dest); return;
|
||||
case VT_FILETIME: ConvertFileTimeToString(prop.filetime, dest, true, true); return;
|
||||
case VT_FILETIME: ConvertUtcFileTimeToString(prop.filetime, dest); return;
|
||||
// case VT_I1: return ConvertInt64ToString(prop.cVal, dest); return;
|
||||
case VT_I2: ConvertInt64ToString(prop.iVal, dest); return;
|
||||
case VT_I4: ConvertInt64ToString(prop.lVal, dest); return;
|
||||
|
||||
@@ -6,8 +6,15 @@
|
||||
#include "../Common/MyTypes.h"
|
||||
|
||||
// provide at least 32 bytes for buffer including zero-end
|
||||
bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime = true, bool includeSeconds = true) throw();
|
||||
void ConvertFileTimeToString(const FILETIME &ft, wchar_t *s, bool includeTime = true, bool includeSeconds = true) throw();
|
||||
|
||||
#define kTimestampPrintLevel_DAY -3
|
||||
// #define kTimestampPrintLevel_HOUR -2
|
||||
#define kTimestampPrintLevel_MIN -1
|
||||
#define kTimestampPrintLevel_SEC 0
|
||||
#define kTimestampPrintLevel_NTFS 7
|
||||
|
||||
bool ConvertUtcFileTimeToString(const FILETIME &ft, char *s, int level = kTimestampPrintLevel_SEC) throw();
|
||||
bool ConvertUtcFileTimeToString(const FILETIME &ft, wchar_t *s, int level = kTimestampPrintLevel_SEC) throw();
|
||||
|
||||
// provide at least 32 bytes for buffer including zero-end
|
||||
// don't send VT_BSTR to these functions
|
||||
|
||||
@@ -8,27 +8,32 @@
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
static AString GetHex(UInt32 v)
|
||||
static void AddHex(AString &s, UInt32 v)
|
||||
{
|
||||
char sz[16];
|
||||
sz[0] = '0';
|
||||
sz[1] = 'x';
|
||||
ConvertUInt32ToHex(v, sz + 2);
|
||||
return sz;
|
||||
s += sz;
|
||||
}
|
||||
|
||||
|
||||
AString TypePairToString(const CUInt32PCharPair *pairs, unsigned num, UInt32 value)
|
||||
{
|
||||
AString s;
|
||||
char sz[16];
|
||||
const char *p = NULL;
|
||||
for (unsigned i = 0; i < num; i++)
|
||||
{
|
||||
const CUInt32PCharPair &p = pairs[i];
|
||||
if (p.Value == value)
|
||||
s = p.Name;
|
||||
const CUInt32PCharPair &pair = pairs[i];
|
||||
if (pair.Value == value)
|
||||
p = pair.Name;
|
||||
}
|
||||
if (s.IsEmpty())
|
||||
s = GetHex(value);
|
||||
return s;
|
||||
if (!p)
|
||||
{
|
||||
ConvertUInt32ToString(value, sz);
|
||||
p = sz;
|
||||
}
|
||||
return (AString)p;
|
||||
}
|
||||
|
||||
void PairToProp(const CUInt32PCharPair *pairs, unsigned num, UInt32 value, NCOM::CPropVariant &prop)
|
||||
@@ -39,14 +44,30 @@ void PairToProp(const CUInt32PCharPair *pairs, unsigned num, UInt32 value, NCOM:
|
||||
|
||||
AString TypeToString(const char * const table[], unsigned num, UInt32 value)
|
||||
{
|
||||
char sz[16];
|
||||
const char *p = NULL;
|
||||
if (value < num)
|
||||
return table[value];
|
||||
return GetHex(value);
|
||||
p = table[value];
|
||||
if (!p)
|
||||
{
|
||||
ConvertUInt32ToString(value, sz);
|
||||
p = sz;
|
||||
}
|
||||
return (AString)p;
|
||||
}
|
||||
|
||||
void TypeToProp(const char * const table[], unsigned num, UInt32 value, NCOM::CPropVariant &prop)
|
||||
void TypeToProp(const char * const table[], unsigned num, UInt32 value, NWindows::NCOM::CPropVariant &prop)
|
||||
{
|
||||
prop = TypeToString(table, num, value);
|
||||
char sz[16];
|
||||
const char *p = NULL;
|
||||
if (value < num)
|
||||
p = table[value];
|
||||
if (!p)
|
||||
{
|
||||
ConvertUInt32ToString(value, sz);
|
||||
p = sz;
|
||||
}
|
||||
prop = p;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,20 +80,17 @@ AString FlagsToString(const char * const *names, unsigned num, UInt32 flags)
|
||||
if ((flags & flag) != 0)
|
||||
{
|
||||
const char *name = names[i];
|
||||
if (name != 0 && name[0] != 0)
|
||||
if (name && name[0] != 0)
|
||||
{
|
||||
if (!s.IsEmpty())
|
||||
s += ' ';
|
||||
s += name;
|
||||
s.Add_OptSpaced(name);
|
||||
flags &= ~flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flags != 0)
|
||||
{
|
||||
if (!s.IsEmpty())
|
||||
s += ' ';
|
||||
s += GetHex(flags);
|
||||
s.Add_Space_if_NotEmpty();
|
||||
AddHex(s, flags);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
@@ -87,23 +105,23 @@ AString FlagsToString(const CUInt32PCharPair *pairs, unsigned num, UInt32 flags)
|
||||
if ((flags & flag) != 0)
|
||||
{
|
||||
if (p.Name[0] != 0)
|
||||
{
|
||||
if (!s.IsEmpty())
|
||||
s += ' ';
|
||||
s += p.Name;
|
||||
}
|
||||
s.Add_OptSpaced(p.Name);
|
||||
}
|
||||
flags &= ~flag;
|
||||
}
|
||||
if (flags != 0)
|
||||
{
|
||||
if (!s.IsEmpty())
|
||||
s += ' ';
|
||||
s += GetHex(flags);
|
||||
s.Add_Space_if_NotEmpty();
|
||||
AddHex(s, flags);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
void FlagsToProp(const char * const *names, unsigned num, UInt32 flags, NCOM::CPropVariant &prop)
|
||||
{
|
||||
prop = FlagsToString(names, num, flags);
|
||||
}
|
||||
|
||||
void FlagsToProp(const CUInt32PCharPair *pairs, unsigned num, UInt32 flags, NCOM::CPropVariant &prop)
|
||||
{
|
||||
prop = FlagsToString(pairs, num, flags);
|
||||
@@ -120,24 +138,18 @@ AString Flags64ToString(const CUInt32PCharPair *pairs, unsigned num, UInt64 flag
|
||||
if ((flags & flag) != 0)
|
||||
{
|
||||
if (p.Name[0] != 0)
|
||||
{
|
||||
if (!s.IsEmpty())
|
||||
s += ' ';
|
||||
s += p.Name;
|
||||
}
|
||||
s.Add_OptSpaced(p.Name);
|
||||
}
|
||||
flags &= ~flag;
|
||||
}
|
||||
if (flags != 0)
|
||||
{
|
||||
if (!s.IsEmpty())
|
||||
s += ' ';
|
||||
{
|
||||
char sz[32];
|
||||
sz[0] = '0';
|
||||
sz[1] = 'x';
|
||||
ConvertUInt64ToHex(flags, sz + 2);
|
||||
s += sz;
|
||||
s.Add_OptSpaced(sz);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
|
||||
@@ -18,6 +18,7 @@ void PairToProp(const CUInt32PCharPair *pairs, unsigned num, UInt32 value, NWind
|
||||
|
||||
AString FlagsToString(const char * const *names, unsigned num, UInt32 flags);
|
||||
AString FlagsToString(const CUInt32PCharPair *pairs, unsigned num, UInt32 flags);
|
||||
void FlagsToProp(const char * const *names, unsigned num, UInt32 flags, NWindows::NCOM::CPropVariant &prop);
|
||||
void FlagsToProp(const CUInt32PCharPair *pairs, unsigned num, UInt32 flags, NWindows::NCOM::CPropVariant &prop);
|
||||
|
||||
AString TypeToString(const char * const table[], unsigned num, UInt32 value);
|
||||
|
||||
@@ -153,8 +153,8 @@ bool BrowseForFolder(HWND /* owner */, LPCTSTR /* title */,
|
||||
MessageBoxW(0, L"yes", L"", 0);
|
||||
*/
|
||||
/*
|
||||
UString s = L"all files";
|
||||
s += L" (*.*)";
|
||||
UString s = "all files";
|
||||
s += " (*.*)";
|
||||
return MyGetOpenFileName(owner, title, initialFolder, s, resultPath, true);
|
||||
*/
|
||||
return false;
|
||||
|
||||
@@ -11,12 +11,42 @@
|
||||
namespace NWindows {
|
||||
namespace NSystem {
|
||||
|
||||
UInt32 CountAffinity(DWORD_PTR mask)
|
||||
{
|
||||
UInt32 num = 0;
|
||||
for (unsigned i = 0; i < sizeof(mask) * 8; i++)
|
||||
num += (UInt32)((mask >> i) & 1);
|
||||
return num;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
BOOL CProcessAffinity::Get()
|
||||
{
|
||||
#ifndef UNDER_CE
|
||||
return GetProcessAffinityMask(GetCurrentProcess(), &processAffinityMask, &systemAffinityMask);
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
UInt32 GetNumberOfProcessors()
|
||||
{
|
||||
// We need to know how many threads we can use.
|
||||
// By default the process is assigned to one group.
|
||||
// So we get the number of logical processors (threads)
|
||||
// assigned to current process in the current group.
|
||||
// Group size can be smaller than total number logical processors, for exammple, 2x36
|
||||
|
||||
CProcessAffinity pa;
|
||||
|
||||
if (pa.Get() && pa.processAffinityMask != 0)
|
||||
return pa.GetNumProcessThreads();
|
||||
|
||||
SYSTEM_INFO systemInfo;
|
||||
GetSystemInfo(&systemInfo);
|
||||
// the number of logical processors in the current group
|
||||
return (UInt32)systemInfo.dwNumberOfProcessors;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,29 @@
|
||||
namespace NWindows {
|
||||
namespace NSystem {
|
||||
|
||||
UInt32 CountAffinity(DWORD_PTR mask);
|
||||
|
||||
struct CProcessAffinity
|
||||
{
|
||||
// UInt32 numProcessThreads;
|
||||
// UInt32 numSysThreads;
|
||||
DWORD_PTR processAffinityMask;
|
||||
DWORD_PTR systemAffinityMask;
|
||||
|
||||
void InitST()
|
||||
{
|
||||
// numProcessThreads = 1;
|
||||
// numSysThreads = 1;
|
||||
processAffinityMask = 1;
|
||||
systemAffinityMask = 1;
|
||||
}
|
||||
|
||||
UInt32 GetNumProcessThreads() const { return CountAffinity(processAffinityMask); }
|
||||
UInt32 GetNumSystemThreads() const { return CountAffinity(systemAffinityMask); }
|
||||
|
||||
BOOL Get();
|
||||
};
|
||||
|
||||
UInt32 GetNumberOfProcessors();
|
||||
|
||||
bool GetRamSize(UInt64 &size); // returns false, if unknown ram size
|
||||
|
||||
@@ -115,16 +115,26 @@ bool FileTimeToDosTime(const FILETIME &ft, UInt32 &dosTime) throw()
|
||||
return true;
|
||||
}
|
||||
|
||||
UInt64 UnixTimeToFileTime64(UInt32 unixTime) throw()
|
||||
{
|
||||
return (kUnixTimeOffset + (UInt64)unixTime) * kNumTimeQuantumsInSecond;
|
||||
}
|
||||
|
||||
void UnixTimeToFileTime(UInt32 unixTime, FILETIME &ft) throw()
|
||||
{
|
||||
UInt64 v = (kUnixTimeOffset + (UInt64)unixTime) * kNumTimeQuantumsInSecond;
|
||||
UInt64 v = UnixTimeToFileTime64(unixTime);
|
||||
ft.dwLowDateTime = (DWORD)v;
|
||||
ft.dwHighDateTime = (DWORD)(v >> 32);
|
||||
}
|
||||
|
||||
UInt64 UnixTime64ToFileTime64(Int64 unixTime) throw()
|
||||
{
|
||||
return (UInt64)(kUnixTimeOffset + unixTime) * kNumTimeQuantumsInSecond;
|
||||
}
|
||||
|
||||
bool UnixTime64ToFileTime(Int64 unixTime, FILETIME &ft) throw()
|
||||
{
|
||||
if (unixTime > kNumSecondsInFileTime - kUnixTimeOffset)
|
||||
if (unixTime > (Int64)(kNumSecondsInFileTime - kUnixTimeOffset))
|
||||
{
|
||||
ft.dwLowDateTime = ft.dwHighDateTime = (UInt32)(Int32)-1;
|
||||
return false;
|
||||
@@ -144,7 +154,7 @@ bool UnixTime64ToFileTime(Int64 unixTime, FILETIME &ft) throw()
|
||||
Int64 FileTimeToUnixTime64(const FILETIME &ft) throw()
|
||||
{
|
||||
UInt64 winTime = (((UInt64)ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
|
||||
return (Int64)(winTime / kNumTimeQuantumsInSecond) - kUnixTimeOffset;
|
||||
return (Int64)(winTime / kNumTimeQuantumsInSecond) - (Int64)kUnixTimeOffset;
|
||||
}
|
||||
|
||||
bool FileTimeToUnixTime(const FILETIME &ft, UInt32 &unixTime) throw()
|
||||
|
||||
@@ -11,10 +11,18 @@ namespace NTime {
|
||||
|
||||
bool DosTimeToFileTime(UInt32 dosTime, FILETIME &fileTime) throw();
|
||||
bool FileTimeToDosTime(const FILETIME &fileTime, UInt32 &dosTime) throw();
|
||||
|
||||
// UInt32 Unix Time : for dates 1970-2106
|
||||
UInt64 UnixTimeToFileTime64(UInt32 unixTime) throw();
|
||||
void UnixTimeToFileTime(UInt32 unixTime, FILETIME &fileTime) throw();
|
||||
|
||||
// Int64 Unix Time : negative values for dates before 1970
|
||||
UInt64 UnixTime64ToFileTime64(Int64 unixTime) throw();
|
||||
bool UnixTime64ToFileTime(Int64 unixTime, FILETIME &fileTime) throw();
|
||||
|
||||
bool FileTimeToUnixTime(const FILETIME &fileTime, UInt32 &unixTime) throw();
|
||||
Int64 FileTimeToUnixTime64(const FILETIME &ft) throw();
|
||||
|
||||
bool GetSecondsSince1601(unsigned year, unsigned month, unsigned day,
|
||||
unsigned hour, unsigned min, unsigned sec, UInt64 &resSeconds) throw();
|
||||
void GetCurUtcFileTime(FILETIME &ft) throw();
|
||||
|
||||
Reference in New Issue
Block a user