diff options
Diffstat (limited to '')
-rw-r--r-- | CPP/7zip/UI/FileManager/FSFolder.cpp | 241 |
1 files changed, 120 insertions, 121 deletions
diff --git a/CPP/7zip/UI/FileManager/FSFolder.cpp b/CPP/7zip/UI/FileManager/FSFolder.cpp index f603061..06c572d 100644 --- a/CPP/7zip/UI/FileManager/FSFolder.cpp +++ b/CPP/7zip/UI/FileManager/FSFolder.cpp | |||
@@ -2,15 +2,24 @@ | |||
2 | 2 | ||
3 | #include "StdAfx.h" | 3 | #include "StdAfx.h" |
4 | 4 | ||
5 | #if defined(_MSC_VER) | 5 | #ifdef __MINGW32_VERSION |
6 | #include <winternl.h> | 6 | // #if !defined(_MSC_VER) && (__GNUC__) && (__GNUC__ < 10) |
7 | // for old mingw | ||
8 | #include <ddk/ntddk.h> | ||
7 | #else | 9 | #else |
8 | #if defined(__GNUC__) && (__GNUC__ >= 10) | 10 | #ifndef Z7_OLD_WIN_SDK |
9 | // new mingw: | 11 | #if !defined(_M_IA64) |
10 | #include <winternl.h> | 12 | #include <winternl.h> |
13 | #endif | ||
11 | #else | 14 | #else |
12 | // old mingw: | 15 | typedef LONG NTSTATUS; |
13 | #include <ddk/winddk.h> | 16 | typedef struct _IO_STATUS_BLOCK { |
17 | union { | ||
18 | NTSTATUS Status; | ||
19 | PVOID Pointer; | ||
20 | }; | ||
21 | ULONG_PTR Information; | ||
22 | } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; | ||
14 | #endif | 23 | #endif |
15 | #endif | 24 | #endif |
16 | 25 | ||
@@ -106,7 +115,7 @@ HRESULT CFSFolder::Init(const FString &path /* , IFolderFolder *parentFolder */) | |||
106 | 115 | ||
107 | if (!_findChangeNotification.IsHandleAllocated()) | 116 | if (!_findChangeNotification.IsHandleAllocated()) |
108 | { | 117 | { |
109 | DWORD lastError = GetLastError(); | 118 | const HRESULT lastError = GetLastError_noZero_HRESULT(); |
110 | CFindFile findFile; | 119 | CFindFile findFile; |
111 | CFileInfo fi; | 120 | CFileInfo fi; |
112 | FString path2 = _path; | 121 | FString path2 = _path; |
@@ -125,7 +134,7 @@ HRESULT CFsFolderStat::Enumerate() | |||
125 | { | 134 | { |
126 | if (Progress) | 135 | if (Progress) |
127 | { | 136 | { |
128 | RINOK(Progress->SetCompleted(NULL)); | 137 | RINOK(Progress->SetCompleted(NULL)) |
129 | } | 138 | } |
130 | Path.Add_PathSepar(); | 139 | Path.Add_PathSepar(); |
131 | const unsigned len = Path.Len(); | 140 | const unsigned len = Path.Len(); |
@@ -139,7 +148,7 @@ HRESULT CFsFolderStat::Enumerate() | |||
139 | NumFolders++; | 148 | NumFolders++; |
140 | Path.DeleteFrom(len); | 149 | Path.DeleteFrom(len); |
141 | Path += fi.Name; | 150 | Path += fi.Name; |
142 | RINOK(Enumerate()); | 151 | RINOK(Enumerate()) |
143 | } | 152 | } |
144 | else | 153 | else |
145 | { | 154 | { |
@@ -166,7 +175,7 @@ bool MyGetCompressedFileSizeW(CFSTR path, UInt64 &size) | |||
166 | return true; | 175 | return true; |
167 | } | 176 | } |
168 | } | 177 | } |
169 | #ifdef WIN_LONG_PATH | 178 | #ifdef Z7_LONG_PATH |
170 | if (USE_SUPER_PATH) | 179 | if (USE_SUPER_PATH) |
171 | { | 180 | { |
172 | UString superPath; | 181 | UString superPath; |
@@ -285,16 +294,16 @@ HRESULT CFSFolder::LoadSubItems(int dirItem, const FString &relPrefix) | |||
285 | 294 | ||
286 | const unsigned endIndex = Folders.Size(); | 295 | const unsigned endIndex = Folders.Size(); |
287 | for (unsigned i = startIndex; i < endIndex; i++) | 296 | for (unsigned i = startIndex; i < endIndex; i++) |
288 | LoadSubItems(i, Folders[i]); | 297 | LoadSubItems((int)i, Folders[i]); |
289 | return S_OK; | 298 | return S_OK; |
290 | } | 299 | } |
291 | 300 | ||
292 | STDMETHODIMP CFSFolder::LoadItems() | 301 | Z7_COM7F_IMF(CFSFolder::LoadItems()) |
293 | { | 302 | { |
294 | Int32 dummy; | 303 | Int32 dummy; |
295 | WasChanged(&dummy); | 304 | WasChanged(&dummy); |
296 | Clear(); | 305 | Clear(); |
297 | RINOK(LoadSubItems(-1, FString())); | 306 | RINOK(LoadSubItems(-1, FString())) |
298 | _commentsAreLoaded = false; | 307 | _commentsAreLoaded = false; |
299 | return S_OK; | 308 | return S_OK; |
300 | } | 309 | } |
@@ -356,7 +365,7 @@ bool CFSFolder::SaveComments() | |||
356 | return true; | 365 | return true; |
357 | } | 366 | } |
358 | 367 | ||
359 | STDMETHODIMP CFSFolder::GetNumberOfItems(UInt32 *numItems) | 368 | Z7_COM7F_IMF(CFSFolder::GetNumberOfItems(UInt32 *numItems)) |
360 | { | 369 | { |
361 | *numItems = Files.Size() /* + Streams.Size() */; | 370 | *numItems = Files.Size() /* + Streams.Size() */; |
362 | return S_OK; | 371 | return S_OK; |
@@ -364,9 +373,9 @@ STDMETHODIMP CFSFolder::GetNumberOfItems(UInt32 *numItems) | |||
364 | 373 | ||
365 | #ifdef USE_UNICODE_FSTRING | 374 | #ifdef USE_UNICODE_FSTRING |
366 | 375 | ||
367 | STDMETHODIMP CFSFolder::GetItemPrefix(UInt32 index, const wchar_t **name, unsigned *len) | 376 | Z7_COM7F_IMF(CFSFolder::GetItemPrefix(UInt32 index, const wchar_t **name, unsigned *len)) |
368 | { | 377 | { |
369 | *name = 0; | 378 | *name = NULL; |
370 | *len = 0; | 379 | *len = 0; |
371 | /* | 380 | /* |
372 | if (index >= Files.Size()) | 381 | if (index >= Files.Size()) |
@@ -383,9 +392,9 @@ STDMETHODIMP CFSFolder::GetItemPrefix(UInt32 index, const wchar_t **name, unsign | |||
383 | return S_OK; | 392 | return S_OK; |
384 | } | 393 | } |
385 | 394 | ||
386 | STDMETHODIMP CFSFolder::GetItemName(UInt32 index, const wchar_t **name, unsigned *len) | 395 | Z7_COM7F_IMF(CFSFolder::GetItemName(UInt32 index, const wchar_t **name, unsigned *len)) |
387 | { | 396 | { |
388 | *name = 0; | 397 | *name = NULL; |
389 | *len = 0; | 398 | *len = 0; |
390 | if (index < Files.Size()) | 399 | if (index < Files.Size()) |
391 | { | 400 | { |
@@ -405,7 +414,7 @@ STDMETHODIMP CFSFolder::GetItemName(UInt32 index, const wchar_t **name, unsigned | |||
405 | return S_OK; | 414 | return S_OK; |
406 | } | 415 | } |
407 | 416 | ||
408 | STDMETHODIMP_(UInt64) CFSFolder::GetItemSize(UInt32 index) | 417 | Z7_COM7F_IMF2(UInt64, CFSFolder::GetItemSize(UInt32 index)) |
409 | { | 418 | { |
410 | /* | 419 | /* |
411 | if (index >= Files.Size()) | 420 | if (index >= Files.Size()) |
@@ -434,6 +443,8 @@ bool CFSFolder::ReadFileInfo(CDirItem &di) | |||
434 | } | 443 | } |
435 | 444 | ||
436 | 445 | ||
446 | EXTERN_C_BEGIN | ||
447 | |||
437 | typedef struct | 448 | typedef struct |
438 | { | 449 | { |
439 | LARGE_INTEGER CreationTime; | 450 | LARGE_INTEGER CreationTime; |
@@ -443,37 +454,57 @@ typedef struct | |||
443 | ULONG FileAttributes; | 454 | ULONG FileAttributes; |
444 | UInt32 Reserved; // it's expected for alignment | 455 | UInt32 Reserved; // it's expected for alignment |
445 | } | 456 | } |
446 | MY__FILE_BASIC_INFORMATION; | 457 | Z7_WIN_FILE_BASIC_INFORMATION; |
447 | 458 | ||
448 | 459 | ||
449 | typedef enum | 460 | typedef enum |
450 | { | 461 | { |
451 | MY__FileDirectoryInformation = 1, | 462 | Z7_WIN_FileDirectoryInformation = 1, |
452 | MY__FileFullDirectoryInformation, | 463 | Z7_WIN_FileFullDirectoryInformation, |
453 | MY__FileBothDirectoryInformation, | 464 | Z7_WIN_FileBothDirectoryInformation, |
454 | MY__FileBasicInformation | 465 | Z7_WIN_FileBasicInformation |
455 | } | 466 | } |
456 | MY__FILE_INFORMATION_CLASS; | 467 | Z7_WIN_FILE_INFORMATION_CLASS; |
468 | |||
457 | 469 | ||
470 | #if (_WIN32_WINNT >= 0x0500) && !defined(_M_IA64) | ||
471 | #define Z7_WIN_NTSTATUS NTSTATUS | ||
472 | #define Z7_WIN_IO_STATUS_BLOCK IO_STATUS_BLOCK | ||
473 | #else | ||
474 | typedef LONG Z7_WIN_NTSTATUS; | ||
475 | typedef struct | ||
476 | { | ||
477 | union | ||
478 | { | ||
479 | Z7_WIN_NTSTATUS Status; | ||
480 | PVOID Pointer; | ||
481 | } DUMMYUNIONNAME; | ||
482 | ULONG_PTR Information; | ||
483 | } Z7_WIN_IO_STATUS_BLOCK; | ||
484 | #endif | ||
458 | 485 | ||
459 | typedef NTSTATUS (WINAPI * Func_NtQueryInformationFile)( | ||
460 | HANDLE handle, IO_STATUS_BLOCK *io, | ||
461 | void *ptr, LONG len, MY__FILE_INFORMATION_CLASS cls); | ||
462 | 486 | ||
463 | #define MY__STATUS_SUCCESS 0 | 487 | typedef Z7_WIN_NTSTATUS (WINAPI * Func_NtQueryInformationFile)( |
488 | HANDLE handle, Z7_WIN_IO_STATUS_BLOCK *io, | ||
489 | void *ptr, LONG len, Z7_WIN_FILE_INFORMATION_CLASS cls); | ||
490 | |||
491 | #define MY_STATUS_SUCCESS 0 | ||
492 | |||
493 | EXTERN_C_END | ||
464 | 494 | ||
465 | static Func_NtQueryInformationFile f_NtQueryInformationFile; | 495 | static Func_NtQueryInformationFile f_NtQueryInformationFile; |
466 | static bool g_NtQueryInformationFile_WasRequested = false; | 496 | static bool g_NtQueryInformationFile_WasRequested = false; |
467 | 497 | ||
498 | |||
468 | void CFSFolder::ReadChangeTime(CDirItem &di) | 499 | void CFSFolder::ReadChangeTime(CDirItem &di) |
469 | { | 500 | { |
470 | di.ChangeTime_WasRequested = true; | 501 | di.ChangeTime_WasRequested = true; |
471 | 502 | ||
472 | if (!g_NtQueryInformationFile_WasRequested) | 503 | if (!g_NtQueryInformationFile_WasRequested) |
473 | { | 504 | { |
474 | g_NtQueryInformationFile_WasRequested = true; | 505 | g_NtQueryInformationFile_WasRequested = true; |
475 | f_NtQueryInformationFile = (Func_NtQueryInformationFile) | 506 | f_NtQueryInformationFile = Z7_GET_PROC_ADDRESS( |
476 | My_GetProcAddress(::GetModuleHandleW(L"ntdll.dll"), | 507 | Func_NtQueryInformationFile, ::GetModuleHandleW(L"ntdll.dll"), |
477 | "NtQueryInformationFile"); | 508 | "NtQueryInformationFile"); |
478 | } | 509 | } |
479 | if (!f_NtQueryInformationFile) | 510 | if (!f_NtQueryInformationFile) |
@@ -482,23 +513,23 @@ void CFSFolder::ReadChangeTime(CDirItem &di) | |||
482 | NIO::CInFile file; | 513 | NIO::CInFile file; |
483 | if (!file.Open_for_ReadAttributes(_path + GetRelPath(di))) | 514 | if (!file.Open_for_ReadAttributes(_path + GetRelPath(di))) |
484 | return; | 515 | return; |
485 | MY__FILE_BASIC_INFORMATION fbi; | 516 | Z7_WIN_FILE_BASIC_INFORMATION fbi; |
486 | IO_STATUS_BLOCK IoStatusBlock; | 517 | Z7_WIN_IO_STATUS_BLOCK IoStatusBlock; |
487 | const NTSTATUS status = f_NtQueryInformationFile(file.GetHandle(), &IoStatusBlock, | 518 | const Z7_WIN_NTSTATUS status = f_NtQueryInformationFile(file.GetHandle(), &IoStatusBlock, |
488 | &fbi, sizeof(fbi), MY__FileBasicInformation); | 519 | &fbi, sizeof(fbi), Z7_WIN_FileBasicInformation); |
489 | if (status != MY__STATUS_SUCCESS) | 520 | if (status != MY_STATUS_SUCCESS) |
490 | return; | 521 | return; |
491 | if (IoStatusBlock.Information != sizeof(fbi)) | 522 | if (IoStatusBlock.Information != sizeof(fbi)) |
492 | return; | 523 | return; |
493 | di.ChangeTime.dwLowDateTime = fbi.ChangeTime.u.LowPart; | 524 | di.ChangeTime.dwLowDateTime = fbi.ChangeTime.u.LowPart; |
494 | di.ChangeTime.dwHighDateTime = fbi.ChangeTime.u.HighPart; | 525 | di.ChangeTime.dwHighDateTime = (DWORD)fbi.ChangeTime.u.HighPart; |
495 | di.ChangeTime_Defined = true; | 526 | di.ChangeTime_Defined = true; |
496 | } | 527 | } |
497 | 528 | ||
498 | #endif // FS_SHOW_LINKS_INFO | 529 | #endif // FS_SHOW_LINKS_INFO |
499 | 530 | ||
500 | 531 | ||
501 | STDMETHODIMP CFSFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value) | 532 | Z7_COM7F_IMF(CFSFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)) |
502 | { | 533 | { |
503 | NCOM::CPropVariant prop; | 534 | NCOM::CPropVariant prop; |
504 | /* | 535 | /* |
@@ -622,34 +653,32 @@ STDMETHODIMP CFSFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va | |||
622 | // ---------- IArchiveGetRawProps ---------- | 653 | // ---------- IArchiveGetRawProps ---------- |
623 | 654 | ||
624 | 655 | ||
625 | STDMETHODIMP CFSFolder::GetNumRawProps(UInt32 *numProps) | 656 | Z7_COM7F_IMF(CFSFolder::GetNumRawProps(UInt32 *numProps)) |
626 | { | 657 | { |
627 | *numProps = 1; | 658 | *numProps = 1; |
628 | return S_OK; | 659 | return S_OK; |
629 | } | 660 | } |
630 | 661 | ||
631 | STDMETHODIMP CFSFolder::GetRawPropInfo(UInt32 /* index */, BSTR *name, PROPID *propID) | 662 | Z7_COM7F_IMF(CFSFolder::GetRawPropInfo(UInt32 /* index */, BSTR *name, PROPID *propID)) |
632 | { | 663 | { |
633 | *name = NULL; | 664 | *name = NULL; |
634 | *propID = kpidNtReparse; | 665 | *propID = kpidNtReparse; |
635 | return S_OK; | 666 | return S_OK; |
636 | } | 667 | } |
637 | 668 | ||
638 | STDMETHODIMP CFSFolder::GetParent(UInt32 /* index */, UInt32 * /* parent */, UInt32 * /* parentType */) | 669 | Z7_COM7F_IMF(CFSFolder::GetParent(UInt32 /* index */, UInt32 * /* parent */, UInt32 * /* parentType */)) |
639 | { | 670 | { |
640 | return E_FAIL; | 671 | return E_FAIL; |
641 | } | 672 | } |
642 | 673 | ||
643 | STDMETHODIMP CFSFolder::GetRawProp(UInt32 | 674 | Z7_COM7F_IMF(CFSFolder::GetRawProp(UInt32 index, PROPID propID, |
644 | #ifndef UNDER_CE | 675 | const void **data, UInt32 *dataSize, UInt32 *propType)) |
645 | index | ||
646 | #endif | ||
647 | , PROPID | ||
648 | #ifndef UNDER_CE | ||
649 | propID | ||
650 | #endif | ||
651 | , const void **data, UInt32 *dataSize, UInt32 *propType) | ||
652 | { | 676 | { |
677 | #ifdef UNDER_CE | ||
678 | UNUSED(index) | ||
679 | UNUSED(propID) | ||
680 | #endif | ||
681 | |||
653 | *data = NULL; | 682 | *data = NULL; |
654 | *dataSize = 0; | 683 | *dataSize = 0; |
655 | *propType = 0; | 684 | *propType = 0; |
@@ -676,11 +705,11 @@ STDMETHODIMP CFSFolder::GetRawProp(UInt32 | |||
676 | 705 | ||
677 | static inline CFSTR GetExtensionPtr(const FString &name) | 706 | static inline CFSTR GetExtensionPtr(const FString &name) |
678 | { | 707 | { |
679 | int dotPos = name.ReverseFind_Dot(); | 708 | const int dotPos = name.ReverseFind_Dot(); |
680 | return name.Ptr((dotPos < 0) ? name.Len() : dotPos); | 709 | return name.Ptr((dotPos < 0) ? name.Len() : (unsigned)dotPos); |
681 | } | 710 | } |
682 | 711 | ||
683 | STDMETHODIMP_(Int32) CFSFolder::CompareItems(UInt32 index1, UInt32 index2, PROPID propID, Int32 /* propIsRaw */) | 712 | Z7_COM7F_IMF2(Int32, CFSFolder::CompareItems(UInt32 index1, UInt32 index2, PROPID propID, Int32 /* propIsRaw */)) |
684 | { | 713 | { |
685 | /* | 714 | /* |
686 | const CAltStream *ss1 = NULL; | 715 | const CAltStream *ss1 = NULL; |
@@ -695,7 +724,7 @@ STDMETHODIMP_(Int32) CFSFolder::CompareItems(UInt32 index1, UInt32 index2, PROPI | |||
695 | { | 724 | { |
696 | case kpidName: | 725 | case kpidName: |
697 | { | 726 | { |
698 | int comp = CompareFileNames_ForFolderList(fi1.Name, fi2.Name); | 727 | const int comp = CompareFileNames_ForFolderList(fi1.Name, fi2.Name); |
699 | /* | 728 | /* |
700 | if (comp != 0) | 729 | if (comp != 0) |
701 | return comp; | 730 | return comp; |
@@ -783,10 +812,10 @@ STDMETHODIMP_(Int32) CFSFolder::CompareItems(UInt32 index1, UInt32 index2, PROPI | |||
783 | 812 | ||
784 | HRESULT CFSFolder::BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder) | 813 | HRESULT CFSFolder::BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder) |
785 | { | 814 | { |
786 | *resultFolder = 0; | 815 | *resultFolder = NULL; |
787 | CFSFolder *folderSpec = new CFSFolder; | 816 | CFSFolder *folderSpec = new CFSFolder; |
788 | CMyComPtr<IFolderFolder> subFolder = folderSpec; | 817 | CMyComPtr<IFolderFolder> subFolder = folderSpec; |
789 | RINOK(folderSpec->Init(_path + name + FCHAR_PATH_SEPARATOR)); | 818 | RINOK(folderSpec->Init(_path + name + FCHAR_PATH_SEPARATOR)) |
790 | *resultFolder = subFolder.Detach(); | 819 | *resultFolder = subFolder.Detach(); |
791 | return S_OK; | 820 | return S_OK; |
792 | } | 821 | } |
@@ -836,23 +865,23 @@ FString CFSFolder::GetRelPath(const CDirItem &item) const | |||
836 | return Folders[item.Parent] + item.Name; | 865 | return Folders[item.Parent] + item.Name; |
837 | } | 866 | } |
838 | 867 | ||
839 | STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder) | 868 | Z7_COM7F_IMF(CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)) |
840 | { | 869 | { |
841 | *resultFolder = 0; | 870 | *resultFolder = NULL; |
842 | const CDirItem &fi = Files[index]; | 871 | const CDirItem &fi = Files[index]; |
843 | if (!fi.IsDir()) | 872 | if (!fi.IsDir()) |
844 | return E_INVALIDARG; | 873 | return E_INVALIDARG; |
845 | return BindToFolderSpec(GetRelPath(fi), resultFolder); | 874 | return BindToFolderSpec(GetRelPath(fi), resultFolder); |
846 | } | 875 | } |
847 | 876 | ||
848 | STDMETHODIMP CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder) | 877 | Z7_COM7F_IMF(CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)) |
849 | { | 878 | { |
850 | return BindToFolderSpec(us2fs(name), resultFolder); | 879 | return BindToFolderSpec(us2fs(name), resultFolder); |
851 | } | 880 | } |
852 | 881 | ||
853 | STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder) | 882 | Z7_COM7F_IMF(CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)) |
854 | { | 883 | { |
855 | *resultFolder = 0; | 884 | *resultFolder = NULL; |
856 | /* | 885 | /* |
857 | if (_parentFolder) | 886 | if (_parentFolder) |
858 | { | 887 | { |
@@ -914,17 +943,17 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder) | |||
914 | return S_OK; | 943 | return S_OK; |
915 | } | 944 | } |
916 | 945 | ||
917 | STDMETHODIMP CFSFolder::GetNumberOfProperties(UInt32 *numProperties) | 946 | Z7_COM7F_IMF(CFSFolder::GetNumberOfProperties(UInt32 *numProperties)) |
918 | { | 947 | { |
919 | *numProperties = ARRAY_SIZE(kProps); | 948 | *numProperties = Z7_ARRAY_SIZE(kProps); |
920 | if (!_flatMode) | 949 | if (!_flatMode) |
921 | (*numProperties)--; | 950 | (*numProperties)--; |
922 | return S_OK; | 951 | return S_OK; |
923 | } | 952 | } |
924 | 953 | ||
925 | STDMETHODIMP CFSFolder::GetPropertyInfo IMP_IFolderFolder_GetProp(kProps) | 954 | IMP_IFolderFolder_GetProp(CFSFolder::GetPropertyInfo, kProps) |
926 | 955 | ||
927 | STDMETHODIMP CFSFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value) | 956 | Z7_COM7F_IMF(CFSFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)) |
928 | { | 957 | { |
929 | COM_TRY_BEGIN | 958 | COM_TRY_BEGIN |
930 | NWindows::NCOM::CPropVariant prop; | 959 | NWindows::NCOM::CPropVariant prop; |
@@ -938,7 +967,7 @@ STDMETHODIMP CFSFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value) | |||
938 | COM_TRY_END | 967 | COM_TRY_END |
939 | } | 968 | } |
940 | 969 | ||
941 | STDMETHODIMP CFSFolder::WasChanged(Int32 *wasChanged) | 970 | Z7_COM7F_IMF(CFSFolder::WasChanged(Int32 *wasChanged)) |
942 | { | 971 | { |
943 | bool wasChangedMain = false; | 972 | bool wasChangedMain = false; |
944 | 973 | ||
@@ -961,7 +990,7 @@ STDMETHODIMP CFSFolder::WasChanged(Int32 *wasChanged) | |||
961 | return S_OK; | 990 | return S_OK; |
962 | } | 991 | } |
963 | 992 | ||
964 | STDMETHODIMP CFSFolder::Clone(IFolderFolder **resultFolder) | 993 | Z7_COM7F_IMF(CFSFolder::Clone(IFolderFolder **resultFolder)) |
965 | { | 994 | { |
966 | CFSFolder *fsFolderSpec = new CFSFolder; | 995 | CFSFolder *fsFolderSpec = new CFSFolder; |
967 | CMyComPtr<IFolderFolder> folderNew = fsFolderSpec; | 996 | CMyComPtr<IFolderFolder> folderNew = fsFolderSpec; |
@@ -970,35 +999,6 @@ STDMETHODIMP CFSFolder::Clone(IFolderFolder **resultFolder) | |||
970 | return S_OK; | 999 | return S_OK; |
971 | } | 1000 | } |
972 | 1001 | ||
973 | HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems, CFsFolderStat &stat) | ||
974 | { | ||
975 | for (UInt32 i = 0; i < numItems; i++) | ||
976 | { | ||
977 | UInt32 index = indices[i]; | ||
978 | /* | ||
979 | if (index >= Files.Size()) | ||
980 | { | ||
981 | size += Streams[index - Files.Size()].Size; | ||
982 | // numFiles++; | ||
983 | continue; | ||
984 | } | ||
985 | */ | ||
986 | const CDirItem &fi = Files[index]; | ||
987 | if (fi.IsDir()) | ||
988 | { | ||
989 | stat.Path = _path; | ||
990 | stat.Path += GetRelPath(fi); | ||
991 | RINOK(stat.Enumerate()); | ||
992 | stat.NumFolders++; | ||
993 | } | ||
994 | else | ||
995 | { | ||
996 | stat.NumFiles++; | ||
997 | stat.Size += fi.Size; | ||
998 | } | ||
999 | } | ||
1000 | return S_OK; | ||
1001 | } | ||
1002 | 1002 | ||
1003 | /* | 1003 | /* |
1004 | HRESULT CFSFolder::GetItemFullSize(unsigned index, UInt64 &size, IProgress *progress) | 1004 | HRESULT CFSFolder::GetItemFullSize(unsigned index, UInt64 &size, IProgress *progress) |
@@ -1019,7 +1019,7 @@ HRESULT CFSFolder::GetItemFullSize(unsigned index, UInt64 &size, IProgress *prog | |||
1019 | return S_OK; | 1019 | return S_OK; |
1020 | } | 1020 | } |
1021 | 1021 | ||
1022 | STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress) | 1022 | Z7_COM7F_IMF(CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress) |
1023 | { | 1023 | { |
1024 | NCOM::CPropVariant prop; | 1024 | NCOM::CPropVariant prop; |
1025 | UInt64 size = 0; | 1025 | UInt64 size = 0; |
@@ -1030,7 +1030,7 @@ STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgr | |||
1030 | } | 1030 | } |
1031 | */ | 1031 | */ |
1032 | 1032 | ||
1033 | STDMETHODIMP CFSFolder::CalcItemFullSize(UInt32 index, IProgress *progress) | 1033 | Z7_COM7F_IMF(CFSFolder::CalcItemFullSize(UInt32 index, IProgress *progress)) |
1034 | { | 1034 | { |
1035 | if (index >= (UInt32)Files.Size()) | 1035 | if (index >= (UInt32)Files.Size()) |
1036 | return S_OK; | 1036 | return S_OK; |
@@ -1038,7 +1038,7 @@ STDMETHODIMP CFSFolder::CalcItemFullSize(UInt32 index, IProgress *progress) | |||
1038 | if (!fi.IsDir()) | 1038 | if (!fi.IsDir()) |
1039 | return S_OK; | 1039 | return S_OK; |
1040 | CFsFolderStat stat(_path + GetRelPath(fi), progress); | 1040 | CFsFolderStat stat(_path + GetRelPath(fi), progress); |
1041 | RINOK(stat.Enumerate()); | 1041 | RINOK(stat.Enumerate()) |
1042 | fi.Size = stat.Size; | 1042 | fi.Size = stat.Size; |
1043 | fi.NumFolders = stat.NumFolders; | 1043 | fi.NumFolders = stat.NumFolders; |
1044 | fi.NumFiles = stat.NumFiles; | 1044 | fi.NumFiles = stat.NumFiles; |
@@ -1054,30 +1054,29 @@ void CFSFolder::GetAbsPath(const wchar_t *name, FString &absPath) | |||
1054 | absPath += us2fs(name); | 1054 | absPath += us2fs(name); |
1055 | } | 1055 | } |
1056 | 1056 | ||
1057 | STDMETHODIMP CFSFolder::CreateFolder(const wchar_t *name, IProgress * /* progress */) | 1057 | Z7_COM7F_IMF(CFSFolder::CreateFolder(const wchar_t *name, IProgress * /* progress */)) |
1058 | { | 1058 | { |
1059 | FString absPath; | 1059 | FString absPath; |
1060 | GetAbsPath(name, absPath); | 1060 | GetAbsPath(name, absPath); |
1061 | if (CreateDir(absPath)) | 1061 | if (CreateDir(absPath)) |
1062 | return S_OK; | 1062 | return S_OK; |
1063 | if (::GetLastError() == ERROR_ALREADY_EXISTS) | 1063 | if (::GetLastError() != ERROR_ALREADY_EXISTS) |
1064 | return ::GetLastError(); | 1064 | if (CreateComplexDir(absPath)) |
1065 | if (!CreateComplexDir(absPath)) | 1065 | return S_OK; |
1066 | return ::GetLastError(); | 1066 | return GetLastError_noZero_HRESULT(); |
1067 | return S_OK; | ||
1068 | } | 1067 | } |
1069 | 1068 | ||
1070 | STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress */) | 1069 | Z7_COM7F_IMF(CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress */)) |
1071 | { | 1070 | { |
1072 | FString absPath; | 1071 | FString absPath; |
1073 | GetAbsPath(name, absPath); | 1072 | GetAbsPath(name, absPath); |
1074 | NIO::COutFile outFile; | 1073 | NIO::COutFile outFile; |
1075 | if (!outFile.Create(absPath, false)) | 1074 | if (!outFile.Create(absPath, false)) |
1076 | return ::GetLastError(); | 1075 | return GetLastError_noZero_HRESULT(); |
1077 | return S_OK; | 1076 | return S_OK; |
1078 | } | 1077 | } |
1079 | 1078 | ||
1080 | STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * /* progress */) | 1079 | Z7_COM7F_IMF(CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * /* progress */)) |
1081 | { | 1080 | { |
1082 | if (index >= (UInt32)Files.Size()) | 1081 | if (index >= (UInt32)Files.Size()) |
1083 | return E_NOTIMPL; | 1082 | return E_NOTIMPL; |
@@ -1088,13 +1087,13 @@ STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * | |||
1088 | if (fi.Parent >= 0) | 1087 | if (fi.Parent >= 0) |
1089 | fullPrefix += Folders[fi.Parent]; | 1088 | fullPrefix += Folders[fi.Parent]; |
1090 | if (!MyMoveFile(fullPrefix + fi.Name, fullPrefix + us2fs(newName))) | 1089 | if (!MyMoveFile(fullPrefix + fi.Name, fullPrefix + us2fs(newName))) |
1091 | return GetLastError(); | 1090 | return GetLastError_noZero_HRESULT(); |
1092 | return S_OK; | 1091 | return S_OK; |
1093 | } | 1092 | } |
1094 | 1093 | ||
1095 | STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress *progress) | 1094 | Z7_COM7F_IMF(CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress *progress)) |
1096 | { | 1095 | { |
1097 | RINOK(progress->SetTotal(numItems)); | 1096 | RINOK(progress->SetTotal(numItems)) |
1098 | // int prevDeletedFileIndex = -1; | 1097 | // int prevDeletedFileIndex = -1; |
1099 | for (UInt32 i = 0; i < numItems; i++) | 1098 | for (UInt32 i = 0; i < numItems; i++) |
1100 | { | 1099 | { |
@@ -1123,15 +1122,15 @@ STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress | |||
1123 | result = DeleteFileAlways(fullPath); | 1122 | result = DeleteFileAlways(fullPath); |
1124 | } | 1123 | } |
1125 | if (!result) | 1124 | if (!result) |
1126 | return GetLastError(); | 1125 | return GetLastError_noZero_HRESULT(); |
1127 | UInt64 completed = i; | 1126 | const UInt64 completed = i; |
1128 | RINOK(progress->SetCompleted(&completed)); | 1127 | RINOK(progress->SetCompleted(&completed)) |
1129 | } | 1128 | } |
1130 | return S_OK; | 1129 | return S_OK; |
1131 | } | 1130 | } |
1132 | 1131 | ||
1133 | STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID, | 1132 | Z7_COM7F_IMF(CFSFolder::SetProperty(UInt32 index, PROPID propID, |
1134 | const PROPVARIANT *value, IProgress * /* progress */) | 1133 | const PROPVARIANT *value, IProgress * /* progress */)) |
1135 | { | 1134 | { |
1136 | if (index >= (UInt32)Files.Size()) | 1135 | if (index >= (UInt32)Files.Size()) |
1137 | return E_INVALIDARG; | 1136 | return E_INVALIDARG; |
@@ -1169,7 +1168,7 @@ STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID, | |||
1169 | return S_OK; | 1168 | return S_OK; |
1170 | } | 1169 | } |
1171 | 1170 | ||
1172 | STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex) | 1171 | Z7_COM7F_IMF(CFSFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex)) |
1173 | { | 1172 | { |
1174 | if (index >= (UInt32)Files.Size()) | 1173 | if (index >= (UInt32)Files.Size()) |
1175 | return E_INVALIDARG; | 1174 | return E_INVALIDARG; |
@@ -1181,17 +1180,17 @@ STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex) | |||
1181 | *iconIndex = iconIndexTemp; | 1180 | *iconIndex = iconIndexTemp; |
1182 | return S_OK; | 1181 | return S_OK; |
1183 | } | 1182 | } |
1184 | return GetLastError(); | 1183 | return GetLastError_noZero_HRESULT(); |
1185 | } | 1184 | } |
1186 | 1185 | ||
1187 | STDMETHODIMP CFSFolder::SetFlatMode(Int32 flatMode) | 1186 | Z7_COM7F_IMF(CFSFolder::SetFlatMode(Int32 flatMode)) |
1188 | { | 1187 | { |
1189 | _flatMode = IntToBool(flatMode); | 1188 | _flatMode = IntToBool(flatMode); |
1190 | return S_OK; | 1189 | return S_OK; |
1191 | } | 1190 | } |
1192 | 1191 | ||
1193 | /* | 1192 | /* |
1194 | STDMETHODIMP CFSFolder::SetShowNtfsStreamsMode(Int32 showStreamsMode) | 1193 | Z7_COM7F_IMF(CFSFolder::SetShowNtfsStreamsMode(Int32 showStreamsMode) |
1195 | { | 1194 | { |
1196 | _scanAltStreams = IntToBool(showStreamsMode); | 1195 | _scanAltStreams = IntToBool(showStreamsMode); |
1197 | return S_OK; | 1196 | return S_OK; |