Offers helper objects to print the file system path of a file or directory object.
Filesystem-Path | Offers helper objects to print the file system path of a file or directory object. |
Copyright | This program is free software. |
Files | |
C-kern/ | Header file Filesystem-Path. |
C-kern/ | Implementation file Filesystem-Path impl. |
Types | |
struct filepath_static_t | Export filepath_static_t into global namespace. |
Functions | |
test | |
unittest_io_filepath | Test filepath_static_t functionality. |
filepath_static_t | Allocates static memory for a working directory and filename combination. |
lifetime | |
init_filepathstatic | Initializes fpath with the path of working directory workdir and filename. |
query | |
STRPARAM_filepathstatic | This macro returns two string parameter describing path of working directory and filename. |
inline implementation | |
Macros | |
STRPARAM_filepathstatic | Implements filepath_static_t.STRPARAM_filepathstatic. |
This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program 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 GNU General Public License for more details.
© 2013 Jörg Seebohn
Header file Filesystem-Path.
Implementation file Filesystem-Path impl.
typedef struct filepath_static_t filepath_static_t
Export filepath_static_t into global namespace.
test | |
unittest_io_filepath | Test filepath_static_t functionality. |
int unittest_io_filepath( void )
Test filepath_static_t functionality.
struct filepath_static_t
Allocates static memory for a working directory and filename combination. The path of the working directory always ends in the path separator ‘/’. So printing workdir and then filename results in a valid path name.
lifetime | |
init_filepathstatic | Initializes fpath with the path of working directory workdir and filename. |
query | |
STRPARAM_filepathstatic | This macro returns two string parameter describing path of working directory and filename. |
void init_filepathstatic( /*out*/filepath_static_t * fpath, const struct directory_t * workdir, const char * filename )
Initializes fpath with the path of working directory workdir and filename. The parameter filename is no copied. So fpath is only valid as long as filename is not changed or deleted. The function calls <path_directory> to determine the path of the working directory. If an error occurrs the path of the working directory is set to “???ERR/”.
It is allowed to set either workdir or filename to 0. If both parameter are set to 0 the resulting path is the empty string.
You do not need to free fpath cause no extra memory is allocated.
void STRPARAM_filepathstatic( const filepath_static_t * fpath )
This macro returns two string parameter describing path of working directory and filename. MAke sure that the expression which evaluates to fpath has no side effects cause fpath is evaluated twice in the macro. Use this macro to print the full path name as
printf("%s%s\n", STRPARAM_filepathstatic(fpath)) ;
#define STRPARAM_filepathstatic( fpath ) (fpath)->workdir, (fpath)->filename
Implements filepath_static_t.STRPARAM_filepathstatic.
Export filepath_static_t into global namespace.
typedef struct filepath_static_t filepath_static_t
Allocates static memory for a working directory and filename combination.
struct filepath_static_t
Test filepath_static_t functionality.
int unittest_io_filepath( void )
Initializes fpath with the path of working directory workdir and filename.
void init_filepathstatic( /*out*/filepath_static_t * fpath, const struct directory_t * workdir, const char * filename )
This macro returns two string parameter describing path of working directory and filename.
void STRPARAM_filepathstatic( const filepath_static_t * fpath )
Implements filepath_static_t.STRPARAM_filepathstatic.
#define STRPARAM_filepathstatic( fpath ) (fpath)->workdir, (fpath)->filename