23char *realpath(
char const *a_path,
char *a_resolved ) {
27 DWORD length = GetFullPathName( a_path,
LUPI_PATH_MAX, resolvedPath,
nullptr );
29 if( ( p1 = (
char *)
malloc( length + 1 ) ) ==
nullptr )
return(
nullptr );
30 strcpy( p1, resolvedPath );
31 if( length == 0 )
return(
nullptr );
35std::string dirname(
char const *a_path ) {
36 std::filesystem::path filePath( a_path );
37 return filePath.parent_path().string();
40std::string basename(
char const *a_path ) {
42 std::filesystem::path filePath( a_path );
43 return filePath.filename().string();
63std::string
realPath( std::string
const &a_path ) {
65 char *p1 = realpath( a_path.c_str( ),
nullptr );
68 std::string errMsg(
"realPath: file does not exist: " );
71 std::string basePath( p1 );
84 char *path =
new char[a_path.size( ) + 1];
85 strcpy( path, a_path.c_str( ) );
86 std::string basename1( basename( path ) );
101 std::size_t found = a_path.rfind(
'.' );
103 return( a_path.substr( 0, found ) );
114 char *path =
new char[a_path.size( ) + 1];
115 strcpy( path, a_path.c_str( ) );
116 std::string dirname1( dirname( (
char *) path ) );
129bool exists( std::string
const &a_path ) {
132 return std::filesystem::exists( std::filesystem::path( a_path ) );
134 return( access( a_path.c_str( ), F_OK ) == 0 );
168 if( ( a_path ==
LUPI_FILE_SEPARATOR ) || ( a_path ==
"." ) || ( a_path ==
"" ) )
return(
true );
170 std::string dirname1(
_dirname( a_path ) );
173 int status = _mkdir( a_path.c_str( ) );
175 int status = mkdir( a_path.c_str( ), S_IRWXU | S_IRWXG | S_IRWXG );
177 if( status == 0 )
return(
true );
198 int error = stat( a_path.c_str( ), &m_stat );
203 throw Exception(
"FileStat::FileStat: Permission denied for file '" + a_path +
"'.." );
205 throw Exception(
"FileStat::FileStat: An error occurred while stat-ing file '" + a_path +
"'.." );
207 throw Exception(
"FileStat::FileStat: A loop exists in symbolic links for file '" + a_path +
"'.." );
209 throw Exception(
"FileStat::FileStat: Path name too long '" + a_path +
"'." );
211 throw Exception(
"FileStat::FileStat: No such path '" + a_path +
"'." );
213 throw Exception(
"FileStat::FileStat: A component of the path prefix is not a directory '" + a_path +
"'." );
215 throw Exception(
"FileStat::FileStat: File too big: '" + a_path +
"'." );
217 throw Exception(
"FileStat::FileStat: Unknown error from C function 'stat' for file '" + a_path +
"'." );
#define LUPI_FILE_SEPARATOR
FileStat(std::string const &a_path)
std::string basenameWithoutExtension(std::string const &a_path)
std::string _basename(std::string const &a_path)
bool exists(std::string const &a_path)
std::string realPath(std::string const &a_path)
bool createDirectories(std::string const &a_path)
std::string _dirname(std::string const &a_path)
bool isDirectory(std::string const &a_path)