summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/lzma/CPP/7zip/UI/Common/ArchiveName.cpp
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2015-01-11 08:10:25 +0100
committer Miodrag Milanovic <mmicko@gmail.com>2015-01-11 08:10:25 +0100
commit6a23c2f3b766cf4fc7028628f76b5ff9396383f0 (patch)
treea01e16637118ae0c80f337119898bdf18f081e24 /3rdparty/lzma/CPP/7zip/UI/Common/ArchiveName.cpp
parent45ac9b351e0076c371de4c7453f59567b27b1cb6 (diff)
Added full lzma sdk source (nw)
Diffstat (limited to '3rdparty/lzma/CPP/7zip/UI/Common/ArchiveName.cpp')
-rw-r--r--3rdparty/lzma/CPP/7zip/UI/Common/ArchiveName.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/3rdparty/lzma/CPP/7zip/UI/Common/ArchiveName.cpp b/3rdparty/lzma/CPP/7zip/UI/Common/ArchiveName.cpp
new file mode 100644
index 00000000000..17947dcef43
--- /dev/null
+++ b/3rdparty/lzma/CPP/7zip/UI/Common/ArchiveName.cpp
@@ -0,0 +1,54 @@
+// ArchiveName.cpp
+
+#include "StdAfx.h"
+
+#include "Windows/FileDir.h"
+#include "Windows/FileFind.h"
+
+#include "ExtractingFilePath.h"
+
+using namespace NWindows;
+
+static FString CreateArchiveName2(const FString &srcName, bool fromPrev, bool keepName)
+{
+ FString resultName = FTEXT("Archive");
+ if (fromPrev)
+ {
+ FString dirPrefix;
+ if (NFile::NDirectory::GetOnlyDirPrefix(srcName, dirPrefix))
+ {
+ if (dirPrefix.Length() > 0)
+ if (dirPrefix.Back() == FCHAR_PATH_SEPARATOR)
+ {
+ dirPrefix.DeleteBack();
+ NFile::NFind::CFileInfo fileInfo;
+ if (fileInfo.Find(dirPrefix))
+ resultName = fileInfo.Name;
+ }
+ }
+ }
+ else
+ {
+ NFile::NFind::CFileInfo fileInfo;
+ if (!fileInfo.Find(srcName))
+ // return resultName;
+ return srcName;
+ resultName = fileInfo.Name;
+ if (!fileInfo.IsDir() && !keepName)
+ {
+ int dotPos = resultName.ReverseFind('.');
+ if (dotPos > 0)
+ {
+ FString archiveName2 = resultName.Left(dotPos);
+ if (archiveName2.ReverseFind(FTEXT('.')) < 0)
+ resultName = archiveName2;
+ }
+ }
+ }
+ return resultName;
+}
+
+UString CreateArchiveName(const UString &srcName, bool fromPrev, bool keepName)
+{
+ return GetCorrectFsPath(fs2us(CreateArchiveName2(us2fs(srcName), fromPrev, keepName)));
+}