Skip to content

Latest commit

 

History

History
64 lines (54 loc) · 1.49 KB

WorkDir.cpp

File metadata and controls

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