Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions
Poco::File Class Reference

The File class provides methods for working with a file. More...

#include <File.h>

Inheritance diagram for Poco::File:
Inheritance graph
[legend]

List of all members.

Public Types

typedef FileSizeImpl FileSize

Public Member Functions

bool canExecute () const
 Returns true iff the file is writeable.
bool canRead () const
 Returns true iff the file exists.
bool canWrite () const
 Returns true iff the file is readable.
void copyTo (const std::string &path) const
Timestamp created () const
void createDirectories ()
bool createDirectory ()
bool createFile ()
bool exists () const
 Returns the path.
 File ()
 File (const std::string &path)
 Creates the file.
 File (const char *path)
 Creates the file.
 File (const Path &path)
 Creates the file.
 File (const File &file)
 Creates the file.
Timestamp getLastModified () const
FileSize getSize () const
 Sets the modification date of the file.
bool isDevice () const
 Returns true iff the file is a directory.
bool isDirectory () const
 Returns true iff the file is a symbolic link.
bool isFile () const
bool isHidden () const
 Returns true iff the file is a device.
bool isLink () const
 Returns true iff the file is a regular file.
void list (std::vector< std::string > &files) const
void list (std::vector< File > &files) const
void moveTo (const std::string &path)
bool operator!= (const File &file) const
bool operator< (const File &file) const
bool operator<= (const File &file) const
Fileoperator= (const File &file)
 Destroys the file.
Fileoperator= (const std::string &path)
 Assignment operator.
Fileoperator= (const char *path)
 Assignment operator.
Fileoperator= (const Path &path)
 Assignment operator.
bool operator== (const File &file) const
bool operator> (const File &file) const
bool operator>= (const File &file) const
const std::string & path () const
 Swaps the file with another one.
void remove (bool recursive=false)
 Renames the file to the new name.
void renameTo (const std::string &path)
void setExecutable (bool flag=true)
void setLastModified (const Timestamp &ts)
 Returns the modification date of the file.
void setReadOnly (bool flag=true)
void setSize (FileSize size)
 Returns the size of the file in bytes.
void setWriteable (bool flag=true)
void swap (File &file)
 Assignment operator.
virtual ~File ()
 Copy constructor.

Static Public Member Functions

static void handleLastError (const std::string &path)

Protected Member Functions

void copyDirectory (const std::string &path) const

Detailed Description

The File class provides methods for working with a file.

Definition at line 65 of file File.h.


Member Typedef Documentation

Definition at line 69 of file File.h.


Constructor & Destructor Documentation

Definition at line 56 of file File.cpp.

Poco::File::File ( const std::string &  path)

Creates the file.

Definition at line 61 of file File.cpp.

Poco::File::File ( const char *  path)

Creates the file.

Definition at line 66 of file File.cpp.

Poco::File::File ( const Path path)

Creates the file.

Definition at line 71 of file File.cpp.

Poco::File::File ( const File file)

Creates the file.

Definition at line 76 of file File.cpp.

Poco::File::~File ( ) [virtual]

Copy constructor.

Definition at line 81 of file File.cpp.


Member Function Documentation

bool Poco::File::canExecute ( ) const

Returns true iff the file is writeable.

Definition at line 139 of file File.cpp.

bool Poco::File::canRead ( ) const

Returns true iff the file exists.

Definition at line 127 of file File.cpp.

bool Poco::File::canWrite ( ) const

Returns true iff the file is readable.

Definition at line 133 of file File.cpp.

void Poco::File::copyDirectory ( const std::string &  path) const [protected]

For internal use only. Throws an appropriate exception for the last file-related error.

Definition at line 240 of file File.cpp.

void Poco::File::copyTo ( const std::string &  path) const

Makes the file executable (if flag is true), or non-executable (if flag is false) by setting the file's permission bits accordingly.

Does nothing on Windows and OpenVMS.

Definition at line 223 of file File.cpp.

Returns true if the file is hidden.

On Windows platforms, the file's hidden attribute is set for this to be true.

On Unix platforms, the file name must begin with a period for this to be true.

Definition at line 175 of file File.cpp.

Creates a directory. Returns true if the directory has been created and false if it already exists. Throws an exception if an error occurs.

Definition at line 298 of file File.cpp.

Creates a new, empty file in an atomic operation. Returns true if the file has been created and false if the file already exists. Throws an exception if an error occurs.

Definition at line 292 of file File.cpp.

Deletes the file. If recursive is true and the file is a directory, recursively deletes all files in the directory.

