Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray::cFilePath Class Reference

#include <cFilePath.h>

Inheritance diagram for Gray::cFilePath:
Gray::cStringT< FILECHAR_t > Gray::CStringT< _TYPE_CH >

Static Public Member Functions

static constexpr bool IsCharDirSep (wchar_t ch) noexcept
 
static constexpr bool IsCharWildcard (wchar_t ch) noexcept
 
static FILECHR_TYPE_ __stdcall GetFileCharType (wchar_t ch, FILESYS_TYPE eSys=FILESYS_DEFAULT)
 
static bool __stdcall IsFileNameValid (const FILECHAR_t *pszName, FILECHR_MASK_t uCharMask=FILECHR_All, FILESYS_TYPE eSys=FILESYS_DEFAULT)
 
static bool __stdcall IsFileNameExt (const FILECHAR_t *pszFileName, const FILECHAR_t *pszExt) noexcept
 
static bool __stdcall HasTitleWildcards (const FILECHAR_t *pszPath)
 
static FILECHAR_t *__stdcall GetFileNameExt (const FILECHAR_t *pszName, StrLen_t iLen=k_StrLen_UNK, bool bMultiDot=false)
 
static StrLen_t __stdcall StripFileExt (FILECHAR_t *pszFile, StrLen_t iLen, bool bMultiDot=false)
 
static cStringF __stdcall ReplaceFileExt (const FILECHAR_t *pszFilePath, const FILECHAR_t *pszExtNew)
 
static cStringF __stdcall GetNameExtStar (const FILECHAR_t *pszFilePath)
 
static FILECHAR_t *__stdcall GetFileName (const FILECHAR_t *pszPath, StrLen_t iLenPath=k_StrLen_UNK)
 
static cStringF __stdcall GetFileNameNE (const FILECHAR_t *pszPath, StrLen_t iLenPath=k_StrLen_UNK, bool bMultiDot=false)
 
static StrLen_t __stdcall MakeFileSymbolicName (ATOMCHAR_t *pszOut, const FILECHAR_t *pszPath, const ATOMCHAR_t *pszPrefix=nullptr, ATOMCHAR_t chSub='_', bool bAllowLeadingNumber=false)
 
static cStringA __stdcall GetFileSymbolicName (const FILECHAR_t *pszPath, const ATOMCHAR_t *pszPrefix=nullptr, ATOMCHAR_t chSub='_', bool bAllowLeadingNumber=false)
 
static StrLen_t __stdcall MakeFullPath2 (FILECHAR_t *pszFileOut, const FILECHAR_t *pszFileInp, StrLen_t iLenMax, FILECHAR_t chSep=k_DirSep)
 
static StrLen_t __stdcall MakeFullPath (FILECHAR_t *pszFileOut, const FILECHAR_t *pszFileInp, StrLen_t iLenMax, FILECHAR_t chSep=k_DirSep)
 
static cStringF __stdcall MakeFullPathX (const FILECHAR_t *pszFileInp, FILECHAR_t chSep=k_DirSep)
 
static StrLen_t __stdcall MakeProperPath (FILECHAR_t *pszFileOut, StrLen_t iLenMax=260, const FILECHAR_t *pszFileInp=nullptr, FILECHAR_t chSep=k_DirSep)
 
static cStringF __stdcall MakeProperPathX (const FILECHAR_t *pszFileInp, FILECHAR_t chSep=k_DirSep)
 
static StrLen_t __stdcall AddFileDirSep (FILECHAR_t *pszOut, StrLen_t iLen=k_StrLen_UNK, FILECHAR_t chSep=k_DirSep)
 
static StrLen_t __stdcall CombineFilePathA (FILECHAR_t *pszOut, StrLen_t iLenMax, StrLen_t iLen, const FILECHAR_t *pszName, FILECHAR_t chSep=k_DirSep)
 
static StrLen_t __stdcall CombineFilePath (FILECHAR_t *pszFilePathOut, StrLen_t iLenMax, const FILECHAR_t *pszDir, const FILECHAR_t *pszName, FILECHAR_t chSep=k_DirSep)
 
static cStringF __stdcall CombineFilePathX (const FILECHAR_t *pszBase, const FILECHAR_t *pszName, FILECHAR_t chSep=k_DirSep)
 
static cStringF _cdecl CombineFilePathF (FILECHAR_t chSep, const FILECHAR_t *pszBase,...)
 
static StrLen_t __stdcall ExtractDir (FILECHAR_t *pszPath, StrLen_t iLen=k_StrLen_UNK, bool bTrailingSep=true)
 
static StrLen_t __stdcall ExtractDirCopy (FILECHAR_t *pszDirPath, StrLen_t iLenMax, const FILECHAR_t *pszFilePathSrc, bool bTrailingSep=true)
 
static cStringF __stdcall GetFileDir (const FILECHAR_t *pszFilePath, bool bTrailingSep=true)
 
static bool __stdcall IsRelativeRoot (const FILECHAR_t *pszFullPath, const FILECHAR_t *pszRootDir, StrLen_t iLen=k_StrLen_UNK)
 
static bool __stdcall IsRelativePath (const FILECHAR_t *pszFullPath, const FILECHAR_t *pszRelativePath)
 
static cStringF __stdcall MakeRelativePath (const FILECHAR_t *pszFullPath, const FILECHAR_t *pszRootDir)
 
static StrLen_t __stdcall GetFilePathDeviceLen (const FILECHAR_t *pszNameRoot)
 
static bool __stdcall IsFileDeviceRemote (const FILECHAR_t *pszPath)
 
static bool __stdcall IsFilePathRooted (const FILECHAR_t *pszName)
 
static bool __stdcall IsFilePathRoot (const FILECHAR_t *pszName)
 
static bool __stdcall IsFilePathTitle (const FILECHAR_t *pszName)
 
static bool __stdcall HasFilePathRelatives (const FILECHAR_t *pszName, bool bOrDevices=true)
 
static FILECHAR_t *__stdcall SkipRelativePrefix (const FILECHAR_t *pszName)
 
static FILECHAR_t *__stdcall GetFilePathUpDir2 (const FILECHAR_t *pszName, StrLen_t iLen=k_StrLen_UNK, int iQtyDirs=1)
 
static cStringF __stdcall GetFilePathUpDir1 (const FILECHAR_t *pszName, StrLen_t iLen=k_StrLen_UNK, int iQtyDirs=1)
 
static bool __stdcall MakeFilePathUpDir (FILECHAR_t *pszName)
 
static COMPARE_t __stdcall ComparePath (const FILECHAR_t *pszPath1, const FILECHAR_t *pszPath2, StrLen_t iLenMax=260)
 
- Static Public Member Functions inherited from Gray::cStringT< FILECHAR_t >
static THIS_t _cdecl GetFormatf (const FILECHAR_t *pszFormat,...)
 
static THIS_t __stdcall GetErrorStringV (HRESULT nFormatID, void *pSource, va_list vargs)
 
static THIS_t __stdcall GetErrorString (HRESULT nFormatID, void *pSource=nullptr)
 
static THIS_t _cdecl GetErrorStringf (HRESULT nFormatID, void *pSource,...)
 
static THIS_t __stdcall GetSizeK (UINT64 uVal, UINT nKUnit=1024, bool bSpace=false)
 

Static Public Attributes

static const StrLen_t k_MaxLen = 260
 Use _MAX_PATH for max length of a file path. More...
 
static const FILECHAR_t k_DirSep1 = '/'
 preferred for linux NFS but allowed by _WIN32. More...
 
static const FILECHAR_t k_DirSep2 = '\\'
 preferred for _WIN32 but NOT allowed in linux. More...
 
static const FILECHAR_t k_DirSep = '/'
 preferred for linux NFS but allowed by _WIN32. More...
 
- Static Public Attributes inherited from Gray::cStringT< FILECHAR_t >
static const int npos
 

Friends

class cFilePathTests
 

Additional Inherited Members

- Public Types inherited from Gray::cStringT< FILECHAR_t >
typedef FILECHAR_t CharType_t
 ALA std::string::value_type. More...
 
