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>2010-11-11 03:00:00 +0300
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:16:04 +0300
commitb75af1bba61529be6787dc470f9db60906a182e5 (patch)
tree9e0ffa6bd9ed8ac72856630225cfe07cbc63cede /CPP/Windows
parentc65230d8585317f7cd58ae2982067385269fdee9 (diff)
9.199.19
Diffstat (limited to 'CPP/Windows')
-rwxr-xr-xCPP/Windows/FileDir.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/CPP/Windows/FileDir.cpp b/CPP/Windows/FileDir.cpp
index 81fcd6ef..85794603 100755
--- a/CPP/Windows/FileDir.cpp
+++ b/CPP/Windows/FileDir.cpp
@@ -474,7 +474,7 @@ bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath, int &fileNamePartS
{
resultPath = fileName;
// change it
- fileNamePartStartIndex = resultPath.ReverseFind('\\');
+ fileNamePartStartIndex = resultPath.ReverseFind(WCHAR_PATH_SEPARATOR);
fileNamePartStartIndex++;
return true;
}
@@ -488,6 +488,38 @@ bool MyGetShortPathName(LPCTSTR longPath, CSysString &shortPath)
return (needLength > 0 && needLength < MAX_PATH);
}
+#ifdef WIN_LONG_PATH
+
+static UString GetLastPart(LPCWSTR path)
+{
+ int i = (int)wcslen(path);
+ for (; i > 0; i--)
+ {
+ WCHAR c = path[i - 1];
+ if (c == WCHAR_PATH_SEPARATOR || c == '/')
+ break;
+ }
+ return path + i;
+}
+
+static void AddTrailingDots(LPCWSTR oldPath, UString &newPath)
+{
+ int len = (int)wcslen(oldPath);
+ int i;
+ for (i = len; i > 0 && oldPath[i - 1] == '.'; i--);
+ if (i == 0 || i == len)
+ return;
+ UString oldName = GetLastPart(oldPath);
+ UString newName = GetLastPart(newPath);
+ int nonDotsLen = oldName.Length() - (len - i);
+ if (nonDotsLen == 0 || newName.CompareNoCase(oldName.Left(nonDotsLen)) != 0)
+ return;
+ for (; i != len; i++)
+ newPath += '.';
+}
+
+#endif
+
bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath, int &fileNamePartStartIndex)
{
resultPath.Empty();
@@ -512,6 +544,11 @@ bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath, int &fileNamePa
fileNamePartStartIndex = lstrlen(fileName);
else
fileNamePartStartIndex = (int)(fileNamePointer - buffer);
+ #ifdef _UNICODE
+ #ifdef WIN_LONG_PATH
+ AddTrailingDots(fileName, resultPath);
+ #endif
+ #endif
return true;
}
@@ -542,6 +579,9 @@ bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath, int &fileNamePartS
fileNamePartStartIndex = MyStringLen(fileName);
else
fileNamePartStartIndex = (int)(fileNamePointer - buffer);
+ #ifdef WIN_LONG_PATH
+ AddTrailingDots(fileName, resultPath);
+ #endif
}
else
{