#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2023 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_SUPPORT_PLATFORM_WINDOWSPATHAPI_H #define NUCLEX_SUPPORT_PLATFORM_WINDOWSPATHAPI_H #include "Nuclex/Support/Config.h" #if defined(NUCLEX_SUPPORT_WINDOWS) #include "WindowsApi.h" namespace Nuclex { namespace Support { namespace Platform { // ------------------------------------------------------------------------------------------- // /// Wraps the Windows path API class WindowsPathApi { /// Checks if the specified path is a relative path /// Path that will be checked /// True if the path is a relative path public: static bool IsPathRelative(const std::wstring &path); /// Appends one path to another /// Path to which another path will be appended /// Other path that will be appended public: static void AppendPath(std::wstring &path, const std::wstring &extra); /// Removes the file name from a path containing a file name /// Path from which the file name will be removed public: static void RemoveFileFromPath(std::wstring &path); /// Checks whether the specified path has a filename extension /// Path that will be checked for having an extension /// True if the path has a filename extension, false otherwise public: static bool HasExtension(const std::wstring &path); /// Checks if the specified path exists and if it is a file /// Path that will be checked /// True if the path exists and is a file, false otherwise public: static bool DoesFileExist(const std::wstring &path); /// Discovers the Windows system directory /// /// String in which the full path to the Windows system directory will be placed /// public: static void GetSystemDirectory(std::wstring &target); /// Discovers the Windows directory /// /// String in which the full path to the Windows directory will be placed /// public: static void GetWindowsDirectory(std::wstring &target); /// Determines the path of the user's temporary directory /// /// String in which the full path of the temporary directory will be placed /// public: static void GetTemporaryDirectory(std::wstring &target); /// Creates a temporary file with a unique name on Windows systems /// Prefix for the temporary filename, can be empty /// The full path to the newly created temporary file public: static std::wstring CreateTemporaryFile(const std::string &prefix); /// Creates a new directory in the specified location /// Path in which the new directory will be created public: static void CreateDirectory(const std::wstring &path); #if defined(NUCLEX_SUPPORT_EMULATE_SHLWAPI) /// Removes the filename from a full path /// Path from which the filename will be removed /// TRUE if the filename was removed, FALSE if nothing was removed /// /// This is a reimplementation of the same-named method from Microsoft's shlwapi, /// done so we don't have to link shlwapi for three measly methods. /// public: static BOOL PathRemoveFileSpecW(LPWSTR pszPath); /// Checks whether a path is relative /// Path that will be checked for being relative /// TRUE if the path is relative, FALSE if it is absolute /// /// This is a reimplementation of the same-named method from Microsoft's shlwapi, /// done so we don't have to link shlwapi for three measly methods. /// public: static BOOL PathIsRelativeW(LPCWSTR pszPath); /// Appends a directory or filename to an existing path /// Path to which the other path will be appended /// Other path that will be appended to the first path /// TRUE if the path is relative, FALSE if it is absolute /// /// This is a reimplementation of the same-named method from Microsoft's shlwapi, /// done so we don't have to link shlwapi for three measly methods. /// Unlike the original, this can destroy pszPath if it starts with dots ('.') /// and the combined path does not fit in the buffer. This library does not /// encounter that case, but if you want to rip this code, you should be aware :) /// BOOL PathAppendW(LPWSTR pszPath, LPCWSTR pszMore); #endif // defined(NUCLEX_SUPPORT_EMULATE_SHLWAPI) }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Support::Platform #endif // defined(NUCLEX_SUPPORT_WINDOWS) #endif // NUCLEX_SUPPORT_PLATFORM_WINDOWSPATHAPI_H