diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2009-08-17 04:00:00 +0400 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:16:00 +0300 |
commit | c99f3ebdd639c2adb03d8b44001b10af18516504 (patch) | |
tree | 92aaf34e5edbd7287c3f55037190da75ab0a8000 /CPP/7zip/UI/FileManager/FSFolder.cpp | |
parent | 829409452d85cd6dd9dfc9151f109d6e13a2bb1c (diff) |
9.06 beta
Diffstat (limited to 'CPP/7zip/UI/FileManager/FSFolder.cpp')
-rwxr-xr-x | CPP/7zip/UI/FileManager/FSFolder.cpp | 133 |
1 files changed, 74 insertions, 59 deletions
diff --git a/CPP/7zip/UI/FileManager/FSFolder.cpp b/CPP/7zip/UI/FileManager/FSFolder.cpp index 5951fc09..1b3837cf 100755 --- a/CPP/7zip/UI/FileManager/FSFolder.cpp +++ b/CPP/7zip/UI/FileManager/FSFolder.cpp @@ -14,7 +14,11 @@ #include "FSDrives.h" #include "FSFolder.h" + +#ifndef UNDER_CE #include "NetFolder.h" +#endif + #include "SysIconUtils.h" namespace NWindows { @@ -61,8 +65,8 @@ HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder) { DWORD lastError = GetLastError(); CFindFile findFile; - CFileInfoW fileInfo; - if (!findFile.FindFirst(_path + UString(L"*"), fileInfo)) + CFileInfoW fi; + if (!findFile.FindFirst(_path + UString(L"*"), fi)) return lastError; } return S_OK; @@ -73,13 +77,13 @@ HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, RINOK(progress->SetCompleted(NULL)); numFiles = numFolders = size = 0; CEnumeratorW enumerator(path + UString(WSTRING_PATH_SEPARATOR L"*")); - CFileInfoW fileInfo; - while (enumerator.Next(fileInfo)) + CFileInfoW fi; + while (enumerator.Next(fi)) { - if (fileInfo.IsDir()) + if (fi.IsDir()) { UInt64 subFolders, subFiles, subSize; - RINOK(GetFolderSize(path + UString(WCHAR_PATH_SEPARATOR) + fileInfo.Name, subFolders, subFiles, subSize, progress)); + RINOK(GetFolderSize(path + UString(WCHAR_PATH_SEPARATOR) + fi.Name, subFolders, subFiles, subSize, progress)); numFolders += subFolders; numFolders++; numFiles += subFiles; @@ -88,7 +92,7 @@ HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, else { numFiles++; - size += fileInfo.Size; + size += fi.Size; } } return S_OK; @@ -98,21 +102,23 @@ HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path) { { CEnumeratorW enumerator(path + L"*"); - CDirItem fileInfo; - while (enumerator.Next(fileInfo)) + CDirItem fi; + while (enumerator.Next(fi)) { - fileInfo.CompressedSizeIsDefined = false; + #ifndef UNDER_CE + fi.CompressedSizeIsDefined = false; /* - if (!GetCompressedFileSize(_path + fileInfo.Name, - fileInfo.CompressedSize)) - fileInfo.CompressedSize = fileInfo.Size; + if (!GetCompressedFileSize(_path + fi.Name, + fi.CompressedSize)) + fi.CompressedSize = fi.Size; */ - if (fileInfo.IsDir()) + #endif + if (fi.IsDir()) { - // fileInfo.Size = GetFolderSize(_path + fileInfo.Name); - fileInfo.Size = 0; + // fi.Size = GetFolderSize(_path + fi.Name); + fi.Size = 0; } - dirItem.Files.Add(fileInfo); + dirItem.Files.Add(fi); } } if (!_flatMode) @@ -237,7 +243,8 @@ STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UInt32 *numSubFolders) } */ -bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size) +#ifndef UNDER_CE +static bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size) { DWORD highPart; DWORD lowPart = ::GetCompressedFileSizeW(fileName, &highPart); @@ -256,46 +263,49 @@ bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size) size = (UInt64(highPart) << 32) | lowPart; return true; } +#endif STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value) { NCOM::CPropVariant prop; if (itemIndex >= (UInt32)_refs.Size()) return E_INVALIDARG; - CDirItem &fileInfo = *_refs[itemIndex]; + CDirItem &fi = *_refs[itemIndex]; switch(propID) { - case kpidIsDir: prop = fileInfo.IsDir(); break; - case kpidName: prop = fileInfo.Name; break; - case kpidSize: if (!fileInfo.IsDir()) prop = fileInfo.Size; break; + case kpidIsDir: prop = fi.IsDir(); break; + case kpidName: prop = fi.Name; break; + case kpidSize: if (!fi.IsDir()) prop = fi.Size; break; case kpidPackSize: - if (!fileInfo.CompressedSizeIsDefined) + #ifdef UNDER_CE + prop = fi.Size; + #else + if (!fi.CompressedSizeIsDefined) { - fileInfo.CompressedSizeIsDefined = true; - if (fileInfo.IsDir () || - !MyGetCompressedFileSizeW(_path + GetRelPath(fileInfo), fileInfo.CompressedSize)) - fileInfo.CompressedSize = fileInfo.Size; + fi.CompressedSizeIsDefined = true; + if (fi.IsDir () || + !MyGetCompressedFileSizeW(_path + GetRelPath(fi), fi.CompressedSize)) + fi.CompressedSize = fi.Size; } - prop = fileInfo.CompressedSize; + prop = fi.CompressedSize; + #endif break; - case kpidAttrib: prop = (UInt32)fileInfo.Attrib; break; - case kpidCTime: prop = fileInfo.CTime; break; - case kpidATime: prop = fileInfo.ATime; break; - case kpidMTime: prop = fileInfo.MTime; break; + case kpidAttrib: prop = (UInt32)fi.Attrib; break; + case kpidCTime: prop = fi.CTime; break; + case kpidATime: prop = fi.ATime; break; + case kpidMTime: prop = fi.MTime; break; case kpidComment: { LoadComments(); UString comment; - if (_comments.GetValue(GetRelPath(fileInfo), comment)) + if (_comments.GetValue(GetRelPath(fi), comment)) prop = comment; break; } case kpidPrefix: { if (_flatMode) - { - prop = GetPrefix(fileInfo); - } + prop = GetPrefix(fi); break; } } @@ -333,10 +343,10 @@ UString CFSFolder::GetRelPath(const CDirItem &item) const STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder) { *resultFolder = 0; - const CDirItem &fileInfo = *_refs[index]; - if (!fileInfo.IsDir()) + const CDirItem &fi = *_refs[index]; + if (!fi.IsDir()) return E_INVALIDARG; - return BindToFolderSpec(GetRelPath(fileInfo), resultFolder); + return BindToFolderSpec(GetRelPath(fi), resultFolder); } STDMETHODIMP CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder) @@ -362,15 +372,19 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder) pos = parentPath.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos < 0) { - parentPath.Empty(); + #ifdef UNDER_CE + *resultFolder = 0; + #else CFSDrives *drivesFolderSpec = new CFSDrives; CMyComPtr<IFolderFolder> drivesFolder = drivesFolderSpec; drivesFolderSpec->Init(); *resultFolder = drivesFolder.Detach(); + #endif return S_OK; } UString parentPathReduced = parentPath.Left(pos); parentPath = parentPath.Left(pos + 1); + #ifndef UNDER_CE pos = parentPathReduced.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos == 1) { @@ -382,6 +396,7 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder) *resultFolder = netFolder.Detach(); return S_OK; } + #endif CFSFolder *parentFolderSpec = new CFSFolder; CMyComPtr<IFolderFolder> parentFolder = parentFolderSpec; RINOK(parentFolderSpec->Init(parentPath, 0)); @@ -457,11 +472,11 @@ HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems, int index = indices[i]; if (index >= _refs.Size()) return E_INVALIDARG; - const CDirItem &fileInfo = *_refs[index]; - if (fileInfo.IsDir()) + const CDirItem &fi = *_refs[index]; + if (fi.IsDir()) { UInt64 subFolders, subFiles, subSize; - RINOK(GetFolderSize(_path + GetRelPath(fileInfo), subFolders, subFiles, subSize, progress)); + RINOK(GetFolderSize(_path + GetRelPath(fi), subFolders, subFiles, subSize, progress)); numFolders += subFolders; numFolders++; numFiles += subFiles; @@ -470,7 +485,7 @@ HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems, else { numFiles++; - size += fileInfo.Size; + size += fi.Size; } } return S_OK; @@ -478,8 +493,8 @@ HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems, HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress) { - const CDirItem &fileInfo = *_refs[index]; - if (fileInfo.IsDir()) + const CDirItem &fi = *_refs[index]; + if (fi.IsDir()) { /* CMyComPtr<IFolderFolder> subFolder; @@ -499,9 +514,9 @@ HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress) } */ UInt64 numFolders, numFiles; - return GetFolderSize(_path + GetRelPath(fileInfo), numFolders, numFiles, size, progress); + return GetFolderSize(_path + GetRelPath(fi), numFolders, numFiles, size, progress); } - size = fileInfo.Size; + size = fi.Size; return S_OK; } @@ -560,9 +575,9 @@ STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * /* progress */) { - const CDirItem &fileInfo = *_refs[index]; - const UString fullPrefix = _path + GetPrefix(fileInfo); - if (!NDirectory::MyMoveFile(fullPrefix + fileInfo.Name, fullPrefix + newName)) + const CDirItem &fi = *_refs[index]; + const UString fullPrefix = _path + GetPrefix(fi); + if (!NDirectory::MyMoveFile(fullPrefix + fi.Name, fullPrefix + newName)) return GetLastError(); return S_OK; } @@ -572,10 +587,10 @@ STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress RINOK(progress->SetTotal(numItems)); for (UInt32 i = 0; i < numItems; i++) { - const CDirItem &fileInfo = *_refs[indices[i]]; - const UString fullPath = _path + GetRelPath(fileInfo); + const CDirItem &fi = *_refs[indices[i]]; + const UString fullPath = _path + GetRelPath(fi); bool result; - if (fileInfo.IsDir()) + if (fi.IsDir()) result = NDirectory::RemoveDirectoryWithSubItems(fullPath); else result = NDirectory::DeleteFileAlways(fullPath); @@ -592,14 +607,14 @@ STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID, { if (index >= (UInt32)_refs.Size()) return E_INVALIDARG; - CDirItem &fileInfo = *_refs[index]; - if (fileInfo.Parent->Parent != 0) + CDirItem &fi = *_refs[index]; + if (fi.Parent->Parent != 0) return E_NOTIMPL; switch(propID) { case kpidComment: { - UString filename = fileInfo.Name; + UString filename = fi.Name; filename.Trim(); if (value->vt == VT_EMPTY) _comments.DeletePair(filename); @@ -630,10 +645,10 @@ STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex) { if (index >= (UInt32)_refs.Size()) return E_INVALIDARG; - const CDirItem &fileInfo = *_refs[index]; + const CDirItem &fi = *_refs[index]; *iconIndex = 0; int iconIndexTemp; - if (GetRealIconIndex(_path + GetRelPath(fileInfo), fileInfo.Attrib, iconIndexTemp) != 0) + if (GetRealIconIndex(_path + GetRelPath(fi), fi.Attrib, iconIndexTemp) != 0) { *iconIndex = iconIndexTemp; return S_OK; |