ReactOS  0.4.15-dev-1177-g6cb3b62
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 
41  if (!RtlDosPathNameToNtPathName_U(PathBuffer, &FileName, NULL, NULL))
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 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_SHARE_READ
Definition: compat.h:136
HANDLE FileHandle
Definition: stats.c:38
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
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:3951
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define SYNCHRONIZE
Definition: nt_native.h:61
#define ERR(fmt,...)
Definition: debug.h:110
struct _FileName FileName
Definition: fatprocs.h:893
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define FileStandardInformation
Definition: propsheet.cpp:61
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
struct FileInfo FileInfo
#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)

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

◆ PathIsExeW()

EXTERN_C BOOL PathIsExeW ( LPCWSTR  lpszPath)

Definition at line 244 of file shellpath.c.

245 {
246  LPCWSTR lpszExtension = PathGetExtensionW(lpszPath);
247  int i;
248  static const WCHAR lpszExtensions[][4] =
249  {{'e','x','e','\0'}, {'c','o','m','\0'}, {'p','i','f','\0'},
250  {'c','m','d','\0'}, {'b','a','t','\0'}, {'s','c','f','\0'},
251  {'s','c','r','\0'}, {'\0'} };
252 
253  TRACE("path=%s\n",debugstr_w(lpszPath));
254 
255  for(i=0; lpszExtensions[i][0]; i++)
256  if (!strcmpiW(lpszExtension,lpszExtensions[i])) return TRUE;
257 
258  return FALSE;
259 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TRUE
Definition: types.h:120
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 FALSE
Definition: types.h:117
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define strcmpiW(s1, s2)
Definition: unicode.h:39
static LPWSTR PathGetExtensionW(LPCWSTR lpszPath)
Definition: shellpath.c:139

Referenced by CFileDefExt::InitGeneralPage(), and PathIsExeAW().

◆ SH_CreatePropertySheetPage()

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

Definition at line 302 of file filedefext.cpp.

303 {
304  PROPSHEETPAGEW Page;
305 
306  memset(&Page, 0x0, sizeof(PROPSHEETPAGEW));
307  Page.dwSize = sizeof(PROPSHEETPAGEW);
308  Page.dwFlags = PSP_DEFAULT;
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 
318  return CreatePropertySheetPageW(&Page);
319 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
LPCWSTR pszTemplate
Definition: prsht.h:218
GLint x0
Definition: linetemp.h:95
DWORD dwSize
Definition: prsht.h:214
DLGPROC pfnDlgProc
Definition: prsht.h:226
struct _PROPSHEETPAGEW PROPSHEETPAGEW
LPCWSTR pszTitle
Definition: prsht.h:225
HPROPSHEETPAGE WINAPI CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage)
Definition: propsheet.c:3075
#define PSP_DEFAULT
Definition: prsht.h:22
LPARAM lParam
Definition: prsht.h:227
HINSTANCE hInstance
Definition: prsht.h:216
#define PSP_USETITLE
Definition: prsht.h:26
#define shell32_hInstance
#define memset(x, y, z)
Definition: compat.h:39
LPARAM lParam
Definition: combotst.c:139
DWORD dwFlags
Definition: prsht.h:215

Referenced by CFileDefExt::AddPages().

◆ 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 }
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:58
#define IDS_BYTES_FORMAT
Definition: resource.h:110
UINT SH_FormatInteger(LONGLONG Num, LPWSTR pwszResult, UINT cchResultMax)
Definition: filedefext.cpp:180
static const WCHAR L[]
Definition: oid.c:1250
STRSAFEAPI StringCchCopyExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags)
Definition: strsafe.h:184
#define shell32_hInstance
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:2380
UINT SH_FormatByteSize(LONGLONG cbSize, LPWSTR pwszResult, UINT cchResultMax)
Definition: filedefext.cpp:236
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR L[]
Definition: oid.c:1250
STRSAFEAPI StringCchCopyExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags)
Definition: strsafe.h:184
unsigned int UINT
Definition: ndis.h:50
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

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];
199  INT cchGrouping = GetLocaleInfoW(LOCALE_USER_DEFAULT,
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 }
LPWSTR lpThousandSep
Definition: winnls.h:643
#define LOCALE_SGROUPING
Definition: winnls.h:44
LPWSTR lpDecimalSep
Definition: winnls.h:642
#define LOCALE_USER_DEFAULT
UINT Grouping
Definition: winnls.h:641
#define ZeroMemory
Definition: winbase.h:1648
int32_t INT
Definition: typedefs.h:58
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
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 LOCALE_STHOUSAND
Definition: winnls.h:43
#define LOCALE_SDECIMAL
Definition: winnls.h:42
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define swprintf(buf, format,...)
Definition: sprintf.c:56
static const WCHAR L[]
Definition: oid.c:1250
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1198

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