Skip to content

Commit

Permalink
DSUtil: добавлена функция GetCanonicalizeFilePath.
Browse files Browse the repository at this point in the history
  • Loading branch information
v0lt committed Sep 12, 2024
1 parent 2b1a962 commit 704eb85
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/DSUtil/FileHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@ CStringW GetCombineFilePath(LPCWSTR dir, LPCWSTR file)
return path;
}

CStringW GetCanonicalizeFilePath(LPCWSTR path)
{
CStringW newPath;
DWORD buflen = ::GetFullPathNameW(path, 0, nullptr, nullptr);
if (buflen > 0) {
DWORD len = ::GetFullPathNameW(path, buflen, newPath.GetBuffer(buflen - 1), nullptr);
if (len > buflen) {
len = 0;
}
newPath.ReleaseBufferSetLength(len);
}

return newPath;
}

//
// Generate temporary files with any extension
//
Expand Down
2 changes: 2 additions & 0 deletions src/DSUtil/FileHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ CStringW AddExtension(LPCWSTR Path, LPCWSTR Ext);
void CombineFilePath(CStringW& path, LPCWSTR file);
CStringW GetCombineFilePath(LPCWSTR dir, LPCWSTR file);

CStringW GetCanonicalizeFilePath(LPCWSTR path);

BOOL GetTemporaryFilePath(CStringW strExtension, CStringW& strFileName);
CStringW CompactPath(LPCWSTR Path, UINT cchMax);

Expand Down

0 comments on commit 704eb85

Please sign in to comment.