OS file-system querying and manipulation. More...
#include <unistd.h>
#include <string>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <cstddef>
#include <ctime>
#include "debugging/debugging.h"
Go to the source code of this file.
Namespaces | |
namespace | FileAccess |
Defines | |
#define | INCLUDED_OS_FILE_H |
Typedefs | |
typedef std::size_t | FileSize |
typedef std::time_t | FileTime |
Seconds elapsed since Jan 1, 1970. | |
typedef unsigned char | byte |
Enumerations | |
enum | FileAccess::Mode { FileAccess::Read = R_OK, FileAccess::Write = W_OK, FileAccess::ReadWrite = Read | Write, FileAccess::Exists = F_OK } |
Functions | |
bool | file_move (const std::string &from, const std::string &to) |
Attempts to move the file identified by from to to and returns true if the operation was successful. | |
bool | file_remove (const std::string &path) |
Attempts to remove the file identified by path and returns true if the operation was successful. | |
bool | file_accessible (const std::string &path, FileAccess::Mode mode) |
Returns true if the file or directory identified by path exists and/or may be accessed for reading, writing or both, depending on the value of mode . | |
bool | file_readable (const std::string &path) |
Returns true if the file or directory identified by path exists and may be opened for reading. | |
bool | file_writeable (const std::string &path) |
Returns true if the file or directory identified by path exists and may be opened for writing. | |
bool | file_exists (const std::string &path) |
Returns true if the file or directory identified by path exists. | |
bool | file_is_directory (const std::string &path) |
Returns true if the file or directory identified by path exists and is a directory. | |
FileSize | file_size (const std::string &path) |
Returns the size in bytes of the file identified by path , or 0 if the file was not found. | |
FileTime | file_modified (const std::string &path) |
Returns the time that the file identified by path was last modified, or c_invalidFileTime if the file was not found. | |
int | file_write (const void *buffer, int len, FILE *f) |
Properly handles partial writes. | |
Variables | |
const FileTime | c_invalidFileTime = -1 |
No file can have been modified earlier than this time. |
OS file-system querying and manipulation.
Definition in file file.h.
typedef std::time_t FileTime |
bool file_accessible | ( | const std::string & | path, | |
FileAccess::Mode | mode | |||
) | [inline] |
Returns true if the file or directory identified by path
exists and/or may be accessed for reading, writing or both, depending on the value of mode
.
Definition at line 77 of file file.h.
Referenced by file_exists(), file_readable(), and file_writeable().
bool file_exists | ( | const std::string & | path | ) | [inline] |
Returns true if the file or directory identified by path
exists.
Definition at line 95 of file file.h.
References FileAccess::Exists, and file_accessible().
bool file_is_directory | ( | const std::string & | path | ) | [inline] |
FileTime file_modified | ( | const std::string & | path | ) | [inline] |
Returns the time that the file identified by path
was last modified, or c_invalidFileTime if the file was not found.
Definition at line 126 of file file.h.
References c_invalidFileTime.
bool file_move | ( | const std::string & | from, | |
const std::string & | to | |||
) | [inline] |
Attempts to move the file identified by from
to to
and returns true if the operation was successful.
The operation will fail unless:
from
identifies an existing file which is accessible for writing.from
identifies an existing directory which is accessible for writing.to
does not identify an existing file or directory.to
identifies an existing directory which is accessible for writing. bool file_readable | ( | const std::string & | path | ) | [inline] |
Returns true if the file or directory identified by path
exists and may be opened for reading.
Definition at line 83 of file file.h.
References file_accessible(), and FileAccess::Read.
bool file_remove | ( | const std::string & | path | ) | [inline] |
Attempts to remove the file identified by path
and returns true if the operation was successful.
The operation will fail unless:
path
identifies an existing file.path
identifies an existing directory which is accessible for writing. FileSize file_size | ( | const std::string & | path | ) | [inline] |
int file_write | ( | const void * | buffer, | |
int | len, | |||
FILE * | f | |||
) | [inline] |
bool file_writeable | ( | const std::string & | path | ) | [inline] |
Returns true if the file or directory identified by path
exists and may be opened for writing.
Definition at line 89 of file file.h.
References file_accessible(), and FileAccess::Write.
const FileTime c_invalidFileTime = -1 |
No file can have been modified earlier than this time.
Definition at line 123 of file file.h.
Referenced by file_modified().