ReactOS 0.4.15-dev-7887-g64a59a1
filedefext.cpp File Reference
#include "precomp.h"
#include <ndk/iofuncs.h>
#include <ndk/obfuncs.h>
Include dependency graph for filedefext.cpp:

Go to the source code of this file.

Macros

#define NTOS_MODE_USER
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
EXTERN_C BOOL PathIsExeW (LPCWSTR lpszPath)
 
BOOL GetPhysicalFileSize (LPCWSTR PathBuffer, PULARGE_INTEGER Size)
 
UINT SH_FormatInteger (LONGLONG Num, LPWSTR pwszResult, UINT cchResultMax)
 
UINT SH_FormatByteSize (LONGLONG cbSize, LPWSTR pwszResult, UINT cchResultMax)
 
LPWSTR SH_FormatFileSizeWithBytes (const PULARGE_INTEGER lpQwSize, LPWSTR pwszResult, UINT cchResultMax)
 
HPROPSHEETPAGE SH_CreatePropertySheetPage (WORD wDialogId, DLGPROC pfnDlgProc, LPARAM lParam, LPCWSTR pwszTitle)
 

Variables

static const WCHAR s_szShellClassInfo [] = L".ShellClassInfo"
 
static const WCHAR s_szIconIndex [] = L"IconIndex"
 
static const WCHAR s_szIconFile [] = L"IconFile"
 
static const WCHAR s_szIconResource [] = L"IconResource"
 

Macro Definition Documentation

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 24 of file filedefext.cpp.

Function Documentation

◆ GetPhysicalFileSize()

BOOL GetPhysicalFileSize ( LPCWSTR  PathBuffer,
PULARGE_INTEGER  Size 
)

Definition at line 32 of file filedefext.cpp.

33{
40
42 {
43 ERR("RtlDosPathNameToNtPathName_U failed\n");
44 return FALSE;
45 }
46
48 &FileName,
50 NULL,
51 NULL);
59 if (!NT_SUCCESS(Status))
60 {
61 ERR("NtOpenFile failed for %S (Status 0x%08lx)\n", PathBuffer, Status);
62 return FALSE;
63 }
64
65 /* Query the file size */
68 &FileInfo,
69 sizeof(FileInfo),
72 if (!NT_SUCCESS(Status))
73 {
74 ERR("NtQueryInformationFile failed for %S (Status: %08lX)\n", PathBuffer, Status);
75 return FALSE;
76 }
77
78 Size->QuadPart = FileInfo.AllocationSize.QuadPart;
79 return TRUE;
80}
LONG NTSTATUS
Definition: precomp.h:26
#define ERR(fmt,...)
Definition: debug.h:110
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define FILE_SHARE_READ
Definition: compat.h:136
struct _FileName FileName
Definition: fatprocs.h:896
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
Status
Definition: gdiplustypes.h:25
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3952
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define FileStandardInformation
Definition: propsheet.cpp:61
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by CFileDefExt::CountFolderAndFiles(), DECLARE_INTERFACE_(), and CFileDefExt::InitFileAttr().

◆ PathIsExeW()

EXTERN_C BOOL PathIsExeW ( LPCWSTR  lpszPath)

Definition at line 539 of file shellpath.c.

540{
541 LPCWSTR lpszExtension = PathGetExtensionW(lpszPath);
542 int i;
543 static const WCHAR lpszExtensions[][4] =
544 {L"exe", L"com", L"pif", L"cmd", L"bat", L"scf", L"scr", L"" };
545
546 TRACE("path=%s\n",debugstr_w(lpszPath));
547
548 for(i=0; lpszExtensions[i][0]; i++)
549 if (!wcsicmp(lpszExtension,lpszExtensions[i])) return TRUE;
550
551 return FALSE;
552}
#define wcsicmp
Definition: compat.h:15
static LPWSTR PathGetExtensionW(LPCWSTR lpszPath)
Definition: shellpath.c:434
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define debugstr_w
Definition: kernel32.h:32
#define L(x)
Definition: ntvdm.h:50
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

