uLib  User mode C/C++ extended API library for Win32 programmers.
Supplementary I/O APIs

Module Description

I/O related functions... (IoUtil.cpp)

Groups

 Memory Mapped Files
 

Macros

#define OPEN_FILE(name, access)   CreateFile( name, access, FILE_SHARE_READ, &DefSec, OPEN_EXISTING, 0,0 )
 
#define LONG_PATH_PREFIX_A   "\\\\?\\"
 
#define LONG_UNC_PREFIX_A   LONG_PATH_PREFIX_A "UNC\\"
 
#define DEVICE_NAME_PREFIX_A   "\\\\.\\"
 
#define UNPARSED_NAME_PREFIX_A   "\\??\\"
 
#define LONG_PATH_PREFIX_W   L"\\\\?\\"
 
#define LONG_UNC_PREFIX_W   LONG_PATH_PREFIX_W L"UNC\\"
 
#define DEVICE_NAME_PREFIX_W   L"\\\\.\\"
 
#define UNPARSED_NAME_PREFIX_W   L"\\??\\"
 
#define LONG_PATH_PREFIX   LONG_PATH_PREFIX_A
 
#define LONG_UNC_PREFIX   LONG_UNC_PREFIX_A
 
#define DEVICE_NAME_PREFIX   DEVICE_NAME_PREFIX_A
 
#define UNPARSED_NAME_PREFIX   UNPARSED_NAME_PREFIX_A
 
#define SkipPathPrefix   SkipPathPrefixA
 
#define GetFilePointer(hFile, pHiPart)   SetFilePointer( hFile, 0, (PLONG)pHiPart, FILE_CURRENT )
 
#define WriteStr   WriteStrA
 
#define ReadLine   ReadLineA
 

Typedefs

typedef bool(__stdcall * PFnEnumHardLinks) (CSTR PathName, PVOID usrData)
 
typedef bool(__stdcall * PFnEnumStreams) (CSTR PathName, UINT64 Size, PVOID usrData)
 

Functions

HANDLE OpenDirectory (CSTR DirPath, DWORD Flags)
 
ACSTR SkipPathPrefixA (ACSTR PathName)
 
WCSTR SkipPathPrefixW (WCSTR PathName)
 
bool FileExist (CSTR PathName)
 
bool DirExist (CSTR PathName)
 
bool IsDir (LPWIN32_FIND_DATA pFd)
 
bool IsSubdirName (CSTR Dir)
 
bool IsSubdir (LPWIN32_FIND_DATA pFd)
 
bool IsJunctionDir (CSTR PathName)
 
bool IsSymLink (CSTR PathName)
 
bool IsSymLinkDir (CSTR PathName)
 
bool IsVolumeMountPoint (CSTR PathName, TSTR VolNameBuf=NULL, UINT ccBuf=0)
 
bool GetWin32FileData (CSTR PathName, LPWIN32_FIND_DATA pFd)
 
UINT64 SetFilePos (HANDLE hFile, INT64 Offset, UINT How)
 
UINT64 GetFilePos (HANDLE hFile)
 
bool Seek (HANDLE hFile, LONG Offs, DWORD How)
 
UINT Tell (HANDLE hFile)
 
bool IsEndOfFile (HANDLE hFile)
 
UINT64 GetFileSize64 (HANDLE hFile)
 
UINT64 GetFileSize64Ex (CSTR FName)
 
UINT64 GetFileSizeByName (CSTR FName)
 
UINT PeekFile (HANDLE hFile, PVOID Buf, UINT nBytes)
 
UINT BlockRead (HANDLE hFile, PVOID Buf, UINT nBytes)
 
UINT BlockWrite (HANDLE hFile, PVOID Buf, UINT nBytes)
 
BOOL WriteLine (HANDLE hFile, CSTR Buf, UINT ccBuf=0)
 
UINT __cdecl WriteStrA (HANDLE hFile, const char *Fmt,...)
 
UINT __cdecl WriteStrW (HANDLE hFile, const wchar_t *Fmt,...)
 
UINT ReadLineA (HANDLE hFile, char *Buffer, UINT BufLength, bool TrimCrLf)
 
UINT ReadLineW (HANDLE hFile, wchar_t *Buffer, UINT BufLength, bool TrimCrLf)
 
TSTR GetPathFileName (TSTR PathName)
 
UINT GetFileNameFromHandle (HANDLE hFile, OUT TSTR Buffer, UINT BufLen)
 
UINT DevicePathToDosPath (IN CSTR DevPath, OUT TSTR PathBuf, UINT ccPathBuf)
 
CSTR ChangeDirectory (CSTR Dir)
 
CSTR DoneDirectory (CSTR prevDir)
 
bool FindMoreFiles (HANDLE hFind, WIN32_FIND_DATA *Found, OPTIN BYTE nTries=1, OPTIN BYTE msWait=50)
 
HANDLE FindCloseEx (HANDLE hFind)
 
CSTR GetTempPathName (CSTR Prefix, CSTR dotExt)
 
ULARGE_INTEGER GetAttributeAndReparseTag (CSTR PathName)
 
bool GetFileInformationByName (CSTR FileName, LPBY_HANDLE_FILE_INFORMATION pInfo)
 
bool GetVolumeGuidOfShare (IN CSTR ShareName, OUT TSTR VolGuid, WORD ccGuid, OPTOUT TSTR DosDrv, WORD ccDrv)
 
bool GetVolumeGuidOfDevice (IN CSTR DevName, OUT TSTR VolGuid, WORD ccGuid, OPTOUT TSTR DosDrv, WORD ccDrv)
 
bool CreateJunctionDir (CSTR LinkName, CSTR TargetPath, CSTR PrintName)
 
bool DeleteJunctionDir (CSTR LinkName)
 
bool CreateSymLink (CSTR LinkName, CSTR TargetPath, CSTR PrintName)
 
bool RemoveReparseData (CSTR PathName)
 
INT GetReparseTarget (IN CSTR LinkName, OUT TSTR SubstPath, UINT cchSubst, OPTOUT TSTR PrintName, UINT cchPrint, OPTOUT PULARGE_INTEGER AttrTag)
 
UINT GetHardLinkCount (CSTR FileName)
 
bool _CreateHardLink (CSTR LinkName, CSTR TargetName)
 
UINT EnumerateHardLinks (CSTR FileName, PFnEnumHardLinks Action, PVOID UserData)
 
UINT EnumerateFileStreams (CSTR FileName, PFnEnumStreams Action, PVOID usrData)
 

Macro Definition Documentation

◆ OPEN_FILE

#define OPEN_FILE (   name,
  access 
)    CreateFile( name, access, FILE_SHARE_READ, &DefSec, OPEN_EXISTING, 0,0 )

Open existing file with shared reading (Most common file usage I can concieve).

Definition at line 2333 of file UtilFunc.h.

◆ LONG_PATH_PREFIX_A

#define LONG_PATH_PREFIX_A   "\\\\?\\"

("\\?\") Disable Win32 name parsing and override the MAX_PATH limit.

Definition at line 2345 of file UtilFunc.h.

◆ LONG_UNC_PREFIX_A

#define LONG_UNC_PREFIX_A   LONG_PATH_PREFIX_A "UNC\\"

("\\?\UNC\") Same as "\\?\" but applies to UNC paths.

Definition at line 2346 of file UtilFunc.h.

◆ DEVICE_NAME_PREFIX_A

#define DEVICE_NAME_PREFIX_A   "\\\\.\\"

("\\.\") A device in the Win32 device name space.

Definition at line 2347 of file UtilFunc.h.

◆ UNPARSED_NAME_PREFIX_A

#define UNPARSED_NAME_PREFIX_A   "\\??\\"

("\??\") AFAIK: The pathname should not be parsed. Used e.g for symlink abs targets.

Definition at line 2348 of file UtilFunc.h.

◆ LONG_PATH_PREFIX_W

#define LONG_PATH_PREFIX_W   L"\\\\?\\"

See LONG_PATH_PREFIX_A

Definition at line 2350 of file UtilFunc.h.

◆ LONG_UNC_PREFIX_W

#define LONG_UNC_PREFIX_W   LONG_PATH_PREFIX_W L"UNC\\"

See LONG_UNC_PREFIX_A

Definition at line 2351 of file UtilFunc.h.

◆ DEVICE_NAME_PREFIX_W

#define DEVICE_NAME_PREFIX_W   L"\\\\.\\"

See DEVICE_NAME_PREFIX_A

Definition at line 2352 of file UtilFunc.h.

◆ UNPARSED_NAME_PREFIX_W

#define UNPARSED_NAME_PREFIX_W   L"\\??\\"

See UNPARSED_NAME_PREFIX_A

Definition at line 2353 of file UtilFunc.h.

◆ LONG_PATH_PREFIX

#define LONG_PATH_PREFIX   LONG_PATH_PREFIX_A

Definition at line 2361 of file UtilFunc.h.

◆ LONG_UNC_PREFIX

#define LONG_UNC_PREFIX   LONG_UNC_PREFIX_A

Definition at line 2362 of file UtilFunc.h.

◆ DEVICE_NAME_PREFIX

#define DEVICE_NAME_PREFIX   DEVICE_NAME_PREFIX_A

Definition at line 2363 of file UtilFunc.h.

◆ UNPARSED_NAME_PREFIX

#define UNPARSED_NAME_PREFIX   UNPARSED_NAME_PREFIX_A

Definition at line 2364 of file UtilFunc.h.

◆ SkipPathPrefix

#define SkipPathPrefix   SkipPathPrefixA

Definition at line 2375 of file UtilFunc.h.

◆ GetFilePointer

#define GetFilePointer (   hFile,
  pHiPart 
)    SetFilePointer( hFile, 0, (PLONG)pHiPart, FILE_CURRENT )

Get the current file position in hFile.\nSee also GetFilePos().

Definition at line 2409 of file UtilFunc.h.

◆ WriteStr

#define WriteStr   WriteStrA

Definition at line 2459 of file UtilFunc.h.

◆ ReadLine

#define ReadLine   ReadLineA

Definition at line 2460 of file UtilFunc.h.

Typedef Documentation

◆ PFnEnumHardLinks

typedef bool(__stdcall * PFnEnumHardLinks) (CSTR PathName, PVOID usrData)

Callback for EnumerateHardLinks(). Return true to continue.
PathName specifies the absolute path name of the hardlink, including the drive spec.

Definition at line 2652 of file UtilFunc.h.

◆ PFnEnumStreams

typedef bool(__stdcall * PFnEnumStreams) (CSTR PathName, UINT64 Size, PVOID usrData)

PFnEnumStreams is the callback for EnumerateFileStreams(). Return true to continue.
PathName specifies the absolute path name of the stream, including the drive spec.

Definition at line 2667 of file UtilFunc.h.

Function Documentation

◆ OpenDirectory()

HANDLE OpenDirectory ( CSTR  DirPath,
DWORD  Flags 
)

OpenDirectory opens a disk directory for direct access.

Flags may be f.ex. FILE_LIST_DIRECTORY. FILE_FLAG_BACKUP_SEMANTICS is added by default.
The returned handle can be used with f.ex. ReadDirectoryChangesW() or DeviceIoControl().
Requires SE_BACKUP_NAME / SE_RESTORE_NAME privilege. On failure the function returns NULL.

Definition at line 385 of file IoUtil.cpp.

◆ SkipPathPrefixA()

ACSTR SkipPathPrefixA ( ACSTR  PathName)

Return a pointer to the first char past any known namespace prefix in PathName.

Definition at line 108 of file IoUtil.cpp.

◆ SkipPathPrefixW()

WCSTR SkipPathPrefixW ( WCSTR  PathName)

See SkipPathPrefixA().

Definition at line 133 of file IoUtil.cpp.

◆ FileExist()

bool FileExist ( CSTR  PathName)

True if file exist. VERY fast.

Definition at line 24 of file IoUtil.cpp.

◆ DirExist()

bool DirExist ( CSTR  PathName)

True if directory exist. VERY fast.

Definition at line 30 of file IoUtil.cpp.

◆ IsDir()

bool IsDir ( LPWIN32_FIND_DATA  pFd)

True if pFd refers to a directory.

Definition at line 38 of file IoUtil.cpp.

◆ IsSubdirName()

bool IsSubdirName ( CSTR  Dir)

True if Dir is a subdir name (not "." or "..").

Definition at line 43 of file IoUtil.cpp.

◆ IsSubdir()

bool IsSubdir ( LPWIN32_FIND_DATA  pFd)

True if pFd refers to a subdirectory.

Definition at line 55 of file IoUtil.cpp.

◆ IsJunctionDir()

bool IsJunctionDir ( CSTR  PathName)

NTFS junction to another directory? (IO_REPARSE_TAG_MOUNT_POINT)

Definition at line 640 of file ReparsePnt.cpp.

◆ IsSymLink()

bool IsSymLink ( CSTR  PathName)

NTFS symbolic link? (IO_REPARSE_TAG_SYMLINK)

Definition at line 624 of file ReparsePnt.cpp.

◆ IsSymLinkDir()

bool IsSymLinkDir ( CSTR  PathName)

NTFS symbolic link to a directory? (IO_REPARSE_TAG_SYMLINK and FILE_ATTRIBUTE_DIRECTORY)

Definition at line 632 of file ReparsePnt.cpp.

◆ IsVolumeMountPoint()

bool IsVolumeMountPoint ( CSTR  PathName,
TSTR  VolNameBuf = NULL,
UINT  ccBuf = 0 
)

Determine if directory is a junction mounted volume.
Note: IsVolumeMountPoint fails for mapped network directories (they're not mount points).

Definition at line 652 of file ReparsePnt.cpp.

◆ GetWin32FileData()

bool GetWin32FileData ( CSTR  PathName,
LPWIN32_FIND_DATA  pFd 
)

GetWin32FileData gets the FindFile() data for a file or subdirectory.
Note: For directories, PathName should not have a terminal backslash.
For root directories pFd->cFilename recieves esotheric OS info.

Definition at line 84 of file IoUtil.cpp.

◆ SetFilePos()

UINT64 SetFilePos ( HANDLE  hFile,
INT64  Offset,
UINT  How 
)

Set current (64 bit) file position in hFile.
See [MSDN] SetFilePointer() for parameter details.

Definition at line 306 of file IoUtil.cpp.

◆ GetFilePos()

UINT64 GetFilePos ( HANDLE  hFile)

Get current (64 bit) file position in hFile.

Definition at line 299 of file IoUtil.cpp.

◆ Seek()

bool Seek ( HANDLE  hFile,
LONG  Offs,
DWORD  How 
)

Set current (32 bit) file position in hFile.

Definition at line 316 of file IoUtil.cpp.

◆ Tell()

UINT Tell ( HANDLE  hFile)

Get current (32 bit) file position in hFile.

Definition at line 321 of file IoUtil.cpp.

◆ IsEndOfFile()

bool IsEndOfFile ( HANDLE  hFile)

Amend strange omission in Win32 APIs. True if hFile is at end.

Definition at line 395 of file IoUtil.cpp.

◆ GetFileSize64()

UINT64 GetFileSize64 ( HANDLE  hFile)

Get the size of an open file. Note: Symlink behavior is: Size of the Target.

Definition at line 328 of file IoUtil.cpp.

◆ GetFileSize64Ex()

UINT64 GetFileSize64Ex ( CSTR  FName)

Get the size of a named file. Note: Symlink behavior is: Size of the Target.

Definition at line 336 of file IoUtil.cpp.

◆ GetFileSizeByName()

UINT64 GetFileSizeByName ( CSTR  FName)

Get the size of an unopened file. Note: Symlink behavior is: Size of the Link (0).

Definition at line 354 of file IoUtil.cpp.

◆ PeekFile()

UINT PeekFile ( HANDLE  hFile,
PVOID  Buf,
UINT  nBytes 
)

Read from file without moving the file pointer.

Definition at line 404 of file IoUtil.cpp.

◆ BlockRead()

UINT BlockRead ( HANDLE  hFile,
PVOID  Buf,
UINT  nBytes 
)

Read a data block from hFile. Return nr of bytes read.

Definition at line 417 of file IoUtil.cpp.

◆ BlockWrite()

UINT BlockWrite ( HANDLE  hFile,
PVOID  Buf,
UINT  nBytes 
)

Write a data block to hFile. Return nr of bytes written.

Definition at line 423 of file IoUtil.cpp.

◆ WriteLine()

BOOL WriteLine ( HANDLE  hFile,
CSTR  Buf,
UINT  ccBuf = 0 
)

WriteLine writes text to hFile, and appends CRLF.
If ccBuf is zero, the whole string is written, else that nr of TCHARs.

Definition at line 432 of file IoUtil.cpp.

◆ WriteStrA()

UINT __cdecl WriteStrA ( HANDLE  hFile,
const char *  Fmt,
  ... 
)

WriteStr formats a string into an internal buffer of 512 chars, and writes it.
It returns the nr of characters, not bytes, written to the file.
On error, the return value is zero, and GetLastError() returns the reason.

◆ WriteStrW()

UINT __cdecl WriteStrW ( HANDLE  hFile,
const wchar_t *  Fmt,
  ... 
)

Definition at line 492 of file IoUtil.cpp.

◆ ReadLineA()

UINT ReadLineA ( HANDLE  hFile,
char *  Buffer,
UINT  BufLength,
bool  TrimCrLf 
)

ReadLine reads a line of text, up to the next [CR]LF found.

Returns
Returns the nr of chars read from the file, including [CR]LF.
The returned string in Buffer will be shorter than that if TrimCrLf is true.

On error the function returns zero, and GetLastError returns the reason.
If no linefeed was found within the span of BufLength, the error code is
ERROR_INSUFFICIENT_BUFFER, and the file pointer is not moved.
If the file is at EOF, the error code is ERROR_HANDLE_EOF.
(This is an improvement over Windows ususal behavior, which only
return EOF as an error condition on OVERLAPPED file operations.)
Note
Character conversions are currently not supported; ReadLineA only support
reading ANSI/MultiByte chars, and ReadLineW only reads Unicode chars.
Neglecting this limitation will cause undefined results.

Definition at line 508 of file IoUtil.cpp.

◆ ReadLineW()

UINT ReadLineW ( HANDLE  hFile,
wchar_t *  Buffer,
UINT  BufLength,
bool  TrimCrLf 
)

See ReadLineA()

Definition at line 565 of file IoUtil.cpp.

◆ GetPathFileName()

TSTR GetPathFileName ( TSTR  PathName)

GetPathFileName gets a pointer to the "filname.ext" part of PathName.
If there is no '\' in PathName, you'll get a pointer to PathName itself.

Warning
Be cautious with GetPathFileName for pathnames without a filename part.
If PathName denotes just a directory with no ending BSLASH, you'll get
a pointer to the terminal directory (if present), which is probably
not what you want, so assert dir-only names have an ending BSLASH,
which will then give you a ptr to the terminal NUL in the string.

Definition at line 620 of file IoUtil.cpp.

◆ GetFileNameFromHandle()

UINT GetFileNameFromHandle ( HANDLE  hFile,
OUT TSTR  Buffer,
UINT  BufLen 
)

Get the file name of the specified handle.
Return nr of chars copied to Buffer, or zero on failure.
See GetFinalPathNameByHandle:VOLUME_NAME_DOS and NtQueryObject:ObjectNameInformation.

◆ DevicePathToDosPath()

UINT DevicePathToDosPath ( IN CSTR  DevPath,
OUT TSTR  PathBuf,
UINT  ccPathBuf 
)

Translate path with device name to a DOS path (that is, with drive letter).
Return length of resulting pathname, in chars, excluding NUL terminator.
Note: You may translate in-place by passing the same buffer as DevPath and PathBuf.

Definition at line 1007 of file IoUtil.cpp.

◆ ChangeDirectory()

CSTR ChangeDirectory ( CSTR  Dir)

ChangeDirectory combines GetCurrentDirectory() and SetCurrentDirectory().
The function returns a newStr() duplicate of previous dir, or NULL on error.
Note: Use DoneDirectory() or deleteStr() when done with the returned string.

Definition at line 1026 of file IoUtil.cpp.

◆ DoneDirectory()

CSTR DoneDirectory ( CSTR  prevDir)

Restore previous working directory and free prevDir.
See ChangeDirectory().

Definition at line 1040 of file IoUtil.cpp.

◆ FindMoreFiles()

bool FindMoreFiles ( HANDLE  hFind,
WIN32_FIND_DATA *  Found,
OPTIN BYTE  nTries = 1,
OPTIN BYTE  msWait = 50 
)

FindMoreFiles combines FindNextFile() and FindClose().
If FindNextFile fails, it calls FindClose and returns false.

Parameters
hFindHandle from FindFirstFile.
FoundRecieves item data for the file.
nTries[optional] Max tries for FindNextFile (in case of error).
msWait[optional] Millisec wait between retries for FindNextFile.

◆ FindCloseEx()

HANDLE FindCloseEx ( HANDLE  hFind)

FindCloseEx closes a find-handle, and returns NULL on success.
On failure, the handle is returned as-is.

Definition at line 1072 of file IoUtil.cpp.

◆ GetTempPathName()

CSTR GetTempPathName ( CSTR  Prefix,
CSTR  dotExt 
)

GetTempPathName returns a full tempfile pathname, with specific ext.
Note: The function uses a static buffer for the generated path name.

Parameters
PrefixPrefix for the file name. Only the first 3 chars are used.
dotExtExtension, with leading dot. Use NULL or a blank string for extensionless name.

See also GetTempFileName() and GetTempPath().

Definition at line 62 of file IoUtil.cpp.

◆ GetAttributeAndReparseTag()

ULARGE_INTEGER GetAttributeAndReparseTag ( CSTR  PathName)

GetAttributeAndReparseTag gets the file attributes and reparse tag for a file.
Return file attributes in LowPart, and reparse tag, if any, in HighPart.
On failure, the result is zero, not INVALID_FILE_ATTRIBUTES.

Definition at line 554 of file ReparsePnt.cpp.

◆ GetFileInformationByName()

bool GetFileInformationByName ( CSTR  FileName,
LPBY_HANDLE_FILE_INFORMATION  pInfo 
)

See [MSDN] GetFileInformationByHandle().

Definition at line 163 of file IoUtil.cpp.

◆ GetVolumeGuidOfShare()

bool GetVolumeGuidOfShare ( IN CSTR  ShareName,
OUT TSTR  VolGuid,
WORD  ccGuid,
OPTOUT TSTR  DosDrv,
WORD  ccDrv 
)

Return the volume GUID of an UNC share ("\\Server\Share").

Returns
A volume GUID suitable for CreateJunctionDir() or SetVolumeMountPoint().
See also
GetVolumeGuidOfDevice(), CreateJunctionDir(), [MSDN] GetVolumeNameForVolumeMountPoint()

Definition at line 180 of file IoUtil.cpp.

◆ GetVolumeGuidOfDevice()

bool GetVolumeGuidOfDevice ( IN CSTR  DevName,
OUT TSTR  VolGuid,
WORD  ccGuid,
OPTOUT TSTR  DosDrv,
WORD  ccDrv 
)

Return the volume GUID of a disk device, e.g ("\Device\HarddiskVolumeX").

Returns
A volume GUID suitable for CreateJunctionDir() or SetVolumeMountPoint().
See also
GetVolumeGuidOfShare(), CreateJunctionDir()

Definition at line 273 of file IoUtil.cpp.

◆ CreateJunctionDir()

bool CreateJunctionDir ( CSTR  LinkName,
CSTR  TargetPath,
CSTR  PrintName 
)

CreateJunctionDir() creates a directory junction (if the volume supports it).
This function works with both directory junctions and volume mount points.
The link directory is automatically created before mounting the directory or volume.
You can also set the "friendly name".

Parameters
LinkNamePathname of the junction directory to create.
TargetPathAbsolute path of an existing target to link to.
This can be an absolute DOS directory path, or a volume GUID.
PrintNameA "friendly" print name (ATM not shown by the shell). If this is NULL, TargetPath is used as a base for the print name.
Returns
Return true if the target spec was successfully written to the link object.
Note: UNC paths and NT device paths will be accepted by FSCTL_SET_REPARSE_POINT,
however, the resulting junction would be dysfunctional. Use discretion.
See also
GetVolumeGuidOfShare(), GetVolumeGuidOfDevice(), GetReparseTarget(), DeleteJunctionDir().

Definition at line 766 of file ReparsePnt.cpp.

◆ DeleteJunctionDir()

bool DeleteJunctionDir ( CSTR  LinkName)

DeleteJunctionDir() deletes a directory junction (without touching the link target).
See also CreateJunctionDir(), GetReparseTarget(), RemoveReparseData().

Definition at line 796 of file ReparsePnt.cpp.

◆ CreateSymLink()

bool CreateSymLink ( CSTR  LinkName,
CSTR  TargetPath,
CSTR  PrintName 
)

CreateSymLink() creates a symbolic link to a file or directory.
This function sets the full surrogate name, including the "friendly" print name.
(The Win32 API CreateSymbolicLink() doesn't provide access to the print name.)

Parameters
LinkNamePathname of the symbolic link to create.
TargetPathAbsolute or relative path of an existing target.
Note: Directory targets must be absolute, not relative.
PrintNameA "friendly" print name (ATM not shown by the shell). If this is NULL, TargetPath is used as a base for the print name.
Returns
Return true if the target spec was successfully written to the link object.
See also
CreateJunctionDir(), GetReparseTarget(), Shell_CreateLink().

Definition at line 822 of file ReparsePnt.cpp.

◆ RemoveReparseData()

bool RemoveReparseData ( CSTR  PathName)

RemoveReparseData() removes the reparse data from a file or directory.
See also CreateSymLink(), CreateJunctionDir().

Definition at line 687 of file ReparsePnt.cpp.

◆ GetReparseTarget()

INT GetReparseTarget ( IN CSTR  LinkName,
OUT TSTR  SubstPath,
UINT  cchSubst,
OPTOUT TSTR  PrintName,
UINT  cchPrint,
OPTOUT PULARGE_INTEGER  AttrTag 
)

GetReparseTarget() gets the target of a junction or symlink.

Parameters
[in]LinkNamePathname of the link.
[out]SubstPathBuffer to recieve the target pathname. This buffer should normally be at least MAX_PATH long.
[in]cchSubstLength, in TCHARs, of the target buffer.
[out]PrintName[optional] Buffer that recieves the "friendly" name.
[in]cchPrintLength, in TCHARs, of the PrintName buffer (if supplied).
[out]AttrTag[optional] If provided, recieves the GetAttributeAndReparseTag() value.
Note
LinkName and SubstPath can refer to the same buffer, allowing you to resolve a reparse path in-place.
Returns
Return nr of chars copied to the caller's buffer, excluding the terminating NUL.
On error the return value is <= 0, and GetLastError() has the code.
If BufLen is too small, the return value is the negated length required,
and the error code is ERROR_INSUFFICIENT_BUFFER.
If the link is an ISV reparse point, the error is ERROR_NOT_SUPPORTED.
Caveat Emptor
This function can not resolve relative links under other links on the
same volume, due to a shortcoming in the implementation of FSCTL_GET_REPARSE_POINT,
which returns incomplete relative results for nested intralinks.
In this case GetReparseTarget() returns zero and ERROR_INVALID_REPARSE_DATA.

A possible workaround is to go through your preceding path components
and resolve any occurring links separately before resolving the final link.

◆ GetHardLinkCount()

UINT GetHardLinkCount ( CSTR  FileName)

Return the nr of NTFS hard links (that is, MFT entries) for FileName.

Definition at line 7 of file Hardlink.cpp.

◆ _CreateHardLink()

bool _CreateHardLink ( CSTR  LinkName,
CSTR  TargetName 
)

_CreateHardLink() creates an hard link to a file (if the volume supports it).
Note that the system has had this function since Win2k, so this is a legacy version.
Also note that this one omits the security parameter of the Win32 call, since it
doesn't apply to hard links (MFT entries), only the files they link to, and
I don't think a link should be allowed to change the security on the original file.

Definition at line 122 of file Hardlink.cpp.

◆ EnumerateHardLinks()

UINT EnumerateHardLinks ( CSTR  FileName,
PFnEnumHardLinks  Action,
PVOID  UserData 
)

[PRELIMINARY] Enumerate the hardlinks for FileName. Return nr of links processed.
Note: Not all file systems support hardlinks, and hence return zero.
This function requires Vista++.

Parameters
FileNamePathname of the file.
ActionCallback function.
See also
PFnEnumHardLinks.
Parameters
UserDataArbitrary data for the callback.

Definition at line 236 of file Hardlink.cpp.

◆ EnumerateFileStreams()

UINT EnumerateFileStreams ( CSTR  FileName,
PFnEnumStreams  Action,
PVOID  usrData 
)

[PRELIMINARY] Enumerate $DATA streams contained in a file. Return nr of streams processed.
Note: Not all file systems support file streams, and hence return zero.
This function requires Vista++.

Reference
List of official NTFS stream types (attribute type codes):

::$DATA

Data stream. The default data stream has no name.
Data streams can be enumerated using the FindFirstStreamW and FindNextStreamW functions.
These streams can be enumerated with EnumerateFileStreams().

::$LOGGED_UTILITY_STREAM

Similar to ::$DATA but operations are logged to the NTFS change journal.
Used by EFS and Transactional NTFS (TxF). The :StreamName:$StreamType pair for EFS is :$EFS:$LOGGED_UTILITY_STREAM and for TxF is :$TXF_DATA:$LOGGED_UTILITY_STREAM.

::$ATTRIBUTE_LIST

Contains a list of all attributes that make up the file and identifies where each attribute is located.

::$BITMAP

A bitmap used by indexes to manage the B-tree free space for a directory.
The B-tree is managed in 4 KB chunks (regardless of cluster size) and this is used to manage the allocation of these chunks. This stream type is present on every directory.

::$EA

Contains Extended Attributes data.

::$EA_INFORMATION

Contains support information about the Extended Attributes.

::$FILE_NAME

The name of the file, in Unicode characters.
This includes the short name of the file as well as any hard links.

::$INDEX_ALLOCATION

The stream type of a directory. Used to implement filename allocation for large directories.
This stream represents the directory itself and contains all of the data of the directory. Changes to streams of this type are logged to the NTFS change journal. The default stream name of an $INDEX_ALLOCATION stream type is $I30 so "DirName", "DirName::$INDEX_ALLOCATION", and "DirName:$I30:$INDEX_ALLOCATION" are all equivalent.

::$INDEX_ROOT

This stream represents root of the b-tree of an index.
This stream type is present on every directory.

::$OBJECT_ID

An 16-byte ID used to identify the file for the link-tracking service.

::$REPARSE_POINT
The reparse point data.

Definition at line 1084 of file IoUtil.cpp.