Overview
Comment: | -[destinationOfSymbolicLinkAtPath:] for Windows |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
7341924cedacb465fc1c6d61df459a77 |
User & Date: | js on 2016-07-04 21:40:14 |
Other Links: | manifest | tags |
Context
2016-07-05
| ||
19:31 | runtime/class.m: Add explicit size_t -> long cast check-in: c71706db46 user: js tags: trunk | |
2016-07-04
| ||
21:40 | -[destinationOfSymbolicLinkAtPath:] for Windows check-in: 7341924ced user: js tags: trunk | |
20:30 | Implement -[symbolicLinkExistsAtPath:] for Windows check-in: 0b886dd56d user: js tags: trunk | |
Changes
Modified src/OFFileManager.h from [8708c00019] to [84b16d5c13].
︙ | ︙ | |||
260 261 262 263 264 265 266 | * @param source The path to the item for which a symbolic link should be * created */ - (void)createSymbolicLinkAtPath: (OFString*)destination withDestinationPath: (OFString*)source; #endif | | > > | 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | * @param source The path to the item for which a symbolic link should be * created */ - (void)createSymbolicLinkAtPath: (OFString*)destination withDestinationPath: (OFString*)source; #endif #if defined(OF_HAVE_READLINK) || defined(OF_WINDOWS) /*! * @brief Returns the destination of the symbolic link at the specified path. * * @param path The path to the symbolic link * * @note On Windows, at least Windows Vista is required. * * @return The destination of the symbolic link at the specified path */ - (OFString*)destinationOfSymbolicLinkAtPath: (OFString*)path; #endif @end OF_ASSUME_NONNULL_END |
Modified src/OFFileManager.m from [065a5a9bcd] to [bdb65f91bc].
︙ | ︙ | |||
57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #import "OFRemoveItemFailedException.h" #import "OFStatItemFailedException.h" #import "OFUnlockFailedException.h" #ifdef OF_WINDOWS # include <windows.h> # include <direct.h> #endif #ifndef S_IRGRP # define S_IRGRP 0 #endif #ifndef S_IROTH # define S_IROTH 0 | > | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #import "OFRemoveItemFailedException.h" #import "OFStatItemFailedException.h" #import "OFUnlockFailedException.h" #ifdef OF_WINDOWS # include <windows.h> # include <direct.h> # include <ntdef.h> #endif #ifndef S_IRGRP # define S_IRGRP 0 #endif #ifndef S_IROTH # define S_IROTH 0 |
︙ | ︙ | |||
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 | if (length < 0) @throw [OFStatItemFailedException exceptionWithPath: path errNo: errno]; return [OFString stringWithCString: destination encoding: encoding length: length]; } #endif @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 | if (length < 0) @throw [OFStatItemFailedException exceptionWithPath: path errNo: errno]; return [OFString stringWithCString: destination encoding: encoding length: length]; } #elif defined(OF_WINDOWS) - (OFString*)destinationOfSymbolicLinkAtPath: (OFString*)path { HANDLE handle; /* Check if we're on a version that actually supports symlinks. */ if (func_CreateSymbolicLinkW == NULL) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; if (path == nil) @throw [OFInvalidArgumentException exception]; if ((handle = CreateFileW([path UTF16String], 0, (FILE_SHARE_READ | FILE_SHARE_WRITE), NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT, NULL)) == INVALID_HANDLE_VALUE) @throw [OFStatItemFailedException exceptionWithPath: path]; @try { union { char bytes[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; REPARSE_DATA_BUFFER data; } buffer; DWORD size; wchar_t *tmp; if (!DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, NULL, 0, buffer.bytes, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &size, NULL)) @throw [OFStatItemFailedException exceptionWithPath: path]; if (buffer.data.ReparseTag != IO_REPARSE_TAG_SYMLINK) @throw [OFStatItemFailedException exceptionWithPath: path]; #define slrb buffer.data.SymbolicLinkReparseBuffer tmp = slrb.PathBuffer + (slrb.SubstituteNameOffset / sizeof(wchar_t)); return [OFString stringWithUTF16String: tmp length: slrb.SubstituteNameLength / sizeof(wchar_t)]; #undef slrb } @finally { CloseHandle(handle); } } #endif @end |