◆ SH_CreatePropertySheetPage()

HPROPSHEETPAGE SH_CreatePropertySheetPage ( WORD  wDialogId,
DLGPROC  pfnDlgProc,
LPARAM  lParam,
LPCWSTR  pwszTitle 
)

Definition at line 302 of file filedefext.cpp.

303{
305
306 memset(&Page, 0x0, sizeof(PROPSHEETPAGEW));
307 Page.dwSize = sizeof(PROPSHEETPAGEW);
308 Page.dwFlags = PSP_DEFAULT;
309 Page.hInstance = shell32_hInstance;
310 Page.pszTemplate = MAKEINTRESOURCE(wDialogId);
311 Page.pfnDlgProc = pfnDlgProc;
312 Page.lParam = lParam;
313 Page.pszTitle = pwszTitle;
314
315 if (pwszTitle)
316 Page.dwFlags |= PSP_USETITLE;
317
319}
#define shell32_hInstance
LPARAM lParam
Definition: combotst.c:139
HPROPSHEETPAGE WINAPI CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage)
Definition: propsheet.c:3083
_In_ PVOID _Out_opt_ BOOLEAN _Out_opt_ PPFN_NUMBER Page
Definition: mm.h:1306
#define PSP_USETITLE
Definition: prsht.h:26
#define PSP_DEFAULT
Definition: prsht.h:22
struct _PROPSHEETPAGEW PROPSHEETPAGEW
#define memset(x, y, z)
Definition: compat.h:39
#define MAKEINTRESOURCE
Definition: winuser.h:591

◆ SH_FormatByteSize()

UINT SH_FormatByteSize ( LONGLONG  cbSize,
LPWSTR  pwszResult,
UINT  cchResultMax 
)

Definition at line 236 of file filedefext.cpp.

237{
238 /* Write formated bytes count */
239 INT cchWritten = SH_FormatInteger(cbSize, pwszResult, cchResultMax);
240 if (!cchWritten)
241 return 0;
242
243 /* Copy " bytes" to buffer */
244 LPWSTR pwszEnd = pwszResult + cchWritten;
245 size_t cchRemaining = cchResultMax - cchWritten;
246 StringCchCopyExW(pwszEnd, cchRemaining, L" ", &pwszEnd, &cchRemaining, 0);
247 cchWritten = LoadStringW(shell32_hInstance, IDS_BYTES_FORMAT, pwszEnd, cchRemaining);
248 cchRemaining -= cchWritten;
249
250 return cchResultMax - cchRemaining;
251}
#define IDS_BYTES_FORMAT
Definition: resource.h:120
UINT SH_FormatInteger(LONGLONG Num, LPWSTR pwszResult, UINT cchResultMax)
Definition: filedefext.cpp:180
STRSAFEAPI StringCchCopyExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags)
Definition: strsafe.h:184
int32_t INT
Definition: typedefs.h:58
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CDrvDefExt::InitGeneralPage(), and SH_FormatFileSizeWithBytes().

◆ SH_FormatFileSizeWithBytes()

LPWSTR SH_FormatFileSizeWithBytes ( const PULARGE_INTEGER  lpQwSize,
LPWSTR  pwszResult,
UINT  cchResultMax 
)

Definition at line 266 of file filedefext.cpp.

