Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2009-06-02 04:00:00 +0400
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:59 +0300
commit829409452d85cd6dd9dfc9151f109d6e13a2bb1c (patch)
treee0acaea47044d167f35fa197584dee1bde41c329 /CPP/7zip/Common/FilePathAutoRename.cpp
parent8874e4fbc9faabdcff719b9b2ac8ebad4f282bbe (diff)
9.04 beta
Diffstat (limited to 'CPP/7zip/Common/FilePathAutoRename.cpp')
-rwxr-xr-xCPP/7zip/Common/FilePathAutoRename.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/CPP/7zip/Common/FilePathAutoRename.cpp b/CPP/7zip/Common/FilePathAutoRename.cpp
index bf69fc79..7d6e36f1 100755
--- a/CPP/7zip/Common/FilePathAutoRename.cpp
+++ b/CPP/7zip/Common/FilePathAutoRename.cpp
@@ -1,25 +1,25 @@
// FilePathAutoRename.cpp
#include "StdAfx.h"
-#include "FilePathAutoRename.h"
#include "Common/Defs.h"
#include "Common/IntToString.h"
-#include "Windows/FileName.h"
#include "Windows/FileFind.h"
+#include "FilePathAutoRename.h"
+
using namespace NWindows;
static bool MakeAutoName(const UString &name,
- const UString &extension, int value, UString &path)
+ const UString &extension, unsigned value, UString &path)
{
- wchar_t number[32];
- ConvertUInt64ToString(value, number);
+ wchar_t number[16];
+ ConvertUInt32ToString(value, number);
path = name;
path += number;
path += extension;
- return NFile::NFind::DoesFileExist(path);
+ return NFile::NFind::DoesFileOrDirExist(path);
}
bool AutoRenamePath(UString &fullProcessedPath)
@@ -34,7 +34,7 @@ bool AutoRenamePath(UString &fullProcessedPath)
#endif
UString name, extension;
- if (dotPos > slashPos && dotPos > 0)
+ if (dotPos > slashPos && dotPos > 0)
{
name = fullProcessedPath.Left(dotPos);
extension = fullProcessedPath.Mid(dotPos);
@@ -42,16 +42,14 @@ bool AutoRenamePath(UString &fullProcessedPath)
else
name = fullProcessedPath;
name += L'_';
- int indexLeft = 1, indexRight = (1 << 30);
- while (indexLeft != indexRight)
+ unsigned left = 1, right = (1 << 30);
+ while (left != right)
{
- int indexMid = (indexLeft + indexRight) / 2;
- if (MakeAutoName(name, extension, indexMid, path))
- indexLeft = indexMid + 1;
+ unsigned mid = (left + right) / 2;
+ if (MakeAutoName(name, extension, mid, path))
+ left = mid + 1;
else
- indexRight = indexMid;
+ right = mid;
}
- if (MakeAutoName(name, extension, indexRight, fullProcessedPath))
- return false;
- return true;
+ return !MakeAutoName(name, extension, right, fullProcessedPath);
}