Fawkes API
Fawkes Development Version
|
25 #include <core/exceptions/system.h>
27 #include <sys/types.h>
28 #include <utils/system/file.h>
50 append(
"File that could not be opened: %s", filename);
74 fd = open(
filename, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
79 fd = open(
filename, O_RDWR | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
84 char *filename_ext = strdup(
filename);
88 if (asprintf(&filename_ext,
"%s.%d",
filename, ++index) == -1) {
92 fd = open(filename_ext, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
96 default: printf(
"%s [line %d]: Unkown method.\n", __FILE__, __LINE__);
103 fp = fdopen(fd,
"r+");
139 return (access(
filename, F_OK) == 0);
152 return S_ISREG(s.st_mode);
static bool exists(const char *filename)
Check if a file exists.
static bool is_regular(const char *filename)
Check if a file is a regular file.
UnableToOpenFileException(const char *filename, int error)
Constructor.
@ ADD_SUFFIX
add a suffix (starting with ".1") to the given filename
const char * filename() const
Get the file's name.
@ OVERWRITE
overwrite the existing file
void append(const char *format,...)
Append messages to the message list.
Opening a file failed for some reason.
File(const char *filename, FileOpenMethod method=APPEND)
Constructor.
Fawkes library namespace.
@ APPEND
append data at the end of the existing file
FILE * stream() const
Get access to the file stream.
System ran out of memory and desired operation could not be fulfilled.
FileOpenMethod
What to do when a file with the same name already exists.
Base class for exceptions in Fawkes.