- Public Member Functions inherited from Gray::cStringT< FILECHAR_t >
 cStringT () noexcept
 
 cStringT (SUPER_t &str) noexcept
 
 cStringT (const char *pszText)
 
 cStringT (const char *pszText, StrLen_t iLenMax)
 
 cStringT (const wchar_t *pwText)
 
 cStringT (const wchar_t *pwText, StrLen_t iLenMax)
 
const FILECHAR_tget_CPtr () const noexcept
 
bool isPrintableString () const
 
bool isValidString () const noexcept
 
bool isValidCheck () const noexcept
 
bool IsWhitespace () const
 
HRESULT ReadZ (cStreamInput &File, StrLen_t iLenMax)
 
bool WriteZ (cStreamOutput &File) const
 
HASHCODE_t get_HashCode () const noexcept
 
size_t GetHeapStats (OUT ITERATE_t &iAllocCount) const
 
int get_RefCount () const
 
void SetStringStatic ()
 
StrLen_t SetCodePage (const wchar_t *pwText, CODEPAGE_t uCodePage=CP_UTF8)
 
StrLen_t SetCodePage (const wchar_t *pwStr, CODEPAGE_t uCodePage)
 
StrLen_t SetCodePage (const wchar_t *pwStr, CODEPAGE_t uCodePage)
 
StrLen_t GetCodePage (OUT wchar_t *pwText, StrLen_t iLenMax, CODEPAGE_t uCodePage=CP_UTF8) const
 
StrLen_t GetCodePage (OUT wchar_t *pwText, StrLen_t iLenMax, CODEPAGE_t uCodePage) const
 
StrLen_t GetCodePage (OUT wchar_t *pwText, StrLen_t iLenMax, CODEPAGE_t uCodePage) const
 
THIS_t GetTrimWhitespace () const
 
HRESULT SerializeInput (cStreamInput &File, StrLen_t iLenMax=StrT::k_LEN_MAX)
 
HRESULT SerializeOutput (cStreamOutput &File) const
 
HRESULT SerializeOutput (cArchive &a) const
 
HRESULT Serialize (cArchive &a)
 
const THIS_toperator= (const THIS_t &s)
 
const THIS_toperator= (const char *pszStr)
 
const THIS_toperator= (const wchar_t *pwStr)
 
void SetErase ()
 
bool Contains (const FILECHAR_t *pSubStr)
 
bool ContainsI (const FILECHAR_t *pSubStr)
 
bool StartsWithI (const FILECHAR_t *pSubStr)
 
bool EndsWithI (const FILECHAR_t *pSubStr) const
 
const FILECHAR_tc_str () const
 
StrLen_t size () const
 
StrLen_t length () const
 
bool empty () const
 
StrLen_t find (FILECHAR_t ch) const
 
void assign (const FILECHAR_t *pszStr, StrLen_t iLenCat)
 
void append (const FILECHAR_t *pszStr, StrLen_t iLenCat)
 
void push_back (FILECHAR_t ch)
 
void resize (StrLen_t iSize)
 
void reserve (StrLen_t iSize)
 
THIS_t substr (StrLen_t nFirst, StrLen_t nCount=StrT::k_LEN_MAX) const
 
- Public Member Functions inherited from Gray::CStringT< _TYPE_CH >
 CStringT () noexcept
 
 CStringT (const wchar_t *pwText)
 
 CStringT (const wchar_t *pwText, StrLen_t iLenMax)
 
 CStringT (const char *pszStr)
 
 CStringT (const char *pszStr, StrLen_t iLenMax)
 
 CStringT (const THIS_t &ref) noexcept
 
 CStringT (THIS_t &&ref) noexcept
 
 ~CStringT ()
 
CStringDataGetData () const noexcept
 
const _TYPE_CH * GetString () const noexcept
 
bool isValidString () const noexcept
 
bool IsEmpty () const noexcept
 
StrLen_t GetLength () const noexcept
 
void Empty ()
 
const _TYPE_CH & ReferenceAt (StrLen_t nIndex) const
 
_TYPE_CH GetAt (StrLen_t nIndex) const
 
void SetAt (StrLen_t nIndex, _TYPE_CH ch)
 
_TYPE_CH * GetBuffer (StrLen_t iMinLength)
 
