1baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// WorkDir.cpp 2baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 3baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "StdAfx.h" 4baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 5baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "Common/StringConvert.h" 6baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "Common/Wildcard.h" 7baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 8baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "Windows/FileDir.h" 9baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "Windows/FileName.h" 10baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 11baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "WorkDir.h" 12baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 13baa3858d3f5d128a5c8466b700098109edcad5f2repo syncusing namespace NWindows; 14baa3858d3f5d128a5c8466b700098109edcad5f2repo syncusing namespace NFile; 15baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 16baa3858d3f5d128a5c8466b700098109edcad5f2repo syncUString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path) 17baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 18baa3858d3f5d128a5c8466b700098109edcad5f2repo sync NWorkDir::NMode::EEnum mode = workDirInfo.Mode; 19baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #ifndef UNDER_CE 20baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (workDirInfo.ForRemovableOnly) 21baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 22baa3858d3f5d128a5c8466b700098109edcad5f2repo sync mode = NWorkDir::NMode::kCurrent; 23baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UString prefix = path.Left(3); 24baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (prefix[1] == L':' && prefix[2] == L'\\') 25baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 26baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UINT driveType = GetDriveType(GetSystemString(prefix, ::AreFileApisANSI() ? CP_ACP : CP_OEMCP)); 27baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (driveType == DRIVE_CDROM || driveType == DRIVE_REMOVABLE) 28baa3858d3f5d128a5c8466b700098109edcad5f2repo sync mode = workDirInfo.Mode; 29baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 30baa3858d3f5d128a5c8466b700098109edcad5f2repo sync /* 31baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CParsedPath parsedPath; 32baa3858d3f5d128a5c8466b700098109edcad5f2repo sync parsedPath.ParsePath(archiveName); 33baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UINT driveType = GetDriveType(parsedPath.Prefix); 34baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if ((driveType != DRIVE_CDROM) && (driveType != DRIVE_REMOVABLE)) 35baa3858d3f5d128a5c8466b700098109edcad5f2repo sync mode = NZipSettings::NWorkDir::NMode::kCurrent; 36baa3858d3f5d128a5c8466b700098109edcad5f2repo sync */ 37baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 38baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #endif 39baa3858d3f5d128a5c8466b700098109edcad5f2repo sync switch(mode) 40baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 41baa3858d3f5d128a5c8466b700098109edcad5f2repo sync case NWorkDir::NMode::kCurrent: 42baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 43baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return ExtractDirPrefixFromPath(path); 44baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 45baa3858d3f5d128a5c8466b700098109edcad5f2repo sync case NWorkDir::NMode::kSpecified: 46baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 47baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UString tempDir = workDirInfo.Path; 48baa3858d3f5d128a5c8466b700098109edcad5f2repo sync NName::NormalizeDirPathPrefix(tempDir); 49baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return tempDir; 50baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 51baa3858d3f5d128a5c8466b700098109edcad5f2repo sync default: 52baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 53baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UString tempDir; 54baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (!NDirectory::MyGetTempPath(tempDir)) 55baa3858d3f5d128a5c8466b700098109edcad5f2repo sync throw 141717; 56baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return tempDir; 57baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 58baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 59baa3858d3f5d128a5c8466b700098109edcad5f2repo sync} 60