aboutsummaryrefslogtreecommitdiff
path: root/CPP/7zip/UI/Common/WorkDir.cpp
diff options
context:
space:
mode:
authorrepo sync <gcondra@google.com>2013-07-26 17:53:31 -0700
committerrepo sync <gcondra@google.com>2013-07-29 11:00:59 -0700
commitbaa3858d3f5d128a5c8466b700098109edcad5f2 (patch)
tree2860fc3eaf476caa6296788b828f296a5ee37486 /CPP/7zip/UI/Common/WorkDir.cpp
parentdd8f4f771627dacc36cd45f18c2b54f939471065 (diff)
downloadlzma-baa3858d3f5d128a5c8466b700098109edcad5f2.tar.gz
The only change from stock lzma sdk is the removal of two .exe files, which we don't need. Change-Id: I46287cbc416161e93b449761ebe531acd758cf95
Diffstat (limited to 'CPP/7zip/UI/Common/WorkDir.cpp')
-rwxr-xr-xCPP/7zip/UI/Common/WorkDir.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/CPP/7zip/UI/Common/WorkDir.cpp b/CPP/7zip/UI/Common/WorkDir.cpp
new file mode 100755
index 0000000..2989632
--- /dev/null
+++ b/CPP/7zip/UI/Common/WorkDir.cpp
@@ -0,0 +1,59 @@
+// WorkDir.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringConvert.h"
+#include "Common/Wildcard.h"
+
+#include "Windows/FileDir.h"
+#include "Windows/FileName.h"
+
+#include "WorkDir.h"
+
+using namespace NWindows;
+using namespace NFile;
+
+UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path)
+{
+ NWorkDir::NMode::EEnum mode = workDirInfo.Mode;
+ #ifndef UNDER_CE
+ if (workDirInfo.ForRemovableOnly)
+ {
+ mode = NWorkDir::NMode::kCurrent;
+ UString prefix = path.Left(3);
+ if (prefix[1] == L':' && prefix[2] == L'\\')
+ {
+ UINT driveType = GetDriveType(GetSystemString(prefix, ::AreFileApisANSI() ? CP_ACP : CP_OEMCP));
+ 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;
+ */
+ }
+ #endif
+ switch(mode)
+ {
+ case NWorkDir::NMode::kCurrent:
+ {
+ return ExtractDirPrefixFromPath(path);
+ }
+ case NWorkDir::NMode::kSpecified:
+ {
+ UString tempDir = workDirInfo.Path;
+ NName::NormalizeDirPathPrefix(tempDir);
+ return tempDir;
+ }
+ default:
+ {
+ UString tempDir;
+ if (!NDirectory::MyGetTempPath(tempDir))
+ throw 141717;
+ return tempDir;
+ }
+ }
+}