From c8160055e847dea8f73409a00cfffd4cd7ac87d9 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 3 Oct 2003 03:31:46 +0000 Subject: [PATCH] Implemented GetCompressedFileSize[AW]. --- files/file.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ win32/newfns.c | 31 -------------------------- 2 files changed, 59 insertions(+), 31 deletions(-) diff --git a/files/file.c b/files/file.c index 8125af1df51..b219a27989e 100644 --- a/files/file.c +++ b/files/file.c @@ -987,6 +987,65 @@ BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD attributes) } +/****************************************************************************** + * GetCompressedFileSizeA [KERNEL32.@] + */ +DWORD WINAPI GetCompressedFileSizeA( + LPCSTR lpFileName, + LPDWORD lpFileSizeHigh) +{ + UNICODE_STRING filenameW; + DWORD ret; + + if (RtlCreateUnicodeStringFromAsciiz(&filenameW, lpFileName)) + { + ret = GetCompressedFileSizeW(filenameW.Buffer, lpFileSizeHigh); + RtlFreeUnicodeString(&filenameW); + } + else + { + ret = INVALID_FILE_SIZE; + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + } + return ret; +} + + +/****************************************************************************** + * GetCompressedFileSizeW [KERNEL32.@] + * + * RETURNS + * Success: Low-order doubleword of number of bytes + * Failure: INVALID_FILE_SIZE + */ +DWORD WINAPI GetCompressedFileSizeW( + LPCWSTR lpFileName, /* [in] Pointer to name of file */ + LPDWORD lpFileSizeHigh) /* [out] Receives high-order doubleword of size */ +{ + DOS_FULL_NAME full_name; + struct stat st; + DWORD low; + + TRACE("(%s,%p)\n",debugstr_w(lpFileName),lpFileSizeHigh); + + if (!DOSFS_GetFullName( lpFileName, TRUE, &full_name )) return INVALID_FILE_SIZE; + if (stat(full_name.long_name, &st) != 0) + { + FILE_SetDosError(); + return INVALID_FILE_SIZE; + } +#if HAVE_STRUCT_STAT_ST_BLOCKS + /* blocks are 512 bytes long */ + if (lpFileSizeHigh) *lpFileSizeHigh = (st.st_blocks >> 23); + low = (DWORD)(st.st_blocks << 9); +#else + if (lpFileSizeHigh) *lpFileSizeHigh = (st.st_size >> 32); + low = (DWORD)st.st_size; +#endif + return low; +} + + /*********************************************************************** * GetFileTime (KERNEL32.@) */ diff --git a/win32/newfns.c b/win32/newfns.c index 51ae2ea89d6..83c8f68efc1 100644 --- a/win32/newfns.c +++ b/win32/newfns.c @@ -45,37 +45,6 @@ at a later date. */ WINE_DEFAULT_DEBUG_CHANNEL(win32); -/****************************************************************************** - * GetCompressedFileSizeA [KERNEL32.@] - * - * NOTES - * This should call the W function below - */ -DWORD WINAPI GetCompressedFileSizeA( - LPCSTR lpFileName, - LPDWORD lpFileSizeHigh) -{ - FIXME("(...): stub\n"); - return 0xffffffff; -} - - -/****************************************************************************** - * GetCompressedFileSizeW [KERNEL32.@] - * - * RETURNS - * Success: Low-order doubleword of number of bytes - * Failure: 0xffffffff - */ -DWORD WINAPI GetCompressedFileSizeW( - LPCWSTR lpFileName, /* [in] Pointer to name of file */ - LPDWORD lpFileSizeHigh) /* [out] Receives high-order doubleword of size */ -{ - FIXME("(%s,%p): stub\n",debugstr_w(lpFileName),lpFileSizeHigh); - return 0xffffffff; -} - - /****************************************************************************** * CreateIoCompletionPort (KERNEL32.@) */