aboutsummaryrefslogtreecommitdiff
path: root/dep/CascLib/src/CascOpenStorage.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2016-12-05 17:41:27 +0100
committerShauren <shauren.trinity@gmail.com>2016-12-05 17:41:27 +0100
commitc856a058b50e9f9844a4eb4b63e3786de69e6678 (patch)
treea24d90a382882fdaeb563e99a34b9b0c11f901d6 /dep/CascLib/src/CascOpenStorage.cpp
parentfcbbeb3644c2f19f6c074871e1cb47c7fb8876c0 (diff)
Dep: Update CascLib to ladislav-zezula/CascLib@e2fc95cdb15d03eb1e4c86b1161df82d5b92eff9
Diffstat (limited to 'dep/CascLib/src/CascOpenStorage.cpp')
-rw-r--r--dep/CascLib/src/CascOpenStorage.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/dep/CascLib/src/CascOpenStorage.cpp b/dep/CascLib/src/CascOpenStorage.cpp
index 4883e83283e..398dfb62960 100644
--- a/dep/CascLib/src/CascOpenStorage.cpp
+++ b/dep/CascLib/src/CascOpenStorage.cpp
@@ -166,13 +166,26 @@ static bool CutLastPathPart(TCHAR * szWorkPath)
{
size_t nLength = _tcslen(szWorkPath);
- for(nLength = _tcslen(szWorkPath); nLength > 0; nLength--)
+ // Go one character back
+ if(nLength > 0)
+ nLength--;
+
+ // Cut ending (back)slashes, if any
+ while(nLength > 0 && (szWorkPath[nLength] == _T('\\') || szWorkPath[nLength] == _T('/')))
+ nLength--;
+
+ // Cut the last path part
+ while(nLength > 0)
{
- if(szWorkPath[nLength] == '\\' || szWorkPath[nLength] == '/')
+ // End of path?
+ if(szWorkPath[nLength] == _T('\\') || szWorkPath[nLength] == _T('/'))
{
szWorkPath[nLength] = 0;
return true;
}
+
+ // Go one character back
+ nLength--;
}
return false;