Definition at line 286 of file File.cpp.

bool Poco::File::exists ( ) const

Returns the path.

Definition at line 121 of file File.cpp.

Returns the creation date of the file.

Not all platforms or filesystems (e.g. Linux and most Unix platforms with the exception of FreeBSD and Mac OS X) maintain the creation date of a file. On such platforms, created() returns the time of the last inode modification.

Definition at line 181 of file File.cpp.

Sets the modification date of the file.

Definition at line 193 of file File.cpp.

void Poco::File::handleLastError ( const std::string &  path) [static]

Reimplemented from Poco::FileImpl.

Definition at line 341 of file File.cpp.

bool Poco::File::isDevice ( ) const

Returns true iff the file is a directory.

Definition at line 163 of file File.cpp.

bool Poco::File::isDirectory ( ) const

Returns true iff the file is a symbolic link.

Definition at line 151 of file File.cpp.

bool Poco::File::isFile ( ) const

Returns true iff the file is executable.

On Windows and OpenVMS, the file must have the extension ".EXE" to be executable. On Unix platforms, the executable permission bit must be set.

Definition at line 145 of file File.cpp.

bool Poco::File::isHidden ( ) const

Returns true iff the file is a device.

Definition at line 169 of file File.cpp.

bool Poco::File::isLink ( ) const

Returns true iff the file is a regular file.

Definition at line 157 of file File.cpp.

void Poco::File::list ( std::vector< std::string > &  files) const

Creates a directory (and all parent directories if necessary).

Definition at line 315 of file File.cpp.

void Poco::File::list ( std::vector< File > &  files) const

Fills the vector with the names of all files in the directory.

Definition at line 328 of file File.cpp.

void Poco::File::moveTo ( const std::string &  path)

Copies the file (or directory) to the given path. The target path can be a directory.

A directory is copied recursively.

Definition at line 256 of file File.cpp.

bool Poco::File::operator!= ( const File file) const [inline]

Definition at line 257 of file File.h.

bool Poco::File::operator< ( const File file) const [inline]

Definition at line 263 of file File.h.

bool Poco::File::operator<= ( const File file) const [inline]

Definition at line 269 of file File.h.

File & Poco::File::operator= ( const File file)

Destroys the file.

Definition at line 86 of file File.cpp.

File & Poco::File::operator= ( const std::string &  path)

Assignment operator.

Definition at line 93 of file File.cpp.

File & Poco::File::operator= ( const char *  path)

Assignment operator.

Definition at line 100 of file File.cpp.

File & Poco::File::operator= ( const Path path)

Assignment operator.

Definition at line 108 of file File.cpp.

bool Poco::File::operator== ( const File file) const [inline]

Fills the vector with the names of all files in the directory.

Definition at line 251 of file File.h.

bool Poco::File::operator> ( const File file) const [inline]

Definition at line 275 of file File.h.

bool Poco::File::operator>= ( const File file) const [inline]

Definition at line 281 of file File.h.

const std::string & Poco::File::path ( ) const [inline]

Swaps the file with another one.

Definition at line 245 of file File.h.

void Poco::File::remove ( bool  recursive = false)

Renames the file to the new name.

Definition at line 271 of file File.cpp.

void Poco::File::renameTo ( const std::string &  path)

Copies the file (or directory) to the given path and removes the original file. The target path can be a directory.

Definition at line 264 of file File.cpp.

void Poco::File::setExecutable ( bool  flag = true)

Makes the file non-writeable (if flag is true), or writeable (if flag is false) by setting the file's flags in the filesystem accordingly.

Definition at line 217 of file File.cpp.

void Poco::File::setLastModified ( const Timestamp ts)

Returns the modification date of the file.

Definition at line 187 of file File.cpp.

void Poco::File::setReadOnly ( bool  flag = true)

Makes the file writeable (if flag is true), or non-writeable (if flag is false) by setting the file's flags in the filesystem accordingly.

Definition at line 211 of file File.cpp.

void Poco::File::setSize ( FileSize  size)

Returns the size of the file in bytes.

Definition at line 199 of file File.cpp.

void Poco::File::setWriteable ( bool  flag = true)

Sets the size of the file in bytes. Can be used to truncate a file.

Definition at line 205 of file File.cpp.

void Poco::File::swap ( File file)

Assignment operator.

Definition at line 115 of file File.cpp.


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


pluginlib
Author(s): Tully Foote and Eitan Marder-Eppstein
autogenerated on Sat Dec 28 2013 17:20:20