- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Classes | Public Types | Static Public Member Functions | Friends | List of all members
G::File Class Reference

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

`#include <gfile.h>`

## Classes
class | NoThrow
| An overload discriminator class for File methods. More...

## 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. More...
static void | remove (const Path &path)
| Deletes the file or directory. Throws an exception on error. More...
static bool | rename (const Path &from, const Path &to, const NoThrow &)
| Renames the file. Returns false on error. More...
static void | rename (const Path &from, const Path &to)
| Renames the file. More...
static bool | copy (const Path &from, const Path &to, const NoThrow &)
| Copies a file. Returns false on error. More...
static void | copy (const Path &from, const Path &to)
| Copies a file. More...
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. More...
static bool | mkdirs (const Path &dir, const NoThrow &, int=100)
| Creates a directory and all necessary parents. More...
static void | mkdirs (const Path &dir, int=100)
| Creates a directory and all necessary parents. More...
static bool | mkdir (const Path &dir, const NoThrow &)
| Creates a directory. Returns false on error. More...
static void | mkdir (const Path &dir)
| Creates a directory. More...
static std::string | sizeString (const Path &file)
| Returns the file's size in string format. More...
static bool | exists (const Path &file)
| Returns true if the file (directory, link, device etc.) exists. More...
static bool | exists (const Path &file, const NoThrow &)
| Returns true if the file (directory, link, device etc.) exists. More...
static time_type | time (const Path &file)
| Returns the file's timestamp. More...
static time_type | time (const Path &file, const NoThrow &)
| Returns the file's timestamp. More...
static void | chmodx (const Path &file)
| Makes the file executable. More...
static bool | chmodx (const Path &file, const NoThrow &)
| Makes the file executable. More...
static void | link (const Path &target, const Path &new_link)
| Creates a symlink. More...
static bool | link (const Path &target, const Path &new_link, const NoThrow &)
| Creates a symlink. More...
static bool | executable (const Path &)
| Returns true if the path is probably executable. More...
static void | create (const Path &)
| Creates an empty file. Throws on error. More...

## Friends
class | G::DirectoryIteratorImp

## 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

typedef DateTime::EpochTime G::File::time_type

Definition at line 44 of file gfile.h.

## Member Function Documentation

void G::File::chmodx | ( | const Path & | file | ) |
| static

Makes the file executable.

Definition at line 164 of file gfile.cpp.

bool G::File::chmodx | ( | const Path & | file,
|  | const NoThrow & |
| ) |  |
| static

Makes the file executable.

Definition at line 159 of file gfile.cpp.

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 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 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.

void G::File::create | ( | const Path & | path | ) |
| static

Creates an empty file. Throws on error.

Definition at line 188 of file gfile.cpp.

References 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().

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(), GSmtp::StoredFile::fail(), and filter_run().

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.

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 G::limits::path, 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().

void G::File::mkdir | ( | const Path & | dir | ) |
| static

Creates a directory.

Definition at line 124 of file gfile.cpp.

References G::Path::str().

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 G::Path::dirname(), G_DEBUG, and G::Path::str().

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 G::Path::str().

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(), GSmtp::StoredFile::lock(), and GSmtp::StoredFile::unfail().

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().

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().

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().

## 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:

- gfile.h
- gfile.cpp
- gfile_unix.cpp