Main Page | Class List | File List | Class Members | File Members | Related Pages

gi_fileutil.h File Reference

Simple file manipulation routines. More...

#include "gi_path.h"
#include <limits.h>
#include <dirent.h>
#include <io.h>
#include <stddef.h>

Go to the source code of this file.

Classes

struct  dirent
struct  DIR

Defines

#define PATH_MAX   4096
#define S_ISDIR(m)   (((m) & S_IFMT) == S_IFDIR)
#define S_ISFIFO(m)   (((m) & S_IFMT) == S_IFIFO)
#define S_ISCHR(m)   (((m) & S_IFMT) == S_IFCHR)
#define S_ISBLK(m)   (((m) & S_IFMT) == S_IFBLK)
#define S_ISREG(m)   (((m) & S_IFMT) == S_IFREG)

Functions

EXTERN_C_BEGIN LIBGIFT_EXPORT
int 
gi_file_mv (const char *src, const char *dst)
LIBGIFT_EXPORT int gi_file_cp (const char *src, const char *dst)
LIBGIFT_EXPORT int gi_file_mkdir (const char *path, int mode)
LIBGIFT_EXPORT int gi_file_mkdirp (GiPath *path, int mode)
LIBGIFT_EXPORT int unlink (const char *path)
LIBGIFT_EXPORT int rmdir (const char *path)
LIBGIFT_EXPORT int gi_file_rmdirr (const char *path)


Detailed Description

Simple file manipulation routines.


Function Documentation

LIBGIFT_EXPORT int gi_file_cp const char *  src,
const char *  dst
 

Make a copy of a file.

Returns:
On success, zero is returned; otherwise, -1 and errno will be set.

LIBGIFT_EXPORT int gi_file_mkdir const char *  path,
int  mode
 

Portable alternative to the POSIX mkdir() function. This function behaves identically in every way, except that the calling parameter is defined as int instead of mode_t.

Note:
The name of the function changes from mkdir() simply because we do not expect a consistent prototype across every platform. For this reason, we must produce a wrapper for even POSIX.

LIBGIFT_EXPORT int gi_file_mkdirp GiPath path,
int  mode
 

Similar to /bin/mkdir --parents. If any of the internal calls to gi_file_mkdir fail, or there is an element on the directory path that exists but is not already a directory, the call will abort. If the full path already exists as a directory, no action will be performed.

Parameters:
path Path object to ensure that the path may be reliably parsed on all platforms.
mode Mode to be passed directly to ::gi_path_mkdir for each directory that requires creation.
Returns:
If the full directory path described was successfully created, or already existed, 0 is returned. In all other cases, -1 is returned and errno will be set.

EXTERN_C_BEGIN LIBGIFT_EXPORT int gi_file_mv const char *  src,
const char *  dst
 

Move a file, first attempting rename(), then a copy and unlink in /bin/mv fashion.

Returns:
On success, zero is returned; otherwise, -1 and errno will be set.

LIBGIFT_EXPORT int gi_file_rmdirr const char *  path  ) 
 

Remove a directory path as would be done with /bin/rm -r. All subdirectories and files there-under will be removed. In the event of an error, the process will continue until all entries have been attempted.

Returns:
On successful removal of `path' and all entries held within, 0 is returned; otherwise, -1 and errno will be set by the last failed library call.


Generated on Sun Aug 22 07:56:40 2004 by doxygen 1.3.7