7 #include "Common/StringConvert.h"
8 #include "Common/Wildcard.h"
10 #include "Windows/FileName.h"
11 #include "Windows/FileDir.h"
13 static inline UINT GetCurrentCodePage()
14 { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
16 using namespace NWindows;
17 using namespace NFile;
18 using namespace NName;
20 UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path)
22 NWorkDir::NMode::EEnum mode = workDirInfo.Mode;
23 if (workDirInfo.ForRemovableOnly)
25 mode = NWorkDir::NMode::kCurrent;
26 UString prefix = path.Left(3);
27 if (prefix[1] == L':' && prefix[2] == L'\\')
29 UINT driveType = GetDriveType(GetSystemString(prefix, GetCurrentCodePage()));
30 if (driveType == DRIVE_CDROM || driveType == DRIVE_REMOVABLE)
31 mode = workDirInfo.Mode;
34 CParsedPath parsedPath;
35 parsedPath.ParsePath(archiveName);
36 UINT driveType = GetDriveType(parsedPath.Prefix);
37 if ((driveType != DRIVE_CDROM) && (driveType != DRIVE_REMOVABLE))
38 mode = NZipSettings::NWorkDir::NMode::kCurrent;
43 case NWorkDir::NMode::kCurrent:
45 return ExtractDirPrefixFromPath(path);
47 case NWorkDir::NMode::kSpecified:
49 UString tempDir = workDirInfo.Path;
50 NormalizeDirPathPrefix(tempDir);
56 if(!NFile::NDirectory::MyGetTempPath(tempDir))