Filesystem-Path

Offers helper objects to print the file system path of a file or directory object.

Summary
Filesystem-PathOffers helper objects to print the file system path of a file or directory object.
CopyrightThis program is free software.
Files
C-kern/api/io/filesystem/filepath.hHeader file Filesystem-Path.
C-kern/platform/Linux/io/filepath.cImplementation file Filesystem-Path impl.
Types
struct filepath_static_tExport filepath_static_t into global namespace.
Functions
test
unittest_io_filepathTest filepath_static_t functionality.
filepath_static_tAllocates static memory for a working directory and filename combination.
lifetime
init_filepathstaticInitializes fpath with the path of working directory workdir and filename.
query
STRPARAM_filepathstaticThis macro returns two string parameter describing path of working directory and filename.
inline implementation
Macros
STRPARAM_filepathstaticImplements filepath_static_t.STRPARAM_filepathstatic.

Copyright

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.

Author

© 2013 Jörg Seebohn

Files

C-kern/api/io/filesystem/filepath.h

Header file Filesystem-Path.

C-kern/platform/Linux/io/filepath.c

Implementation file Filesystem-Path impl.

Types

struct filepath_static_t

typedef struct filepath_static_t filepath_static_t

Export filepath_static_t into global namespace.

Functions

test

unittest_io_filepath

int unittest_io_filepath(void)

Test filepath_static_t functionality.

filepath_static_t

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.

Summary
lifetime
init_filepathstaticInitializes fpath with the path of working directory workdir and filename.
query
STRPARAM_filepathstaticThis macro returns two string parameter describing path of working directory and filename.

lifetime

init_filepathstatic

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.

query

STRPARAM_filepathstatic

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)) ;

Macros

STRPARAM_filepathstatic

#define STRPARAM_filepathstatic(fpath) (fpath)->workdir, (fpath)->filename

Implements filepath_static_t.STRPARAM_filepathstatic.

Offers helper objects to print the file system path of a file or directory object.
Implements Filesystem-Path.
typedef struct filepath_static_t filepath_static_t
Export filepath_static_t into global namespace.
struct filepath_static_t
Allocates static memory for a working directory and filename combination.
int unittest_io_filepath(void)
Test filepath_static_t functionality.
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.
void STRPARAM_filepathstatic(const filepath_static_t *fpath)
This macro returns two string parameter describing path of working directory and filename.
#define STRPARAM_filepathstatic(fpath) (fpath)->workdir, (fpath)->filename
Implements filepath_static_t.STRPARAM_filepathstatic.
Close