OLD | NEW |
| (Empty) |
1 // ArchiveName.cpp | |
2 | |
3 #include "StdAfx.h" | |
4 | |
5 #include "Windows/FileFind.h" | |
6 #include "Windows/FileDir.h" | |
7 | |
8 using namespace NWindows; | |
9 | |
10 UString CreateArchiveName(const UString &srcName, bool fromPrev, bool keepName) | |
11 { | |
12 UString resultName = L"Archive"; | |
13 if (fromPrev) | |
14 { | |
15 UString dirPrefix; | |
16 if (NFile::NDirectory::GetOnlyDirPrefix(srcName, dirPrefix)) | |
17 { | |
18 if (dirPrefix.Length() > 0) | |
19 if (dirPrefix[dirPrefix.Length() - 1] == WCHAR_PATH_SEPARATOR) | |
20 { | |
21 dirPrefix.Delete(dirPrefix.Length() - 1); | |
22 NFile::NFind::CFileInfoW fileInfo; | |
23 if (NFile::NFind::FindFile(dirPrefix, fileInfo)) | |
24 resultName = fileInfo.Name; | |
25 } | |
26 } | |
27 } | |
28 else | |
29 { | |
30 NFile::NFind::CFileInfoW fileInfo; | |
31 if (!NFile::NFind::FindFile(srcName, fileInfo)) | |
32 return resultName; | |
33 resultName = fileInfo.Name; | |
34 if (!fileInfo.IsDir() && !keepName) | |
35 { | |
36 int dotPos = resultName.ReverseFind('.'); | |
37 if (dotPos > 0) | |
38 { | |
39 UString archiveName2 = resultName.Left(dotPos); | |
40 if (archiveName2.ReverseFind('.') < 0) | |
41 resultName = archiveName2; | |
42 } | |
43 } | |
44 } | |
45 return resultName; | |
46 } | |
OLD | NEW |