void CProxyArc2::GetDirPathParts(int dirIndex, UStringVector &pathParts, bool &isAltStreamDir) const { pathParts.Clear(); isAltStreamDir = false; if (dirIndex == k_Proxy2_RootDirIndex) return; if (dirIndex == k_Proxy2_AltRootDirIndex) { isAltStreamDir = true; return; } while (dirIndex >= k_Proxy2_NumRootDirs) { const CProxyDir2 &dir = Dirs[dirIndex]; const CProxyFile2 &file = Files[dir.ArcIndex]; if (pathParts.IsEmpty() && dirIndex == file.AltDirIndex) isAltStreamDir = true; pathParts.Insert(0, file.Name); int par = file.Parent; if (par < 0) break; dirIndex = Files[par].DirIndex; } }
bool CCensorNode::CheckPathToRoot(bool include, UStringVector &pathParts, bool isFile) const { if (CheckPathCurrent(include, pathParts, isFile)) return true; if (Parent == 0) return false; pathParts.Insert(0, Name); return Parent->CheckPathToRoot(include, pathParts, isFile); }
void AddUniqueStringToHeadOfList(UStringVector &list, const UString &s) { for (unsigned i = 0; i < list.Size();) if (s.IsEqualTo_NoCase(list[i])) list.Delete(i); else i++; list.Insert(0, s); }
void CProxyFolder::GetPathParts(UStringVector &pathParts) const { pathParts.Clear(); const CProxyFolder *current = this; while (current->Parent != NULL) { pathParts.Insert(0, current->Name); current = current->Parent; } }
void CProxyArc::GetDirPathParts(int dirIndex, UStringVector &pathParts) const { pathParts.Clear(); while (dirIndex >= 0) { const CProxyDir &dir = Dirs[dirIndex]; dirIndex = dir.ParentDir; if (dirIndex < 0) break; pathParts.Insert(0, dir.Name); } }
bool ParseVolumeSizes(const UString &s, CRecordVector<UInt64> &values) { values.Clear(); UStringVector destStrings; SplitString(s, destStrings); bool prevIsNumber = false; for (int i = 0; i < destStrings.Size(); i++) { UString subString = destStrings[i]; subString.MakeUpper(); if (subString.IsEmpty()) return false; if (subString == L"-") return true; if (prevIsNumber) { wchar_t c = subString[0]; UInt64 &value = values.Back(); prevIsNumber = false; switch(c) { case L'B': continue; case L'K': value <<= 10; continue; case L'M': value <<= 20; continue; case L'G': value <<= 30; continue; } } const wchar_t *start = subString; const wchar_t *end; UInt64 value = ConvertStringToUInt64(start, &end); if (start == end) return false; if (value == 0) return false; values.Add(value); prevIsNumber = true; UString rem = subString.Mid((int)(end - start)); if (!rem.IsEmpty()) destStrings.Insert(i + 1, rem); } return true; }
void CPlugin::GetPathParts(UStringVector &pathParts) { pathParts.Clear(); CMyComPtr<IFolderFolder> folderItem = _folder; for (;;) { CMyComPtr<IFolderFolder> newFolder; folderItem->BindToParentFolder(&newFolder); if (newFolder == NULL) break; NCOM::CPropVariant prop; if (folderItem->GetFolderProperty(kpidName, &prop) == S_OK) if (prop.vt == VT_BSTR) pathParts.Insert(0, (const wchar_t *)prop.bstrVal); folderItem = newFolder; } }
STDMETHODIMP CAgent::SetFolder(IFolderFolder *folder) { _archiveNamePrefix.Empty(); if (folder == NULL) { _agentFolder = NULL; return S_OK; } else { CMyComPtr<IFolderFolder> archiveFolder = folder; CMyComPtr<IArchiveFolderInternal> archiveFolderInternal; RINOK(archiveFolder.QueryInterface(IID_IArchiveFolderInternal, &archiveFolderInternal)); RINOK(archiveFolderInternal->GetAgentFolder(&_agentFolder)); } UStringVector pathParts; pathParts.Clear(); CMyComPtr<IFolderFolder> folderItem = folder; if (folderItem != NULL) for (;;) { CMyComPtr<IFolderFolder> newFolder; folderItem->BindToParentFolder(&newFolder); if (newFolder == NULL) break; NCOM::CPropVariant prop; if (folderItem->GetFolderProperty(kpidName, &prop) == S_OK) if (prop.vt == VT_BSTR) pathParts.Insert(0, (const wchar_t *)prop.bstrVal); folderItem = newFolder; } for (int i = 0; i < pathParts.Size(); i++) { _archiveNamePrefix += pathParts[i]; _archiveNamePrefix += WCHAR_PATH_SEPARATOR; } return S_OK; }
void Correct_FsPath(bool absIsAllowed, UStringVector &parts, bool isDir) { unsigned i = 0; if (absIsAllowed) { #if defined(_WIN32) && !defined(UNDER_CE) bool isDrive = false; #endif if (parts[0].IsEmpty()) { i = 1; #if defined(_WIN32) && !defined(UNDER_CE) if (parts.Size() > 1 && parts[1].IsEmpty()) { i = 2; if (parts.Size() > 2 && parts[2] == L"?") { i = 3; if (parts.Size() > 3 && NWindows::NFile::NName::IsDrivePath2(parts[3])) { isDrive = true; i = 4; } } } #endif } #if defined(_WIN32) && !defined(UNDER_CE) else if (NWindows::NFile::NName::IsDrivePath2(parts[0])) { isDrive = true; i = 1; } if (isDrive) { // we convert "c:name" to "c:\name", if absIsAllowed path. UString &ds = parts[i - 1]; if (ds.Len() > 2) { parts.Insert(i, ds.Ptr(2)); ds.DeleteFrom(2); } } #endif } for (; i < parts.Size();) { UString &s = parts[i]; Correct_PathPart(s); if (s.IsEmpty()) { if (isDir || i != parts.Size() - 1) { parts.Delete(i); continue; } s = k_EmptyReplaceName; } else { #ifdef _WIN32 CorrectUnsupportedName(s); #endif } i++; } if (!isDir) { if (parts.IsEmpty()) parts.Add((UString)k_EmptyReplaceName); else { UString &s = parts.Back(); if (s.IsEmpty()) s = k_EmptyReplaceName; } } }