void ReleaseBuffer (StrLen_t nNewLength=k_StrLen_UNK)
 
const THIS_toperator= (const THIS_t &ref)
 
const THIS_toperator= (THIS_t &&ref)
 
void AssignLenT (const _TYPE_CH *pszStr, StrLen_t iLenMax)
 
void AssignLen (const char *pszStr, StrLen_t iSizeMax=StrT::k_LEN_MAX)
 
const THIS_toperator= (const char *pStr)
 
void AssignLen (const wchar_t *pwText, StrLen_t iSizeMax=StrT::k_LEN_MAX)
 
const THIS_toperator= (const wchar_t *pStr)
 
void FormatV (const _TYPE_CH *pszStr, va_list args)
 
void _cdecl Format (const _TYPE_CH *pszStr,...)
 
COMPARE_t Compare (const _TYPE_CH *pszStr) const
 
COMPARE_t CompareNoCase (const _TYPE_CH *pszStr) const
 
void MakeUpper ()
 
void MakeLower ()
 
THIS_t Left (StrLen_t nCount) const
 
THIS_t Right (StrLen_t nCount) const
 
THIS_t Mid (StrLen_t nFirst, StrLen_t nCount=StrT::k_LEN_MAX) const
 
void TrimRight ()
 
void TrimLeft ()
 
StrLen_t Find (_TYPE_CH ch, StrLen_t nPosStart=0) const
 
_TYPE_CH operator[] (StrLen_t nIndex) const
 
const _TYPE_CH & operator[] (StrLen_t nIndex)
 
 operator const _TYPE_CH * () const
 
StrLen_t Insert (StrLen_t nIndex, _TYPE_CH ch)
 
const THIS_toperator+= (_TYPE_CH ch)
 
StrLen_t Insert (StrLen_t nIndex, const _TYPE_CH *pszStr, StrLen_t iLenCat)
 
StrLen_t Insert (StrLen_t nIndex, const _TYPE_CH *pszStr)
 
const THIS_toperator+= (const _TYPE_CH *psz)
 
void Assign (const THIS_t &str)
 
void Assign (const wchar_t *pwText)
 
void Assign (const char *pszStr)
 
void AssignLen (const wchar_t *pwStr, StrLen_t iLenMax)
 
void AssignLen (const char *pszStr, StrLen_t iLenMax)
 
void Assign (const wchar_t *pwStr)
 
void Assign (const char *pszStr)
 
void AssignLen (const char *pszStr, StrLen_t iLenMax)
 
void AssignLen (const wchar_t *pwStr, StrLen_t iLenMax)
 
void Assign (const wchar_t *pwStr)
 
void Assign (const char *pszStr)
 
- Protected Member Functions inherited from Gray::CStringT< _TYPE_CH >
void Init () noexcept
 
void EmptyValid ()
 
void AssignFirst (const THIS_t &s) noexcept
 
void AllocBuffer (StrLen_t iStrLength)
 
void CopyBeforeWrite ()
 
const char m_Nil
 
const wchar_t m_Nil
 
- Protected Attributes inherited from Gray::CStringT< _TYPE_CH >
_TYPE_CH * m_pchData
 
- Static Protected Attributes inherited from Gray::CStringT< _TYPE_CH >
static const _TYPE_CH m_Nil
 

Detailed Description

File Name and Path manipulation helper functions. Manipulation of a files name parts such as found in FILECHR_TYPE_ similar to .NET System.IO.Path similar to linux libpath_utils

Note
use _MAX_PATH for max length of file path.

Member Function Documentation

◆ AddFileDirSep()

StrLen_t GRAYCALL Gray::cFilePath::AddFileDirSep ( FILECHAR_t pszOut,
StrLen_t  iLen = k_StrLen_UNK,
FILECHAR_t  chSep = k_DirSep 
)
static

Add the / or \ to the end to make this a directory. ASSUME pszOut >= _MAX_PATH Might be LINUX

Returns
Length

◆ CombineFilePath()

StrLen_t GRAYCALL Gray::cFilePath::CombineFilePath ( FILECHAR_t pszFilePathOut,
StrLen_t  iLenMax,
const FILECHAR_t pszDir,
const FILECHAR_t pszName,
FILECHAR_t  chSep = k_DirSep 
)
static

