Differences From Artifact [828aa0d8f5]:
- File
src/OFFileManager.m
— part of check-in
[c52e685523]
at
2016-07-03 18:22:12
on branch trunk
— OFFileManager: Replace remove with unlink / rmdir
remove() is supposed to delete both, files and directories, but
unfortunately, on Windows it only works for files. Since there is an if
on the type anyway, use unlink() / rmdir() instead. (user: js, size: 21990) [annotate] [blame] [check-ins using]
To Artifact [d13c205905]:
- File src/OFFileManager.m — part of check-in [768b31dede] at 2016-07-03 22:40:35 on branch trunk — Add support for hardlinks and symlinks on Windows (user: js, size: 23528) [annotate] [blame] [check-ins using]
︙ | |||
46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | + | #import "OFCreateDirectoryFailedException.h" #import "OFCreateSymbolicLinkFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFLinkFailedException.h" #import "OFLockFailedException.h" #import "OFMoveItemFailedException.h" #import "OFNotImplementedException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfMemoryException.h" #import "OFReadFailedException.h" #import "OFRemoveItemFailedException.h" #import "OFStatItemFailedException.h" #import "OFUnlockFailedException.h" |
︙ | |||
82 83 84 85 86 87 88 89 90 91 92 93 94 95 | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | + + + + | #if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS) static OFMutex *passwdMutex; #endif #if !defined(HAVE_READDIR_R) && !defined(OF_WINDOWS) && defined(OF_HAVE_THREADS) static OFMutex *readdirMutex; #endif #ifdef OF_WINDOWS static WINAPI BOOLEAN (*func_CreateSymbolicLinkW)(LPCWSTR, LPCWSTR, DWORD); #endif int of_stat(OFString *path, of_stat_t *buffer) { #if defined(OF_WINDOWS) return _wstat64([path UTF16String], buffer); #elif defined(OF_HAVE_OFF64_T) |
︙ | |||
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | + + + + + + + + + + + | # endif #endif } @implementation OFFileManager + (void)initialize { #ifdef OF_WINDOWS HMODULE module; #endif if (self != [OFFileManager class]) return; /* * Make sure OFFile is initialized. * On some systems, this is needed to initialize the file system driver. */ [OFFile class]; #if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS) passwdMutex = [[OFMutex alloc] init]; #endif #if !defined(HAVE_READDIR_R) && !defined(OF_WINDOWS) && defined(OF_HAVE_THREADS) readdirMutex = [[OFMutex alloc] init]; #endif #ifdef OF_WINDOWS if ((module = LoadLibrary("kernel32.dll")) != NULL) func_CreateSymbolicLinkW = (WINAPI BOOLEAN (*)(LPCWSTR, LPCWSTR, DWORD)) GetProcAddress(module, "CreateSymbolicLinkW"); #endif defaultManager = [[OFFileManager alloc] init]; } + (OFFileManager*)defaultManager { return defaultManager; |
︙ | |||
871 872 873 874 875 876 877 | 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 | - + | exceptionWithPath: path errNo: errno]; } objc_autoreleasePoolPop(pool); } |
︙ | |||
893 894 895 896 897 898 899 900 901 | 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 | + + + + + + + + + + + + + + + + + + + - + | @throw [OFLinkFailedException exceptionWithSourcePath: source destinationPath: destination errNo: errno]; objc_autoreleasePoolPop(pool); } #else - (void)linkItemAtPath: (OFString*)source toPath: (OFString*)destination { void *pool; if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); if (!CreateHardLinkW([destination UTF16String], [source UTF16String], NULL)) @throw [OFLinkFailedException exceptionWithSourcePath: source destinationPath: destination]; objc_autoreleasePoolPop(pool); } #endif |
︙ | |||
917 918 919 920 921 922 923 | 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 | + + + - + + + + + + + + + + + + + + + + + + + + + + + | @throw [OFCreateSymbolicLinkFailedException exceptionWithSourcePath: source destinationPath: destination errNo: errno]; objc_autoreleasePoolPop(pool); } #elif defined(OF_WINDOWS) - (void)createSymbolicLinkAtPath: (OFString*)destination withDestinationPath: (OFString*)source |
︙ |