STDMETHODIMP CPhysDriveFolder::Clone(IFolderFolder **resultFolder) { CPhysDriveFolder *folderSpec = new CPhysDriveFolder; CMyComPtr<IFolderFolder> folderNew = folderSpec; folderSpec->Init(_path); *resultFolder = folderNew.Detach(); return S_OK; }
STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder) { *resultFolder = 0; UString name2 = name; name2.Trim(); if (name2.IsEmpty()) { CRootFolder *rootFolderSpec = new CRootFolder; CMyComPtr<IFolderFolder> rootFolder = rootFolderSpec; rootFolderSpec->Init(); *resultFolder = rootFolder.Detach(); return S_OK; } for (int i = 0; i < kNumRootFolderItems; i++) if (AreEqualNames(name2, _names[i])) return BindToFolder((UInt32)i, resultFolder); if (AreEqualNames(name2, L"My Documents") || AreEqualNames(name2, L"Documents")) return BindToFolder((UInt32)ROOT_INDEX_DOCUMENTS, resultFolder); if (AreEqualNames(name2, L"My Computer") || AreEqualNames(name2, L"Computer")) return BindToFolder((UInt32)ROOT_INDEX_COMPUTER, resultFolder); if (name2 == UString(WCHAR_PATH_SEPARATOR)) { CMyComPtr<IFolderFolder> subFolder = this; *resultFolder = subFolder.Detach(); return S_OK; } if (name2.Length () < 2) return E_INVALIDARG; CMyComPtr<IFolderFolder> subFolder; if (name2.Left(4) == L"\\\\.\\") { CPhysDriveFolder *folderSpec = new CPhysDriveFolder; subFolder = folderSpec; RINOK(folderSpec->Init(name2.Mid(4, 2))); } else { if (name2[name2.Length () - 1] != WCHAR_PATH_SEPARATOR) name2 += WCHAR_PATH_SEPARATOR; NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder; subFolder = fsFolderSpec; if (fsFolderSpec->Init(name2, 0) != S_OK) { if (name2[0] == WCHAR_PATH_SEPARATOR) { CNetFolder *netFolderSpec = new CNetFolder; subFolder = netFolderSpec; netFolderSpec->Init(name2); } else return E_INVALIDARG; } } *resultFolder = subFolder.Detach(); return S_OK; }