combine pszDir and pszName to make a single path. MakeProperPath. Similar to Shell PathAppend() .NET System.IO.Path.Combine

  • chSep = k_DirSep default.
    Returns
    length of full output string. pszOut = pszDir + k_DirSep + pszName
    Note
    Resolve all relativism's in MakeProperPath

◆ CombineFilePathA()

StrLen_t GRAYCALL Gray::cFilePath::CombineFilePathA ( FILECHAR_t pszOut,
StrLen_t  iLenMax,
StrLen_t  iLen,
const FILECHAR_t pszName,
FILECHAR_t  chSep = k_DirSep 
)
static

Append file/subdir pszName to existing pszOut path.

  • chSep = k_DirSep default.
    Returns
    New total Length

◆ CombineFilePathF()

cStringF _cdecl Gray::cFilePath::CombineFilePathF ( FILECHAR_t  chSep,
const FILECHAR_t pszBase,
  ... 
)
static

Combine a list of file name parts together. MUST be nullptr terminated list.

  • chSep = k_DirSep
  • pszBase = first entry in the list. nullptr terminated list.

◆ CombineFilePathX()

cStringF GRAYCALL Gray::cFilePath::CombineFilePathX ( const FILECHAR_t pszBase,
const FILECHAR_t pszName,
FILECHAR_t  chSep = k_DirSep 
)
static

Merge path and file name. MakeProperPath. Similar to Shell PathAppend() .NET System.IO.Path.Combine

  • chSep = k_DirSep default.

◆ ComparePath()

COMPARE_t GRAYCALL Gray::cFilePath::ComparePath ( const FILECHAR_t pszPath1,
const FILECHAR_t pszPath2,
StrLen_t  iLenMax = 260 
)
static
Note
Path may or may not be case sensitive!

Compare 2 paths. equate \ and //

Note
file Path/Name may or may not be case sensitive! Linux = sensitive , Windows/Dos = not case sensitive. Try to factor out relatives .. ? using MakeFullPath() and MakeProperPath ? try to equate devices ? C: == /Device/Disk001 ?
  • iLenMax=_MAX_PATH
Returns
0 = same. COMPARE_Equal

◆ ExtractDir()

StrLen_t GRAYCALL Gray::cFilePath::ExtractDir ( FILECHAR_t pszPath,
StrLen_t  iLen = k_StrLen_UNK,
bool  bTrailingSep = true 
)
static

Remove the file name from this and just leave the path. bTrailingSep = leave the trailing / opposite of GetFileName()

Returns
length of the new string.

◆ ExtractDirCopy()

StrLen_t GRAYCALL Gray::cFilePath::ExtractDirCopy ( FILECHAR_t pszDirPath,
StrLen_t  iLenMax,
const FILECHAR_t pszFilePathSrc,
bool  bTrailingSep = true 
)
static

Remove the file name from this and just leave the path. (was ExtractDir)

  • bTrailingSep = leave the trailing /
    Returns
    length of the new string.

◆ GetFileCharType()

FILECHR_TYPE_ GRAYCALL Gray::cFilePath::GetFileCharType ( wchar_t  ch,
FILESYS_TYPE  eSys = FILESYS_DEFAULT 
)
static

Is the char valid for a filename on FILECHR_TYPE_? The valid characters for a filename in DOS manual (DOS 5: page 72) Known Valid: A..Z 0..9 and k_pszAllowedDOS = "_ ^ $ ~ ! # % & - {} () @ ' `" Known Unvalid: "<>:"|" and "/\?*" Unknown: (I've seen used but should not be valid?) [] other chars from 128 to 255 may be valid but we may want to filter FILECHR_Name3 http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx http://en.wikipedia.org/wiki/Filename

◆ GetFileDir()

cStringF GRAYCALL Gray::cFilePath::GetFileDir ( const FILECHAR_t pszFilePath,
bool  bTrailingSep = true 
)
static

Extract the directory from a file path. include the trailing / k_DirSep if bTrailingSep is set.

  • bTrailingSep = leave the trailing /

