mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
130 lines
6.9 KiB
C
130 lines
6.9 KiB
C
// encoding: UTF-8
|
|
/******************************************************************************
|
|
* *
|
|
* *
|
|
* Notepad3 *
|
|
* *
|
|
* PathLib.h *
|
|
* Definition for dynamic wide char Long Path handling *
|
|
* Based on DynStrg module *
|
|
* *
|
|
* (c) Rizonesoft 2021 *
|
|
* https://rizonesoft.com *
|
|
* *
|
|
* *
|
|
*******************************************************************************/
|
|
#pragma once
|
|
|
|
// comment out PATHCCH_NO_DEPRECATE to show deprecated API
|
|
#define PATHCCH_NO_DEPRECATE 1
|
|
///#include <pathcch.h>
|
|
|
|
#include "TypeDefs.h"
|
|
#include "DynStrg.h"
|
|
|
|
#define PTHAPI __stdcall
|
|
|
|
// PATHCCH_MAX_CCH: (0x7FFF + 1 for NULL terminator)
|
|
#define PATHLONG_MAX_CCH 0x8000
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// ----------------------------------------------------------------------------
|
|
|
|
__forceinline bool IsReadOnly(const DWORD dwFileAttr)
|
|
{
|
|
return ((dwFileAttr != INVALID_FILE_ATTRIBUTES) && (dwFileAttr & FILE_ATTRIBUTE_READONLY));
|
|
}
|
|
|
|
__forceinline bool IsExistingFile(const DWORD dwFileAttr)
|
|
{
|
|
return ((dwFileAttr != INVALID_FILE_ATTRIBUTES) && !(dwFileAttr & FILE_ATTRIBUTE_DIRECTORY));
|
|
}
|
|
|
|
__forceinline bool IsExistingDirectory(const DWORD dwFileAttr)
|
|
{
|
|
return ((dwFileAttr != INVALID_FILE_ATTRIBUTES) && (dwFileAttr & FILE_ATTRIBUTE_DIRECTORY));
|
|
}
|
|
|
|
/**************************************************/
|
|
/* */
|
|
/* DYNAMIC WIDCHAR LONG PATH */
|
|
/* */
|
|
/**************************************************/
|
|
|
|
HPATHL PTHAPI Path_Allocate(const wchar_t* path);
|
|
void PTHAPI Path_Release(HPATHL hstr);
|
|
void PTHAPI Path_Empty(HPATHL hpth, bool truncate);
|
|
int PTHAPI Path_Reset(HPATHL hpth, const wchar_t* path);
|
|
size_t PTHAPI Path_GetLength(HPATHL hpth);
|
|
HPATHL PTHAPI Path_Copy(const HPATHL hpth);
|
|
bool PTHAPI Path_Append(HPATHL hpth, const wchar_t* more);
|
|
void PTHAPI Path_Swap(HPATHL hpth1, HPATHL hpth2);
|
|
void PTHAPI Path_FreeExtra(HPATHL hpth_in_out, size_t keep_length);
|
|
|
|
bool PTHAPI Path_Canonicalize(HPATHL hpth_in_out);
|
|
bool PTHAPI Path_IsEmpty(const HPATHL hpth);
|
|
inline bool PTHAPI Path_IsNotEmpty(const HPATHL hpth) { return !Path_IsEmpty(hpth); };
|
|
bool PTHAPI Path_IsValidUNC(const HPATHL hpth);
|
|
bool PTHAPI Path_IsExistingDirectory(const HPATHL hpth);
|
|
|
|
int PTHAPI Path_StrgComparePath(const HPATHL hpth1, const HPATHL hpth2);
|
|
bool PTHAPI Path_RemoveBackslash(HPATHL hpth_in_out);
|
|
bool PTHAPI Path_RemoveFileSpec(HPATHL hpth_in_out);
|
|
bool PTHAPI Path_RenameExtension(HPATHL hpth, const wchar_t* ext);
|
|
void PTHAPI Path_ExpandEnvStrings(HPATHL hpth);
|
|
void PTHAPI Path_UnExpandEnvStrings(HPATHL hpth);
|
|
void PTHAPI Path_GetModuleFilePath(HPATHL hpth_out);
|
|
void PTHAPI Path_GetAppDirectory(HPATHL hpth_out);
|
|
bool PTHAPI Path_IsRelative(const HPATHL hpath);
|
|
bool PTHAPI Path_IsPrefix(const HPATHL hprefix, const HPATHL hpth);
|
|
size_t PTHAPI Path_CommonPrefix(const HPATHL hpth1, const HPATHL hpth2, HPATHL hpfx_out);
|
|
const wchar_t* PTHAPI Path_FindFileName(const HPATHL hpth);
|
|
const wchar_t* PTHAPI Path_FindExtension(const HPATHL hpth);
|
|
bool PTHAPI Path_QuoteSpaces(HPATHL hpth_in_out, bool bForceQuotes);
|
|
int PTHAPI Path_GetDriveNumber(const HPATHL hpth);
|
|
wchar_t PTHAPI Path_GetDriveLetterByNumber(const int number);
|
|
DWORD PTHAPI Path_GetFileAttributes(const HPATHL hpth);
|
|
bool PTHAPI Path_SetFileAttributes(HPATHL hpth, DWORD dwAttributes);
|
|
bool PTHAPI Path_GetCurrentDirectory(HPATHL hpth_out);
|
|
size_t PTHAPI Path_ToShortPathName(HPATHL hpth_in_out);
|
|
size_t PTHAPI Path_GetLongPathNameEx(HPATHL hpth_in_out);
|
|
|
|
void PTHAPI Path_GetDisplayName(LPWSTR lpszDisplayName, const DWORD cchDisplayName, const HPATHL hpth, LPCWSTR repl);
|
|
bool PTHAPI Path_GetLnkPath(const HPATHL hLnkFilePth, HPATHL hResPath_out);
|
|
bool PTHAPI Path_IsLnkFile(const HPATHL hpth);
|
|
bool PTHAPI Path_IsLnkToDirectory(const HPATHL hlnk_pth, HPATHL hpth_out);
|
|
bool PTHAPI Path_CreateFavLnk(LPCWSTR lpszDisplayName, const HPATHL hTargetPth, const HPATHL hDirPth);
|
|
bool PTHAPI Path_CreateDeskLnk(const HPATHL hDocumentPath, LPCWSTR pszDescription);
|
|
bool PTHAPI Path_BrowseDirectory(HWND hwndParent, LPCWSTR lpszTitle, HPATHL hpth_in_out, const HPATHL hbase, bool bNewDialogStyle);
|
|
bool PTHAPI Path_CanonicalizeEx(HPATHL hpth_in_out);
|
|
size_t PTHAPI Path_NormalizeEx(HPATHL hpth_in_out, const HPATHL hpth_wrkdir, bool bRealPath, bool bSearchPathIfRelative);
|
|
bool PTHAPI Path_RelativePathTo(HPATHL hrecv, const HPATHL hfrom, DWORD attr_from, const HPATHL hto, DWORD attr_to);
|
|
void PTHAPI Path_RelativeToApp(HPATHL hpth_in_out, bool bSrcIsFile, bool bUnexpandEnv, bool bUnexpandMyDocs);
|
|
bool PTHAPI Path_GetKnownFolder(REFKNOWNFOLDERID rfid, HPATHL hpth_out);
|
|
|
|
void PTHAPI ExpandEnvironmentStrgs(HSTRINGW hstr);
|
|
void PTHAPI Path_ExpandEnvironmentStrings(HPATHL hpth_in_out);
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// try to minimize use of:
|
|
// ----------------------------------------------------------------------------
|
|
const wchar_t* PTHAPI Path_Get(HPATHL hpth);
|
|
size_t PTHAPI Path_GetBufCount(HPATHL hpth);
|
|
wchar_t* PTHAPI Path_WriteAccessBuf(HPATHL hpth, size_t len);
|
|
void PTHAPI Path_Sanitize(HPATHL hpth);
|
|
|
|
|
|
// ============================================================================
|
|
// Duplicates for INTERMEDIATE DEV
|
|
// ============================================================================
|
|
|
|
bool PTHAPI Path_IsExistingFile(const HPATHL hpth);
|
|
bool PTHAPI PathIsExistingFile(LPCWSTR pszPath);
|
|
|
|
void PTHAPI Path_AbsoluteFromApp(HPATHL hpth_in_out, bool bExpandEnv);
|
|
void PTHAPI PathAbsoluteFromApp(LPWSTR lpszPath, const size_t cchPath, bool bExpandEnv);
|
|
|
|
// ============================================================================
|
|
// ============================================================================
|
|
|