Filesystem - Path style abstraction
A class that carries information about a filesystem path's style: case sensitivity, path separator and whether it supports drive letters.
This commit is contained in:
parent
811916a4a3
commit
ee02f9c5c7
2 changed files with 140 additions and 1 deletions
include/ebcl/inline
|
@ -9,6 +9,90 @@
|
|||
namespace ebcl {
|
||||
|
||||
|
||||
/*= T_FSPathStyle ============================================================*/
|
||||
|
||||
inline T_FSPathStyle::T_FSPathStyle(
|
||||
bool cs ,
|
||||
bool hdl ,
|
||||
T_Flags< E_FSPathSeparator > ps ) noexcept
|
||||
: caseSensitive_{ cs } , hasDriveLetter_{ hdl } , pathSeparators_{ ps }
|
||||
{
|
||||
assert( ps );
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
inline T_FSPathStyle& T_FSPathStyle::swap(
|
||||
T_FSPathStyle& other ) noexcept
|
||||
{
|
||||
using std::swap;
|
||||
swap( caseSensitive_ , other.caseSensitive_ );
|
||||
swap( hasDriveLetter_ , other.hasDriveLetter_ );
|
||||
swap( pathSeparators_ , other.pathSeparators_ );
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
inline bool T_FSPathStyle::caseSensitive( ) const noexcept
|
||||
{
|
||||
return caseSensitive_;
|
||||
}
|
||||
|
||||
inline T_FSPathStyle& T_FSPathStyle::caseSensitive( bool cs ) noexcept
|
||||
{
|
||||
caseSensitive_ = cs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool T_FSPathStyle::hasDriveLetter( ) const noexcept
|
||||
{
|
||||
return hasDriveLetter_;
|
||||
}
|
||||
|
||||
inline T_FSPathStyle& T_FSPathStyle::hasDriveLetter( bool hdl ) noexcept
|
||||
{
|
||||
hasDriveLetter_ = hdl;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline T_Flags< E_FSPathSeparator > T_FSPathStyle::pathSeparators( ) const noexcept
|
||||
{
|
||||
return pathSeparators_;
|
||||
}
|
||||
|
||||
inline T_FSPathStyle& T_FSPathStyle::pathSeparator(
|
||||
T_Flags< E_FSPathSeparator > ps ) noexcept
|
||||
{
|
||||
assert( ps );
|
||||
pathSeparators_ = ps;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
inline T_FSPathStyle T_FSPathStyle::Unix( )
|
||||
{
|
||||
return T_FSPathStyle{ true , false ,
|
||||
T_Flags< E_FSPathSeparator >{ E_FSPathSeparator::SLASH } };
|
||||
}
|
||||
|
||||
inline T_FSPathStyle T_FSPathStyle::Windows( )
|
||||
{
|
||||
return T_FSPathStyle{ false , true ,
|
||||
T_Flags< E_FSPathSeparator >{ E_FSPathSeparator::BACKSLASH } };
|
||||
}
|
||||
|
||||
inline T_FSPathStyle T_FSPathStyle::System( )
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return T_FSPathStyle::Windows( );
|
||||
#else
|
||||
return T_FSPathStyle::Unix( );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*= T_FSPath =================================================================*/
|
||||
|
||||
inline T_FSPath::T_FSPath( ) noexcept
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue