#include <fileio.h>
|
| static FILE * | OpenOrDie (const std::string &filename, const std::string &mode) |
| |
| static FILE * | Open (const std::string &filename, const std::string &mode) |
| |
| static void | WriteStringToFileOrDie (const std::string &str, const std::string &filename) |
| |
| static bool | Readable (const std::string &filename) |
| |
| static bool | ReadFileToString (const std::string &filename, std::string *out) |
| |
| static std::string | JoinPath (const std::string &prefix, const std::string &suffix) |
| |
| static bool | Delete (const char *pathname) |
| |
| static bool | DeleteMatchingFiles (const char *pattern) |
| |
Definition at line 29 of file fileio.h.
| bool tesseract::File::Delete |
( |
const char * |
pathname | ) |
|
|
static |
Definition at line 89 of file fileio.cpp.
90 #if !defined(_WIN32) || defined(__MINGW32__) 91 const int status = unlink(pathname);
93 const int status = _unlink(pathname);
96 tprintf(
"ERROR: Unable to delete file %s\n", pathname);
DLLSYM void tprintf(const char *format,...)
| bool tesseract::File::DeleteMatchingFiles |
( |
const char * |
pattern | ) |
|
|
static |
Definition at line 117 of file fileio.cpp.
120 bool all_deleted =
true;
121 if (glob(pattern, 0,
nullptr, &pglob) == 0) {
122 for (paths = pglob.gl_pathv; *paths !=
nullptr; paths++) {
static bool Delete(const char *pathname)
| std::string tesseract::File::JoinPath |
( |
const std::string & |
prefix, |
|
|
const std::string & |
suffix |
|
) |
| |
|
static |
Definition at line 83 of file fileio.cpp.
84 return (prefix.empty() || prefix[prefix.size() - 1] ==
'/')
86 : prefix +
"/" + suffix;
| FILE * tesseract::File::Open |
( |
const std::string & |
filename, |
|
|
const std::string & |
mode |
|
) |
| |
|
static |
Definition at line 40 of file fileio.cpp.
41 return fopen(filename.c_str(), mode.c_str());
| FILE * tesseract::File::OpenOrDie |
( |
const std::string & |
filename, |
|
|
const std::string & |
mode |
|
) |
| |
|
static |
Definition at line 44 of file fileio.cpp.
46 FILE* stream = fopen(filename.c_str(), mode.c_str());
47 if (stream ==
nullptr) {
48 tprintf(
"Unable to open '%s' in mode '%s'\n", filename.c_str(),
DLLSYM void tprintf(const char *format,...)
| bool tesseract::File::Readable |
( |
const std::string & |
filename | ) |
|
|
static |
Definition at line 65 of file fileio.cpp.
66 FILE* stream = fopen(filename.c_str(),
"rb");
67 if (stream ==
nullptr) {
| bool tesseract::File::ReadFileToString |
( |
const std::string & |
filename, |
|
|
std::string * |
out |
|
) |
| |
|
static |
Definition at line 74 of file fileio.cpp.
75 FILE* stream =
File::Open(filename.c_str(),
"rb");
76 if (stream ==
nullptr)
return false;
77 InputBuffer in(stream);
80 return in.CloseFile();
static FILE * Open(const std::string &filename, const std::string &mode)
| void tesseract::File::WriteStringToFileOrDie |
( |
const std::string & |
str, |
|
|
const std::string & |
filename |
|
) |
| |
|
static |
Definition at line 54 of file fileio.cpp.
56 FILE* stream = fopen(filename.c_str(),
"wb");
57 if (stream ==
nullptr) {
58 tprintf(
"Unable to open '%s' for writing\n", filename.c_str());
61 fputs(str.c_str(), stream);
DLLSYM void tprintf(const char *format,...)
The documentation for this class was generated from the following files: