#include <fileio.h>
List of all members.
Detailed Description
Definition at line 31 of file fileio.h.
Member Function Documentation
| bool tesseract::File::Delete |
( |
const char * |
pathname | ) |
[static] |
Definition at line 94 of file fileio.cpp.
{
const int status = unlink(pathname);
if (status != 0) {
tprintf("ERROR: Unable to delete file %s\n", pathname);
return false;
}
return true;
}
| bool tesseract::File::DeleteMatchingFiles |
( |
const char * |
pattern | ) |
[static] |
Definition at line 118 of file fileio.cpp.
{
glob_t pglob;
char **paths;
bool all_deleted = true;
if (glob(pattern, 0, NULL, &pglob) == 0) {
for (paths = pglob.gl_pathv; *paths != NULL; paths++) {
all_deleted &= File::Delete(*paths);
}
globfree(&pglob);
}
return all_deleted;
}
| string tesseract::File::JoinPath |
( |
const string & |
prefix, |
|
|
const string & |
suffix |
|
) |
| [static] |
Definition at line 89 of file fileio.cpp.
{
return (!prefix.size() || prefix[prefix.size() - 1] == '/') ?
prefix + suffix : prefix + "/" + suffix;
}
| FILE * tesseract::File::Open |
( |
const string & |
filename, |
|
|
const string & |
mode |
|
) |
| [static] |
| FILE * tesseract::File::OpenOrDie |
( |
const string & |
filename, |
|
|
const string & |
mode |
|
) |
| [static] |
Definition at line 43 of file fileio.cpp.
{
FILE* stream = fopen(filename.c_str(), mode.c_str());
if (stream == NULL) {
tprintf("Unable to open '%s' in mode '%s'\n", filename.c_str(),
mode.c_str());
}
return stream;
}
| bool tesseract::File::Readable |
( |
const string & |
filename | ) |
[static] |
Definition at line 64 of file fileio.cpp.
{
FILE* stream = fopen(filename.c_str(), "rb");
if (stream == NULL) {
return false;
}
fclose(stream);
return true;
}
| bool tesseract::File::ReadFileToString |
( |
const string & |
filename, |
|
|
string * |
out |
|
) |
| [static] |
Definition at line 73 of file fileio.cpp.
{
FILE* stream = File::Open(filename.c_str(), "rb");
if (stream == NULL)
return false;
InputBuffer in(stream);
*out = "";
in.Read(out);
return in.CloseFile();
}
| void tesseract::File::ReadFileToStringOrDie |
( |
const string & |
filename, |
|
|
string * |
out |
|
) |
| [static] |
| void tesseract::File::WriteStringToFileOrDie |
( |
const string & |
str, |
|
|
const string & |
filename |
|
) |
| [static] |
Definition at line 53 of file fileio.cpp.
{
FILE* stream = fopen(filename.c_str(), "wb");
if (stream == NULL) {
tprintf("Unable to open '%s' for writing\n", filename.c_str());
return;
}
fputs(str.c_str(), stream);
ASSERT_HOST(fclose(stream) == 0);
}
The documentation for this class was generated from the following files: