diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:20:50 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:20:50 +0200 |
commit | 7e706cf64654aea466c059c307e5723e2423ed5d (patch) | |
tree | e85f0d28d7c81b6d21419fc38e1a654cca2212b1 /zen/symlink_target.h | |
parent | 5.5 (diff) | |
download | FreeFileSync-7e706cf64654aea466c059c307e5723e2423ed5d.tar.gz FreeFileSync-7e706cf64654aea466c059c307e5723e2423ed5d.tar.bz2 FreeFileSync-7e706cf64654aea466c059c307e5723e2423ed5d.zip |
5.6
Diffstat (limited to 'zen/symlink_target.h')
-rw-r--r-- | zen/symlink_target.h | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/zen/symlink_target.h b/zen/symlink_target.h index 17ae1916..6d44d845 100644 --- a/zen/symlink_target.h +++ b/zen/symlink_target.h @@ -21,6 +21,33 @@ #endif +namespace zen +{ +#ifdef FFS_WIN +bool isSymlink(const WIN32_FIND_DATA& data); //*not* a simple FILE_ATTRIBUTE_REPARSE_POINT check! +bool isSymlink(DWORD fileAttributes, DWORD reparseTag); +#endif + +Zstring getSymlinkRawTargetString(const Zstring& linkPath); //throw FileError +} + + + + + + + + + + + + + + + + + +//################################ implementation ################################ #ifdef _MSC_VER //I don't have Windows Driver Kit at hands right now, so unfortunately we need to redefine this structures and cross fingers... typedef struct _REPARSE_DATA_BUFFER //from ntifs.h { @@ -55,10 +82,11 @@ typedef struct _REPARSE_DATA_BUFFER //from ntifs.h #define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer) #endif + namespace { //retrieve raw target data of symlink or junction -Zstring getSymlinkRawTargetString(const Zstring& linkPath) //throw FileError +Zstring getSymlinkRawTargetString_impl(const Zstring& linkPath) //throw FileError { using namespace zen; #ifdef FFS_WIN @@ -136,4 +164,38 @@ Zstring getSymlinkRawTargetString(const Zstring& linkPath) //throw FileError } } + +namespace zen +{ +inline +Zstring getSymlinkRawTargetString(const Zstring& linkPath) { return getSymlinkRawTargetString_impl(linkPath); } + + +#ifdef FFS_WIN +/* + Reparse Point Tags + http://msdn.microsoft.com/en-us/library/windows/desktop/aa365511(v=vs.85).aspx + WIN32_FIND_DATA structure + http://msdn.microsoft.com/en-us/library/windows/desktop/aa365740(v=vs.85).aspx + + The only surrogate reparse points are; + IO_REPARSE_TAG_MOUNT_POINT + IO_REPARSE_TAG_SYMLINK +*/ + +inline +bool isSymlink(DWORD fileAttributes, DWORD reparseTag) +{ + return (fileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0 && + IsReparseTagNameSurrogate(reparseTag); +} + +inline +bool isSymlink(const WIN32_FIND_DATA& data) +{ + return isSymlink(data.dwFileAttributes, data.dwReserved0); +} +#endif +} + #endif // SYMLINK_WIN_H_INCLUDED |