From ec6ebc495d27a40e23dc38416ef87170ae622da3 Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Fri, 28 Jan 2000 06:17:06 +0000 Subject: [PATCH] Removing WIN API which requires windows 98 or better. Fixes 25101, and others. I erronously checked in a fix which still linked with this non-win95 API. So, now I am just defaulting to standard GetFileAttributes() and doing away with the EX version. git-svn-id: svn://10.0.0.236/trunk@59028 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/io/nsLocalFileWin.cpp | 107 ++++++++++++---------------- 1 file changed, 47 insertions(+), 60 deletions(-) diff --git a/mozilla/xpcom/io/nsLocalFileWin.cpp b/mozilla/xpcom/io/nsLocalFileWin.cpp index f48efbab4ac..00e338652ef 100644 --- a/mozilla/xpcom/io/nsLocalFileWin.cpp +++ b/mozilla/xpcom/io/nsLocalFileWin.cpp @@ -122,72 +122,57 @@ MyGetFileAttributesEx(const char* file, WIN32_FILE_ATTRIBUTE_DATA* data) if (!data || !file) return NS_ERROR_FAILURE; - HINSTANCE hInst = LoadLibrary("KERNEL32.DLL"); - NS_ASSERTION(hInst != NULL, "COULD NOT LOAD KERNEL32.DLL"); - if (hInst != NULL) - { - if (GetProcAddress(hInst, "GetFileAttributesEx")) + okay = PR_FALSE; + + memset(data, 0, sizeof(WIN32_FILE_ATTRIBUTE_DATA)); + data->dwFileAttributes = GetFileAttributes(file); + + if(data->dwFileAttributes != 0xFFFFFFFF) + { + if(! (data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - okay = GetFileAttributesEx(file,GetFileExInfoStandard,data); + HANDLE hFile = CreateFile(file, + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if (hFile != INVALID_HANDLE_VALUE) + { + okay = GetFileTime(hFile, + &data->ftCreationTime, + &data->ftLastAccessTime, + &data->ftLastWriteTime); + if (okay) + { + // Try to obtain hFile's huge size. + data->nFileSizeLow = GetFileSize (hFile, + &data->nFileSizeHigh); + + if (data->nFileSizeLow == 0xFFFFFFFF && + GetLastError() != NO_ERROR ) + { + //error in getting filesize + okay = PR_FALSE; + } + else + { + okay = PR_TRUE; + } + } + + CloseHandle(hFile); + } } else { - okay = PR_FALSE; - - memset(data, 0, sizeof(WIN32_FILE_ATTRIBUTE_DATA)); - data->dwFileAttributes = GetFileAttributes(file); - - if(data->dwFileAttributes != 0xFFFFFFFF) - { - - if(! (data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) - { - HANDLE hFile = CreateFile(file, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile != INVALID_HANDLE_VALUE) - { - okay = GetFileTime(hFile, - &data->ftCreationTime, - &data->ftLastAccessTime, - &data->ftLastWriteTime); - if (okay) - { - // Try to obtain hFile's huge size. - data->nFileSizeLow = GetFileSize (hFile, - &data->nFileSizeHigh); - - if (data->nFileSizeLow == 0xFFFFFFFF && - GetLastError() != NO_ERROR ) - { - //error in getting filesize - okay = PR_FALSE; - } - else - { - okay = PR_TRUE; - } - } - CloseHandle(hFile); - } - } - else - { - // it is a directory, - okay = PR_TRUE; - } - } + // it is a directory, I dont think that there is a wy to get the time or size. + okay = PR_TRUE; } - - FreeLibrary(hInst); } - if (!okay) return ConvertWinError(GetLastError()); @@ -224,7 +209,9 @@ class nsDirEnumerator : public nsISimpleEnumerator mDir = PR_OpenDir(filepath); if (mDir == nsnull) // not a directory? return NS_ERROR_FAILURE; - + + nsAllocator::Free(filepath); + mParent = parent; return NS_OK; }