This commit is contained in:
Igor Pavlov
2015-06-15 00:00:00 +00:00
committed by Kornel Lesiński
parent 0713a3ab80
commit 54490d51d5
591 changed files with 34932 additions and 16390 deletions

View File

@@ -3,68 +3,76 @@
#include "StdAfx.h"
#include "../../../Windows/FileDir.h"
#include "../../../Windows/FileName.h"
#include "ExtractingFilePath.h"
#include "ArchiveName.h"
using namespace NWindows;
using namespace NFile;
UString CreateArchiveName(const NFile::NFind::CFileInfo fileInfo, bool keepName)
UString CreateArchiveName(const NFind::CFileInfo &fi, bool keepName)
{
FString resultName = fileInfo.Name;
if (!fileInfo.IsDir() && !keepName)
FString resultName = fi.Name;
if (!fi.IsDir() && !keepName)
{
int dotPos = resultName.ReverseFind(FTEXT('.'));
int dotPos = resultName.ReverseFind_Dot();
if (dotPos > 0)
{
FString archiveName2 = resultName.Left(dotPos);
if (archiveName2.ReverseFind(FTEXT('.')) < 0)
if (archiveName2.ReverseFind_Dot() < 0)
resultName = archiveName2;
}
}
return GetCorrectFsPath(fs2us(resultName));
return Get_Correct_FsFile_Name(fs2us(resultName));
}
static FString CreateArchiveName2(const FString &srcName, bool fromPrev, bool keepName)
static FString CreateArchiveName2(const FString &path, bool fromPrev, bool keepName)
{
FString resultName = FTEXT("Archive");
if (fromPrev)
{
FString dirPrefix;
if (NFile::NDir::GetOnlyDirPrefix(srcName, dirPrefix))
if (NDir::GetOnlyDirPrefix(path, dirPrefix))
{
if (dirPrefix.Len() > 0)
if (dirPrefix.Back() == FCHAR_PATH_SEPARATOR)
if (!dirPrefix.IsEmpty() && IsPathSepar(dirPrefix.Back()))
{
#if defined(_WIN32) && !defined(UNDER_CE)
if (NName::IsDriveRootPath_SuperAllowed(dirPrefix))
resultName = dirPrefix[dirPrefix.Len() - 3]; // only letter
else
#endif
{
dirPrefix.DeleteBack();
NFile::NFind::CFileInfo fileInfo;
if (fileInfo.Find(dirPrefix))
resultName = fileInfo.Name;
NFind::CFileInfo fi;
if (fi.Find(dirPrefix))
resultName = fi.Name;
}
}
}
}
else
{
NFile::NFind::CFileInfo fileInfo;
if (!fileInfo.Find(srcName))
// return resultName;
return srcName;
resultName = fileInfo.Name;
if (!fileInfo.IsDir() && !keepName)
NFind::CFileInfo fi;
if (fi.Find(path))
{
int dotPos = resultName.ReverseFind('.');
if (dotPos > 0)
resultName = fi.Name;
if (!fi.IsDir() && !keepName)
{
FString archiveName2 = resultName.Left(dotPos);
if (archiveName2.ReverseFind(FTEXT('.')) < 0)
resultName = archiveName2;
int dotPos = resultName.ReverseFind_Dot();
if (dotPos > 0)
{
FString name2 = resultName.Left(dotPos);
if (name2.ReverseFind_Dot() < 0)
resultName = name2;
}
}
}
}
return resultName;
}
UString CreateArchiveName(const UString &srcName, bool fromPrev, bool keepName)
UString CreateArchiveName(const UString &path, bool fromPrev, bool keepName)
{
return GetCorrectFsPath(fs2us(CreateArchiveName2(us2fs(srcName), fromPrev, keepName)));
return Get_Correct_FsFile_Name(fs2us(CreateArchiveName2(us2fs(path), fromPrev, keepName)));
}