G::File Class Reference

A simple static class for dealing with files. More...

#include <gfile.h>

List of all members.

Public Types

typedef DateTime::EpochTime time_type

Static Public Member Functions

static bool remove (const Path &path, const NoThrow &)
 Deletes the file or directory. Returns false on error.
static void remove (const Path &path)
 Deletes the file or directory. Throws an exception on error.
static bool rename (const Path &from, const Path &to, const NoThrow &)
 Renames the file. Returns false on error.
static void rename (const Path &from, const Path &to)
 Renames the file.
static bool copy (const Path &from, const Path &to, const NoThrow &)
 Copies a file. Returns false on error.
static void copy (const Path &from, const Path &to)
 Copies a file.
static void copy (std::istream &from, std::ostream &to, std::streamsize limit=0U, std::string::size_type block=0U)
 Copies a stream with an optional size limit.
static bool mkdirs (const Path &dir, const NoThrow &, int=100)
 Creates a directory and all necessary parents.
static void mkdirs (const Path &dir, int=100)
 Creates a directory and all necessary parents.
static bool mkdir (const Path &dir, const NoThrow &)
 Creates a directory. Returns false on error.
static void mkdir (const Path &dir)
 Creates a directory.
static std::string sizeString (const Path &file)
 Returns the file's size in string format.