◆ GetFileName()

FILECHAR_t *GRAYCALL Gray::cFilePath::GetFileName ( const FILECHAR_t pszPath,
StrLen_t  iLenPath = k_StrLen_UNK 
)
static

Get file name and ext. (not path or drive) (File title) using iLen we might back up to the directory under any other directory. similar to COMMDLG.H GetFileTitleA(const char*, char*, WORD)

◆ GetFileNameExt()

FILECHAR_t *GRAYCALL Gray::cFilePath::GetFileNameExt ( const FILECHAR_t pszName,
StrLen_t  iLen = k_StrLen_UNK,
bool  bMultiDot = false 
)
static

Get a pointer to the extension of the file.

Note
Includes the DOT !
  • iLen = the known string length of the file name. -1 = k_StrLen_UNK = find '\0' bMultiDot = ".xt.sdf.fff" is considered a single extension.
Returns
The pointer to the extension in this file name. Includes the DOT. nullptr = has no extension.

◆ GetFileNameNE()

cStringF GRAYCALL Gray::cFilePath::GetFileNameNE ( const FILECHAR_t pszPath,
StrLen_t  iLenPath = k_StrLen_UNK,
bool  bMultiDot = false 
)
static

Get the file name title with NO extension and NO path.

◆ GetFilePathDeviceLen()

StrLen_t GRAYCALL Gray::cFilePath::GetFilePathDeviceLen ( const FILECHAR_t pszNameRoot)
static

Skip the device info at the start of the path. have a device name in it ? e.g. "COM1:" or "C:" "file://", "http://"

◆ GetFilePathUpDir1()

cStringF GRAYCALL Gray::cFilePath::GetFilePathUpDir1 ( const FILECHAR_t pszName,
StrLen_t  iLen = k_StrLen_UNK,
int  iQtyDirs = 1 
)
static

Go up a single dir. My immediate parent.

  • iQtyDirs = -1 = for "sdf:/dir1/dir2/dir3/dir4" = "sdf:/dir1/dir2/dir3"

◆ GetFilePathUpDir2()

FILECHAR_t *GRAYCALL Gray::cFilePath::GetFilePathUpDir2 ( const FILECHAR_t pszName,
StrLen_t  iLen = k_StrLen_UNK,
int  iQtyDirs = 1 
)
static

go up this many folders if possible. iQtyDirs = 1 = the folder for "sdf:/dir1/dir2/dir3/dir4" = "/dir4" 2 = for "sdf:/dir1/dir2/dir3/dir4" = "/dir3/dir4" -1 = for "sdf:/dir1/dir2/dir3/dir4" = "/dir2/dir3/dir4" ASSUME: trailing \ is a separate directory. weird.

Returns
pointer to char after the DirSep or 0th. nullptr = cant go that far.

◆ GetFileSymbolicName()

cStringA GRAYCALL Gray::cFilePath::GetFileSymbolicName ( const FILECHAR_t pszPath,
const ATOMCHAR_t pszPrefix = nullptr,
ATOMCHAR_t  chSub = '_',
bool  bAllowLeadingNumber = false 
)
static

convert the file name into a useful symbolic name. (SYMNAME) remove the directory and extension name.

◆ GetNameExtStar()

cStringF GRAYCALL Gray::cFilePath::GetNameExtStar ( const FILECHAR_t pszFilePath)
static

Convert a name possibly with a full path to a name and extension wildcard. "dir/Name.ext"

Returns
"Name.*"

◆ HasFilePathRelatives()

bool GRAYCALL Gray::cFilePath::HasFilePathRelatives ( const FILECHAR_t pszName,
bool  bOrDevices = true 
)
static

Does the file have any relative components. like .. Get rid of them with MakeProperPath()

◆ HasTitleWildcards()

bool GRAYCALL Gray::cFilePath::HasTitleWildcards ( const FILECHAR_t pszPath)
static

Any wildcards ?* in this title ? Use StrT::MatchRegEx and cFileDir to evaluate these.

◆ IsCharDirSep()

static constexpr bool Gray::cFilePath::IsCharDirSep ( wchar_t  ch)
inlinestaticconstexprnoexcept

