From 704eb85afae9bf8454fdc3eecb0b37e7cfe3e692 Mon Sep 17 00:00:00 2001 From: v0lt Date: Thu, 12 Sep 2024 07:07:11 +0300 Subject: [PATCH] =?UTF-8?q?DSUtil:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F?= =?UTF-8?q?=20GetCanonicalizeFilePath.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DSUtil/FileHandle.cpp | 15 +++++++++++++++ src/DSUtil/FileHandle.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/DSUtil/FileHandle.cpp b/src/DSUtil/FileHandle.cpp index cf266d48e..d1e0c3cb0 100644 --- a/src/DSUtil/FileHandle.cpp +++ b/src/DSUtil/FileHandle.cpp @@ -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 // diff --git a/src/DSUtil/FileHandle.h b/src/DSUtil/FileHandle.h index ce2be776b..d93d5ddc0 100644 --- a/src/DSUtil/FileHandle.h +++ b/src/DSUtil/FileHandle.h @@ -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);