aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDennis Syrovatsky <dennis@tightvnc.com>2005-10-26 01:10:22 +0000
committerDennis Syrovatsky <dennis@tightvnc.com>2005-10-26 01:10:22 +0000
commit05c448f948a9a4e2b251489996529f968f6a4ac3 (patch)
tree9c65684cadefa82c270b48f8f757ccbc628d95a3
parent4691feb7495a36ec14a57d0bfdcc55a21a24ebf0 (diff)
downloadtigervnc-05c448f948a9a4e2b251489996529f968f6a4ac3.tar.gz
tigervnc-05c448f948a9a4e2b251489996529f968f6a4ac3.zip
Small code improvements.
Added two methods getTime70 and getFiletime to FolderManager class. Methods renameDir and deleteDir was renamed to renameIt and deleteIt. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@357 3789f03b-4d11-0410-bbf8-ca57d06f2519
-rw-r--r--rfb_win32/FolderManager.cxx62
-rw-r--r--rfb_win32/FolderManager.h11
2 files changed, 62 insertions, 11 deletions
diff --git a/rfb_win32/FolderManager.cxx b/rfb_win32/FolderManager.cxx
index d554cbb0..c261427d 100644
--- a/rfb_win32/FolderManager.cxx
+++ b/rfb_win32/FolderManager.cxx
@@ -45,7 +45,7 @@ FolderManager::createDir(char *pFullPath)
}
bool
-FolderManager::renameDir(char *pOldName, char *pNewName)
+FolderManager::renameIt(char *pOldName, char *pNewName)
{
if (MoveFile(pOldName, pNewName)) return true;
@@ -53,10 +53,14 @@ FolderManager::renameDir(char *pOldName, char *pNewName)
}
bool
-FolderManager::deleteDir(char *pFullPath)
+FolderManager::deleteIt(char *pFullPath)
{
FileInfo fileInfo;
- fileInfo.add(pFullPath, 0, 0, FT_ATTR_DIR);
+
+ FILEINFO FIStruct;
+ if (!getInfo(pFullPath, &FIStruct)) return false;
+
+ fileInfo.add(&FIStruct);
unsigned int num = fileInfo.getNumEntries();
unsigned int last = num - 1;
@@ -128,15 +132,12 @@ FolderManager::getFolderInfo(char *pPath, FileInfo *pFileInfo, unsigned int dirO
do {
if (strcmp(FindFileData.cFileName, ".") != 0 &&
strcmp(FindFileData.cFileName, "..") != 0) {
- LARGE_INTEGER li;
- li.LowPart = FindFileData.ftLastWriteTime.dwLowDateTime;
- li.HighPart = FindFileData.ftLastWriteTime.dwHighDateTime;
- li.QuadPart = (li.QuadPart - 116444736000000000) / 10000000;
+ unsigned int lastWriteTime = getTime70(FindFileData.ftLastWriteTime);
if ((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
- pFileInfo->add(FindFileData.cFileName, 0, li.LowPart, FT_ATTR_DIR);
+ pFileInfo->add(FindFileData.cFileName, 0, lastWriteTime, FT_ATTR_DIR);
} else {
if (!dirOnly)
- pFileInfo->add(FindFileData.cFileName, FindFileData.nFileSizeLow, li.LowPart, FT_ATTR_FILE);
+ pFileInfo->add(FindFileData.cFileName, FindFileData.nFileSizeLow, lastWriteTime, FT_ATTR_FILE);
}
}
@@ -167,3 +168,46 @@ FolderManager::getDrivesInfo(FileInfo *pFileInfo)
}
return true;
}
+
+bool
+FolderManager::getInfo(char *pFullPath, FILEINFO *pFIStruct)
+{
+ WIN32_FIND_DATA FindFileData;
+ SetErrorMode(SEM_FAILCRITICALERRORS);
+ HANDLE hFile = FindFirstFile(pFullPath, &FindFileData);
+ DWORD lastError = GetLastError();
+ SetErrorMode(0);
+ if (hFile != INVALID_HANDLE_VALUE) {
+ FindClose(hFile);
+ strcpy(pFIStruct->name, FindFileData.cFileName);
+ pFIStruct->info.data = getTime70(FindFileData.ftLastWriteTime);
+ if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ pFIStruct->info.size = 0;
+ pFIStruct->info.flags = FT_ATTR_DIR;
+ return true;
+ } else {
+ pFIStruct->info.size = FindFileData.nFileSizeLow;
+ pFIStruct->info.flags = FT_ATTR_FILE;
+ return true;
+ }
+ }
+ return false;
+}
+
+unsigned int
+FolderManager::getTime70(FILETIME ftime)
+{
+ LARGE_INTEGER uli;
+ uli.LowPart = ftime.dwLowDateTime;
+ uli.HighPart = ftime.dwHighDateTime;
+ uli.QuadPart = (uli.QuadPart - 116444736000000000) / 10000000;
+ return uli.LowPart;
+}
+
+void
+FolderManager::getFiletime(unsigned int time70, FILETIME *pftime)
+{
+ LONGLONG ll = Int32x32To64(time70, 10000000) + 116444736000000000;
+ pftime->dwLowDateTime = (DWORD) ll;
+ pftime->dwHighDateTime = (DWORD) (ll >> 32);
+}
diff --git a/rfb_win32/FolderManager.h b/rfb_win32/FolderManager.h
index 6f1839d0..2ef26655 100644
--- a/rfb_win32/FolderManager.h
+++ b/rfb_win32/FolderManager.h
@@ -37,13 +37,20 @@ namespace rfb {
~FolderManager();
bool createDir(char *pFullPath);
- bool renameDir(char *pOldName, char *pNewName);
- bool deleteDir(char *pFullPath);
+
+ bool renameIt(char *pOldName, char *pNewName);
+ bool deleteIt(char *pFullPath);
+
+ bool getInfo(char *pFullPath, FILEINFO *pFIStruct);
bool getFolderInfo(char *pPath, FileInfo *pFileInfo, unsigned int dirOnly);
bool getDrivesInfo(FileInfo *pFI);
private:
bool getFolderInfoWithPrefix(char *pPrefix, FileInfo *pFileInfo);
+
+ unsigned int getTime70(FILETIME ftime);
+ void getFiletime(unsigned int time70, FILETIME *pftime);
+
};
}
}