FAT honors backslash. NTFS honors both chars. NFS uses just the forward slash. FILECHR_Dirs, like MFC IsDirSep()

◆ IsCharWildcard()

static constexpr bool Gray::cFilePath::IsCharWildcard ( wchar_t  ch)
inlinestaticconstexprnoexcept

FILECHR_Wildcard

◆ IsFileDeviceRemote()

bool GRAYCALL Gray::cFilePath::IsFileDeviceRemote ( const FILECHAR_t pszPath)
static

Is the file based on some remote device/service? e.g. HTTP, HTTPS, FTP, RTP, RTMP etc. GetFilePathDeviceLen like NETSERVICE_TYPE

◆ IsFileNameExt()

bool GRAYCALL Gray::cFilePath::IsFileNameExt ( const FILECHAR_t pszFileName,
const FILECHAR_t pszExt 
)
staticnoexcept

Is this the extension for the file name ? with or without dot.

◆ IsFileNameValid()

bool GRAYCALL Gray::cFilePath::IsFileNameValid ( const FILECHAR_t pszName,
FILECHR_MASK_t  uCharMask = FILECHR_All,
FILESYS_TYPE  eSys = FILESYS_DEFAULT 
)
static

Is this a valid file name? Maybe UTF8. Do not end a file or directory name with a space or a period.

  • eSys = FILESYS_FAT = enforce the DOS 8.3 rules.
    Note
    CANNOT have names the same as system devices. e.g. CLOCK$ CON PRN AUX NUL COM# LPT#. Check for those here ?

◆ IsFilePathRoot()

bool GRAYCALL Gray::cFilePath::IsFilePathRoot ( const FILECHAR_t pszName)
static

is this the root of a device?

Note
Includes the DOT ! e.g. "C:\" is true

◆ IsFilePathRooted()

bool GRAYCALL Gray::cFilePath::IsFilePathRooted ( const FILECHAR_t pszName)
static

Is the file path absolute ? (not relative path to current directory for process) Based on drive, device or root ? not have .. in it. If relative path then use MakeFullPathX() to get full rooted path. e.g. "COM1:" is true! "C:\" is true.

◆ IsFilePathTitle()

bool GRAYCALL Gray::cFilePath::IsFilePathTitle ( const FILECHAR_t pszName)
static

Does this NOT have path/dir indicators?

◆ IsRelativePath()

bool GRAYCALL Gray::cFilePath::IsRelativePath ( const FILECHAR_t pszFullPath,
const FILECHAR_t pszRelativePath 
)
static

a reverse compare of 2 paths. is pszRelativePath the same as pszFullPath assuming a root. e.g. pszFullPath="a\b\c", pszRelativePath="b\c" = true

◆ IsRelativeRoot()

bool GRAYCALL Gray::cFilePath::IsRelativeRoot ( const FILECHAR_t pszFullPath,
const FILECHAR_t pszRootDir,
StrLen_t  iLen = k_StrLen_UNK 
)
static

is the pszRootDir inside pszFullPath? e.g. pszFullPath="a\b\c", pszRootDir="a" = true

◆ MakeFilePathUpDir()

bool GRAYCALL Gray::cFilePath::MakeFilePathUpDir ( FILECHAR_t pszName)
static

Get the file path if the file were up one directory. in its parent dir. Like using ExtractDir()

◆ MakeFileSymbolicName()

StrLen_t GRAYCALL Gray::cFilePath::MakeFileSymbolicName ( ATOMCHAR_t pszOut,
const FILECHAR_t pszPath,
const ATOMCHAR_t pszPrefix = nullptr,
ATOMCHAR_t  chSub = '_',
bool  bAllowLeadingNumber = false 
)
static

make a symbolic name from a file name. replace directory separators with _ chSub

Note
pszPrefix = nullptr is allowed. Limit pszOut to StrT::k_LEN_MAX_KEY
Returns
length of the string.

◆ MakeFullPath()

StrLen_t GRAYCALL Gray::cFilePath::MakeFullPath ( FILECHAR_t pszFileOut,
const FILECHAR_t pszFileInp,
StrLen_t  iLenMax,
FILECHAR_t  chSep = k_DirSep 
)
static

