diff options
| author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2024-05-14 00:00:00 +0000 |
|---|---|---|
| committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2024-05-15 23:55:04 +0500 |
| commit | fc662341e6f85da78ada0e443f6116b978f79f22 (patch) | |
| tree | 1be1cc402a7a9cbc18d4eeea6b141354c2d559e3 /CPP/Windows/FileDir.cpp | |
| parent | 5b39dc76f1bc82f941d5c800ab9f34407a06b53a (diff) | |
| download | 7zip-fc662341e6f85da78ada0e443f6116b978f79f22.tar.gz 7zip-fc662341e6f85da78ada0e443f6116b978f79f22.tar.bz2 7zip-fc662341e6f85da78ada0e443f6116b978f79f22.zip | |
24.0524.05
Diffstat (limited to 'CPP/Windows/FileDir.cpp')
| -rw-r--r-- | CPP/Windows/FileDir.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/CPP/Windows/FileDir.cpp b/CPP/Windows/FileDir.cpp index 5b1f340..dfeed82 100644 --- a/CPP/Windows/FileDir.cpp +++ b/CPP/Windows/FileDir.cpp | |||
| @@ -37,7 +37,12 @@ static bool FiTime_To_timespec(const CFiTime *ft, timespec &ts) | |||
| 37 | { | 37 | { |
| 38 | if (ft) | 38 | if (ft) |
| 39 | { | 39 | { |
| 40 | #if defined(_AIX) | ||
| 41 | ts.tv_sec = ft->tv_sec; | ||
| 42 | ts.tv_nsec = ft->tv_nsec; | ||
| 43 | #else | ||
| 40 | ts = *ft; | 44 | ts = *ft; |
| 45 | #endif | ||
| 41 | return true; | 46 | return true; |
| 42 | } | 47 | } |
| 43 | // else | 48 | // else |
| @@ -246,6 +251,11 @@ bool MyMoveFile(CFSTR oldFile, CFSTR newFile) | |||
| 246 | } | 251 | } |
| 247 | 252 | ||
| 248 | #ifndef UNDER_CE | 253 | #ifndef UNDER_CE |
| 254 | #if !defined(Z7_WIN32_WINNT_MIN) || Z7_WIN32_WINNT_MIN < 0x0500 // Win2000 | ||
| 255 | #define Z7_USE_DYN_CreateHardLink | ||
| 256 | #endif | ||
| 257 | |||
| 258 | #ifdef Z7_USE_DYN_CreateHardLink | ||
| 249 | EXTERN_C_BEGIN | 259 | EXTERN_C_BEGIN |
| 250 | typedef BOOL (WINAPI *Func_CreateHardLinkW)( | 260 | typedef BOOL (WINAPI *Func_CreateHardLinkW)( |
| 251 | LPCWSTR lpFileName, | 261 | LPCWSTR lpFileName, |
| @@ -253,6 +263,7 @@ typedef BOOL (WINAPI *Func_CreateHardLinkW)( | |||
| 253 | LPSECURITY_ATTRIBUTES lpSecurityAttributes | 263 | LPSECURITY_ATTRIBUTES lpSecurityAttributes |
| 254 | ); | 264 | ); |
| 255 | EXTERN_C_END | 265 | EXTERN_C_END |
| 266 | #endif | ||
| 256 | #endif // UNDER_CE | 267 | #endif // UNDER_CE |
| 257 | 268 | ||
| 258 | bool MyCreateHardLink(CFSTR newFileName, CFSTR existFileName) | 269 | bool MyCreateHardLink(CFSTR newFileName, CFSTR existFileName) |
| @@ -270,6 +281,7 @@ bool MyCreateHardLink(CFSTR newFileName, CFSTR existFileName) | |||
| 270 | else | 281 | else |
| 271 | #endif | 282 | #endif |
| 272 | { | 283 | { |
| 284 | #ifdef Z7_USE_DYN_CreateHardLink | ||
| 273 | const | 285 | const |
| 274 | Func_CreateHardLinkW | 286 | Func_CreateHardLinkW |
| 275 | my_CreateHardLinkW = Z7_GET_PROC_ADDRESS( | 287 | my_CreateHardLinkW = Z7_GET_PROC_ADDRESS( |
| @@ -277,9 +289,13 @@ bool MyCreateHardLink(CFSTR newFileName, CFSTR existFileName) | |||
| 277 | "CreateHardLinkW"); | 289 | "CreateHardLinkW"); |
| 278 | if (!my_CreateHardLinkW) | 290 | if (!my_CreateHardLinkW) |
| 279 | return false; | 291 | return false; |
| 292 | #define MY_CreateHardLinkW my_CreateHardLinkW | ||
| 293 | #else | ||
| 294 | #define MY_CreateHardLinkW CreateHardLinkW | ||
| 295 | #endif | ||
| 280 | IF_USE_MAIN_PATH_2(newFileName, existFileName) | 296 | IF_USE_MAIN_PATH_2(newFileName, existFileName) |
| 281 | { | 297 | { |
| 282 | if (my_CreateHardLinkW(fs2us(newFileName), fs2us(existFileName), NULL)) | 298 | if (MY_CreateHardLinkW(fs2us(newFileName), fs2us(existFileName), NULL)) |
| 283 | return true; | 299 | return true; |
| 284 | } | 300 | } |
| 285 | #ifdef Z7_LONG_PATH | 301 | #ifdef Z7_LONG_PATH |
| @@ -287,7 +303,7 @@ bool MyCreateHardLink(CFSTR newFileName, CFSTR existFileName) | |||
| 287 | { | 303 | { |
| 288 | UString d1, d2; | 304 | UString d1, d2; |
| 289 | if (GetSuperPaths(newFileName, existFileName, d1, d2, USE_MAIN_PATH_2)) | 305 | if (GetSuperPaths(newFileName, existFileName, d1, d2, USE_MAIN_PATH_2)) |
| 290 | return BOOLToBool(my_CreateHardLinkW(d1, d2, NULL)); | 306 | return BOOLToBool(MY_CreateHardLinkW(d1, d2, NULL)); |
| 291 | } | 307 | } |
| 292 | #endif | 308 | #endif |
| 293 | } | 309 | } |
| @@ -780,7 +796,7 @@ bool CreateTempFile2(CFSTR prefix, bool addRandom, AString &postfix, NIO::COutFi | |||
| 780 | unsigned k; | 796 | unsigned k; |
| 781 | for (k = 0; k < 8; k++) | 797 | for (k = 0; k < 8; k++) |
| 782 | { | 798 | { |
| 783 | const unsigned t = val & 0xF; | 799 | const unsigned t = (unsigned)val & 0xF; |
| 784 | val >>= 4; | 800 | val >>= 4; |
| 785 | s[k] = (char)((t < 10) ? ('0' + t) : ('A' + (t - 10))); | 801 | s[k] = (char)((t < 10) ? ('0' + t) : ('A' + (t - 10))); |
| 786 | } | 802 | } |
| @@ -805,7 +821,7 @@ bool CreateTempFile2(CFSTR prefix, bool addRandom, AString &postfix, NIO::COutFi | |||
| 805 | } | 821 | } |
| 806 | if (outFile) | 822 | if (outFile) |
| 807 | { | 823 | { |
| 808 | if (outFile->Create(path, false)) | 824 | if (outFile->Create_NEW(path)) |
| 809 | return true; | 825 | return true; |
| 810 | } | 826 | } |
| 811 | else | 827 | else |
| @@ -928,7 +944,7 @@ bool RemoveDir(CFSTR path) | |||
| 928 | static BOOL My_CopyFile(CFSTR oldFile, CFSTR newFile) | 944 | static BOOL My_CopyFile(CFSTR oldFile, CFSTR newFile) |
| 929 | { | 945 | { |
| 930 | NWindows::NFile::NIO::COutFile outFile; | 946 | NWindows::NFile::NIO::COutFile outFile; |
| 931 | if (!outFile.Create(newFile, false)) | 947 | if (!outFile.Create_NEW(newFile)) |
| 932 | return FALSE; | 948 | return FALSE; |
| 933 | 949 | ||
| 934 | NWindows::NFile::NIO::CInFile inFile; | 950 | NWindows::NFile::NIO::CInFile inFile; |
