uLib  User mode C/C++ extended API library for Win32 programmers.
_Internal.h
Go to the documentation of this file.
1 // Project: uLib
2 // Module: A handful of small internal subroutines used by various implementation modules.
3 //
4 // Note: These function id's have two leading underscores to mark them as global internals.
5 // That is, routines that regular uLib users have no need to concern themselves with.
6 // Parameter validation is generally absent. It is assumed callers constrain their arguments.
7 // Alas, anyone may of course use them if they fit the bill.
8 // For usage examples, see e.g. ReparsePnt.cpp
9 //
10 // Author: Love Nystrom
11 
12 #ifndef __uLib_Internal_h_incl__
13 #define __uLib_Internal_h_incl__
14 
15 #include <uLib/Common.h>
16 
18 
19 #define FILE_WRITE_ATTRIB_EA (FILE_WRITE_ATTRIBUTES| FILE_WRITE_EA)
20 #define FILE_READ_ATTRIB_EA (FILE_READ_ATTRIBUTES| FILE_READ_EA)
21 
22 // Return the passed-in boolean expression, and, if FALSE, set an error code.
23 // Ex: ok = __ChkOkSetErr( !DirExist( LinkName ), ERROR_FILE_EXISTS );
24 
25 __inline bool __ChkOkSetErr( BOOL Ok, DWORD Err )
26 {
27  if (!Ok) SetLastError( Err );
28  return bool_cast( Ok );
29 }
30 
31 // Return the passed-in boolean expression, and, if FALSE, get an error code.
32 // Ex: ok = __ChkOkGetErr( CreateDirectory( LinkName, NULL ), &error );
33 
34 __inline bool __ChkOkGetErr( BOOL Ok, PDWORD pErr )
35 {
36  if (!Ok) *pErr = GetLastError();
37  return bool_cast( Ok );
38 }
39 
40 // Enable a privilege for the current process. Return the token handle and previous state.
41 
42 bool __EnableProcPrivilege( IN CSTR Privilege, OUT LUID_AND_ATTRIBUTES* pPrv, OUT HANDLE* pToken );
43 
44 // Get the root component of PathName.
45 // Handles both DOS paths and UNC paths (\\server\share\path).
46 
47 bool __GetRoot( OUT TSTR Root, UINT ccRoot, IN CSTR PathName );
48 
49 // Get the file system ability flags of PathName's containing volume.
50 
51 DWORD __GetVolumeFlags( CSTR PathName );
52 
53 // Get the S/N of PathName's containing volume.
54 
55 DWORD __GetVolumeId( CSTR PathName );
56 
57 // Get the S/N of the volume of an open FS object.
58 
59 DWORD __GetHandleVolumeId( HANDLE hObj );
60 
61 // Change the CWD to that of PathName's path component.
62 
63 CSTR __ChangeToDirOf( CSTR PathName );
64 
66 #endif//ndef __uLib_Internal_h_incl__
67 // EOF
unsigned long DWORD
Definition: Common.h:414
#define CSTR
Definition: Common.h:329
#define TSTR
Definition: Common.h:328
DWORD __GetHandleVolumeId(HANDLE hObj)
Definition: _Internal.cpp:68
DWORD __GetVolumeFlags(CSTR PathName)
Definition: _Internal.cpp:44
BOOL(WINAPI *SysImgList::Shell_GetImageLists)(HIMAGELIST *pimlLarge
bool __GetRoot(OUT TSTR Root, UINT ccRoot, IN CSTR PathName)
__inline bool __ChkOkSetErr(BOOL Ok, DWORD Err)
Definition: _Internal.h:25
bool __forceinline bool_cast(BOOL B52)
Definition: Common.h:767
__inline bool __ChkOkGetErr(BOOL Ok, PDWORD pErr)
Definition: _Internal.h:34
Common include; Added types, small "ubiquitous" utilities, et c.
#define END_EXTERN_C
Definition: Common.h:221
#define BEGIN_EXTERN_C
Definition: Common.h:220
CSTR __ChangeToDirOf(CSTR PathName)
Definition: _Internal.cpp:77
bool __EnableProcPrivilege(IN CSTR Privilege, OUT LUID_AND_ATTRIBUTES *pPrv, OUT HANDLE *pToken)
Definition: _Internal.cpp:16
DWORD __GetVolumeId(CSTR PathName)
Definition: _Internal.cpp:56
unsigned long * PDWORD
Definition: Common.h:414