blob: 17947dcef43d5648e35e5a7d3c77188acd02993a (
plain) (
blame)
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
|
// 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)));
}
|