If this is a relative path (to app current dir) make this an absolute (rooted) path

Returns
Length

◆ MakeFullPath2()

StrLen_t GRAYCALL Gray::cFilePath::MakeFullPath2 ( FILECHAR_t pszFileOut,
const FILECHAR_t pszFileInp,
StrLen_t  iLenMax,
FILECHAR_t  chSep = k_DirSep 
)
static

ASSERT(!IsFilePathRooted(pszFileInp))

Note
UNDER_CE has no concept of application current directory. All paths are rooted.
Returns
Length

◆ MakeFullPathX()

cStringF GRAYCALL Gray::cFilePath::MakeFullPathX ( const FILECHAR_t pszFileInp,
FILECHAR_t  chSep = k_DirSep 
)
static

If this is a relative path (to app current dir) make this an absolute (rooted) path

◆ MakeProperPath()

StrLen_t GRAYCALL Gray::cFilePath::MakeProperPath ( FILECHAR_t pszFileOut,
StrLen_t  iLenMax = 260,
const FILECHAR_t pszFileInp = nullptr,
FILECHAR_t  chSep = k_DirSep 
)
static

Make sure all forward/back slashes are chSep. Remove/resolve relatives like ../ or ./ except if relativism would make us lower than root, then just leave it. like _WIN32 PathCanonicalize() _WIN32 calls use paths using \ backslashes. (default) linux uses HTTP style forward / slashes. Windows typically can use either / or \ but they should be consistent.

  • pszFileOut = (inplace pszFileOut == pszFileInp is ok) iLenMax chSep = / = to use / k_DirSep (default)
    Returns
    Length of pszFileOut

◆ MakeProperPathX()

cStringF GRAYCALL Gray::cFilePath::MakeProperPathX ( const FILECHAR_t pszFileInp,
FILECHAR_t  chSep = k_DirSep 
)
static

Make sure all forward/back slashes are chSep.

◆ MakeRelativePath()

cStringF GRAYCALL Gray::cFilePath::MakeRelativePath ( const FILECHAR_t pszFullPath,
const FILECHAR_t pszRootDir 
)
static

given a pszFullPath, subtract pszRootDir out to make a relative path. If pszFullPath is not relative to pszRootDir just return the pszFullPath. Try using IsRelativeRoot() before call to this. e.g. pszFullPath = "c:\data\a\b\c.txt", pszRootDir = "c:\data", Return= "a\b\c.txt"

◆ ReplaceFileExt()

cStringF GRAYCALL Gray::cFilePath::ReplaceFileExt ( const FILECHAR_t pszFilePath,
const FILECHAR_t pszExtNew 
)
static

Replace the existing Ext with this new one. If it didn't have one then just add this.

  • pszExtNew = ".EXT" (with dot)

◆ SkipRelativePrefix()

FILECHAR_t *GRAYCALL Gray::cFilePath::SkipRelativePrefix ( const FILECHAR_t pszName)
static

if it has a relative prefix (.) then skip it. it means nothing.

◆ StripFileExt()

StrLen_t GRAYCALL Gray::cFilePath::StripFileExt ( FILECHAR_t pszFile,
StrLen_t  iLen,
bool  bMultiDot = false 
)
static

strip the ext off the file name (or path).

  • iLen = the known string length of the file name.
    Returns
    new length of the string.

Friends And Related Function Documentation

◆ cFilePathTests

friend class cFilePathTests
friend

Member Data Documentation

◆ k_DirSep

const FILECHAR_t Gray::cFilePath::k_DirSep = '/'
static

preferred for linux NFS but allowed by _WIN32.

◆ k_DirSep1

const FILECHAR_t Gray::cFilePath::k_DirSep1 = '/'
static

preferred for linux NFS but allowed by _WIN32.

◆ k_DirSep2

const FILECHAR_t Gray::cFilePath::k_DirSep2 = '\\'
static

preferred for _WIN32 but NOT allowed in linux.

◆ k_MaxLen

const StrLen_t Gray::cFilePath::k_MaxLen = 260
static

Use _MAX_PATH for max length of a file path.


The documentation for this class was generated from the following files: