Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

dirfile.h File Reference

Directory and filename manipulation routines. More...

Go to the source code of this file.

Functions

char* fname_split (const char *Fullname, char **Path, char **Name, char **Ext)
 fname_split(Fullname, Path, Name, Ext): splits the filename Fullname into Path, Name and Ext. More...

char* change_ext (const char *Name, const char *Ext)
 change_ext(Name, Ext): changes the extension of the filename Name to Ext. More...

int mkdir_p (const char *Path)
 mkdir_p(Path): creates the path Path with rwxrwxrwx permissions, spiced by the current umask of the process. More...


Detailed Description

Directory and filename manipulation routines.

Supports filename splitting, extension change and directory creation. Note that these routines are not portable to non-UNIX systems.

Definition in file dirfile.h.


Function Documentation

char * fname_split ( const char * Fullname,
char ** Path,
char ** Name,
char ** Ext )
 

fname_split(Fullname, Path, Name, Ext): splits the filename Fullname into Path, Name and Ext.

Allocates and returns a string which is essentially Fullname but with appropriate \0-s inserted. So from Fullname --> "dir1/dir2/dir3/name.ext" you get

   "dir1/dir2/dir3/\0name\0.ext"
    ^                ^     ^
    |                |     |
   *Path,          *Name  *Ext
   
pointing to the appropriate positions as shown. The returned string should be saved into a char ptr in any case otherwise you might not be able to free it up when *Path is NULL or not set. If any of Path, Name or Ext is NULL, then the corresponding pointer is not set. If all three are NULL, nothing is done and NULL is returned with a warning. If there is no path, then *Path=NULL, if there is no extension, then *Ext=NULL on return. Filenames beginning with a dot are treated as such: there is no ".ext" without a "name".

char * change_ext ( const char * Name,
const char * Ext )
 

change_ext(Name, Ext): changes the extension of the filename Name to Ext.

An extension is the part of the filename after the last dot ('.') after the last slash ('/') in it. Ext should begin with a dot. If Name has no extension, then Ext is simply appended to it. Return value: the modified Name (allocated within).

int mkdir_p ( const char * Path )
 

mkdir_p(Path): creates the path Path with rwxrwxrwx permissions, spiced by the current umask of the process.

Does the same job as the 'mkdir -p' UNIX command. Return value: 0 if OK, or the UNIX error number (errno) if something went wrong.


Generated at Wed Aug 21 09:33:39 2002 for The Razorback C Library: Miscellaneous Utilities by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001