From c856a058b50e9f9844a4eb4b63e3786de69e6678 Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 5 Dec 2016 17:41:27 +0100 Subject: Dep: Update CascLib to ladislav-zezula/CascLib@e2fc95cdb15d03eb1e4c86b1161df82d5b92eff9 --- dep/CascLib/src/CascOpenStorage.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'dep/CascLib/src/CascOpenStorage.cpp') 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; -- cgit v1.2.3