267{
268 /* Format bytes in KBs, MBs etc */
269 if (StrFormatByteSizeW(lpQwSize->QuadPart, pwszResult, cchResultMax) == NULL)
270 return NULL;
271
272 /* If there is less bytes than 1KB, we have nothing to do */
273 if (lpQwSize->QuadPart < 1024)
274 return pwszResult;
275
276 /* Concatenate " (" */
277 UINT cchWritten = wcslen(pwszResult);
278 LPWSTR pwszEnd = pwszResult + cchWritten;
279 size_t cchRemaining = cchResultMax - cchWritten;
280 StringCchCopyExW(pwszEnd, cchRemaining, L" (", &pwszEnd, &cchRemaining, 0);
281
282 /* Write formated bytes count */
283 cchWritten = SH_FormatByteSize(lpQwSize->QuadPart, pwszEnd, cchRemaining);
284 pwszEnd += cchWritten;
285 cchRemaining -= cchWritten;
286
287 /* Copy ")" to the buffer */
288 StringCchCopyW(pwszEnd, cchRemaining, L")");
289
290 return pwszResult;
291}
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2388
UINT SH_FormatByteSize(LONGLONG cbSize, LPWSTR pwszResult, UINT cchResultMax)
Definition: filedefext.cpp:236
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
unsigned int UINT
Definition: ndis.h:50
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185

Referenced by CFileDefExt::CountFolderAndFiles(), and CFileDefExt::InitFileAttr().

◆ SH_FormatInteger()

UINT SH_FormatInteger ( LONGLONG  Num,
LPWSTR  pwszResult,
UINT  cchResultMax 
)

Definition at line 180 of file filedefext.cpp.

181{
182 // Print the number in uniform mode
183 WCHAR wszNumber[24];
184 swprintf(wszNumber, L"%I64u", Num);
185
186 // Get system strings for decimal and thousand separators.
187 WCHAR wszDecimalSep[8], wszThousandSep[8];
188 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, wszDecimalSep, _countof(wszDecimalSep));
189 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, wszThousandSep, _countof(wszThousandSep));
190
191 // Initialize format for printing the number in bytes
192 NUMBERFMTW nf;
193 ZeroMemory(&nf, sizeof(nf));
194 nf.lpDecimalSep = wszDecimalSep;
195 nf.lpThousandSep = wszThousandSep;
196
197 // Get system string for groups separator
198 WCHAR wszGrouping[12];
201 wszGrouping,
202 _countof(wszGrouping));
203
204 // Convert grouping specs from string to integer
205 for (INT i = 0; i < cchGrouping; i++)
206 {
207 WCHAR wch = wszGrouping[i];
208
209 if (wch >= L'0' && wch <= L'9')
210 nf.Grouping = nf.Grouping * 10 + (wch - L'0');
211 else if (wch != L';')
212 break;
213 }
214
215 if ((nf.Grouping % 10) == 0)
216 nf.Grouping /= 10;
217 else
218 nf.Grouping *= 10;
219
220 // Format the number
222 0,
223 wszNumber,
224 &nf,
225 pwszResult,
226 cchResultMax);
227
228 if (!cchResult)
229 return 0;
230
231 // GetNumberFormatW returns number of characters including UNICODE_NULL
232 return cchResult - 1;
233}
#define swprintf
Definition: precomp.h:40
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1108
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1212
#define LOCALE_USER_DEFAULT
#define _countof(array)
Definition: sndvol32.h:68
LPWSTR lpDecimalSep
Definition: winnls.h:645
UINT Grouping
Definition: winnls.h:644
LPWSTR lpThousandSep
Definition: winnls.h:646
#define ZeroMemory
Definition: winbase.h:1712
#define LOCALE_SGROUPING
Definition: winnls.h:44
#define LOCALE_SDECIMAL
Definition: winnls.h:42
#define LOCALE_STHOUSAND
Definition: winnls.h:43

Referenced by SH_FormatByteSize().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ s_szIconFile

const WCHAR s_szIconFile[] = L"IconFile"
static

◆ s_szIconIndex

const WCHAR s_szIconIndex[] = L"IconIndex"
static

◆ s_szIconResource

const WCHAR s_szIconResource[] = L"IconResource"
static

◆ s_szShellClassInfo

const WCHAR s_szShellClassInfo[] = L".ShellClassInfo"
static