static bool exists (const Path &file)
 Returns true if the file (directory, link, device etc.
static bool exists (const Path &file, const NoThrow &)
 Returns true if the file (directory, link, device etc.
static time_type time (const Path &file)
 Returns the file's timestamp.
static time_type time (const Path &file, const NoThrow &)
 Returns the file's timestamp.
static void chmodx (const Path &file)
 Makes the file executable.
static bool chmodx (const Path &file, const NoThrow &)
 Makes the file executable.
static void link (const Path &target, const Path &new_link)
 Creates a symlink.
static bool link (const Path &target, const Path &new_link, const NoThrow &)
 Creates a symlink.
static bool executable (const Path &)
 Returns true if the path is probably executable.
static void create (const Path &)
 Creates an empty file. Throws on error.

Friends

class G::DirectoryIteratorImp

Classes

class  NoThrow
 An overload discriminator class for File methods. More...


Detailed Description

A simple static class for dealing with files.

See also:
G::Path, G::FileSystem, G::Directory

Definition at line 41 of file gfile.h.


Member Typedef Documentation

Definition at line 44 of file gfile.h.


Member Function Documentation

bool G::File::remove ( const Path path,
const NoThrow  
) [static]

Deletes the file or directory. Returns false on error.

Definition at line 29 of file gfile.cpp.

References G_DEBUG, and G::Path::str().

Referenced by GSmtp::StoredFile::destroy(), and filter_run().

void G::File::remove ( const Path path  )  [static]

Deletes the file or directory. Throws an exception on error.

Definition at line 36 of file gfile.cpp.

References G_DEBUG, and G::Path::str().

bool G::File::rename ( const Path from,
const Path to,
const NoThrow  
) [static]

Renames the file. Returns false on error.

Definition at line 46 of file gfile.cpp.

References G_DEBUG, and G::Path::str().

Referenced by GSmtp::StoredFile::fail(), and GSmtp::StoredFile::lock().

void G::File::rename ( const Path from,
const Path to 
) [static]

Renames the file.

Definition at line 53 of file gfile.cpp.

References G_DEBUG, and G::Path::str().

bool G::File::copy ( const Path from,
const Path to,
const NoThrow  
) [static]

Copies a file. Returns false on error.

Definition at line 70 of file gfile.cpp.

Referenced by copy(), and filter_run().

void G::File::copy ( const Path from,
const Path to 
) [static]

Copies a file.

Definition at line 63 of file gfile.cpp.

References copy(), and G::Path::str().

void G::File::copy ( std::istream &  from,
std::ostream &  to,
std::streamsize  limit = 0U,
std::string::size_type  block = 0U 
) [static]

Copies a stream with an optional size limit.

Definition at line 101 of file gfile.cpp.

References G::limits::file_buffer, and result.

bool G::File::mkdirs ( const Path dir,
const NoThrow ,
int  limit = 100 
) [static]

Creates a directory and all necessary parents.

Returns false on error. Does chmodx() on all created directories.

Definition at line 169 of file gfile.cpp.

References chmodx(), G::Path::dirname(), exists(), G_DEBUG, mkdir(), and G::Path::str().

Referenced by mkdirs().

void G::File::mkdirs ( const Path dir,
int  limit = 100 
) [static]

Creates a directory and all necessary parents.

Does chmodx() on all created directories.

Definition at line 182 of file gfile.cpp.

References mkdirs(), and G::Path::str().

bool G::File::mkdir ( const Path dir,
const NoThrow  
) [static]

Creates a directory. Returns false on error.

Definition at line 30 of file gfile_unix.cpp.

References G::Path::str().

Referenced by mkdir(), and mkdirs().

void G::File::mkdir ( const Path dir  )  [static]

Creates a directory.

Definition at line 124 of file gfile.cpp.

References mkdir(), and G::Path::str().

std::string G::File::sizeString ( const Path file  )  [static]

Returns the file's size in string format.

Returns the empty string on error.

Definition at line 67 of file gfile_unix.cpp.

References G::Path::str().

Referenced by GSmtp::SpamClient::request(), and G::DirectoryIteratorImp::sizeString().

bool G::File::exists ( const Path file  )  [static]

Returns true if the file (directory, link, device etc.

) exists. Throws an exception if permission denied or too many symlinks etc.

Definition at line 130 of file gfile.cpp.

Referenced by GSmtp::FactoryParser::check(), create(), exists(), GSmtp::StoredFile::fail(), filter_run(), link(), and mkdirs().

bool G::File::exists ( const Path file,
const NoThrow  
) [static]

Returns true if the file (directory, link, device etc.

) exists. Returns false on error.

Definition at line 135 of file gfile.cpp.

References exists().

G::File::time_type G::File::time ( const Path file  )  [static]

Returns the file's timestamp.

Definition at line 78 of file gfile_unix.cpp.

References G::Path::str().

G::File::time_type G::File::time ( const Path file,
const NoThrow  
) [static]

Returns the file's timestamp.

Returns zero on error.

Definition at line 86 of file gfile_unix.cpp.

References G::Path::str().

void G::File::chmodx ( const Path file  )  [static]

Makes the file executable.

Definition at line 164 of file gfile.cpp.

Referenced by chmodx(), and mkdirs().

bool G::File::chmodx ( const Path file,
const NoThrow  
) [static]

Makes the file executable.

Definition at line 159 of file gfile.cpp.

References chmodx().

void G::File::link ( const Path target,
const Path new_link 
) [static]

Creates a symlink.

Definition at line 111 of file gfile_unix.cpp.

References G::Process::errno_().

bool G::File::link ( const Path target,
const Path new_link,
const NoThrow  
) [static]

Creates a symlink.

Definition at line 122 of file gfile_unix.cpp.

References exists(), G::limits::path, and G::Path::str().

bool G::File::executable ( const Path path  )  [static]

Returns true if the path is probably executable.

Because of portability and implementation difficulties this does not return a definitive result so it should only used for generating warnings on a false return.

Definition at line 50 of file gfile_unix.cpp.

References G::Path::str().

Referenced by GSmtp::FactoryParser::check().

void G::File::create ( const Path path  )  [static]

Creates an empty file. Throws on error.

Definition at line 188 of file gfile.cpp.

References exists(), and G::Path::str().


Friends And Related Function Documentation

friend class G::DirectoryIteratorImp [friend]

Definition at line 137 of file gfile.h.


The documentation for this class was generated from the following files:

Generated on Fri Apr 18 15:56:13 2008 for E-MailRelay by  doxygen 1.5.5