#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 57 of file fileio.h.
◆ Delete()
bool tesseract::File::Delete |
( |
const char * |
pathname | ) |
|
|
static |
Definition at line 106 of file fileio.cpp.
108 WIN32_FIND_DATA data;
110 HANDLE handle = FindFirstFile(pattern, &data);
111 bool all_deleted =
true;
112 if (handle != INVALID_HANDLE_VALUE) {
113 for (; result; result = FindNextFile(handle, &data)) {
◆ DeleteMatchingFiles()
bool tesseract::File::DeleteMatchingFiles |
( |
const char * |
pattern | ) |
|
|
static |
◆ JoinPath()
std::string tesseract::File::JoinPath |
( |
const std::string & |
prefix, |
|
|
const std::string & |
suffix |
|
) |
| |
|
static |
◆ Open()
FILE * tesseract::File::Open |
( |
const std::string & |
filename, |
|
|
const std::string & |
mode |
|
) |
| |
|
static |
Definition at line 56 of file fileio.cpp.
58 FILE* stream = fopen(filename.c_str(),
"wb");
◆ OpenOrDie()
FILE * tesseract::File::OpenOrDie |
( |
const std::string & |
filename, |
|
|
const std::string & |
mode |
|
) |
| |
|
static |
Definition at line 60 of file fileio.cpp.
61 filename.c_str(), strerror(errno));
64 fputs(str.c_str(), stream);
65 ASSERT_HOST(fclose(stream) == 0);
68 bool File::Readable(const std::string& filename) {
◆ Readable()
bool tesseract::File::Readable |
( |
const std::string & |
filename | ) |
|
|
static |
Definition at line 82 of file fileio.cpp.
87 return (prefix.empty() || prefix[prefix.size() - 1] ==
'/')
89 : prefix +
"/" + suffix;
◆ ReadFileToString()
bool tesseract::File::ReadFileToString |
( |
const std::string & |
filename, |
|
|
std::string * |
out |
|
) |
| |
|
static |
Definition at line 91 of file fileio.cpp.
93 #if !defined(_WIN32) || defined(__MINGW32__)
94 const int status = unlink(pathname);
96 const int status = _unlink(pathname);
◆ WriteStringToFileOrDie()
void tesseract::File::WriteStringToFileOrDie |
( |
const std::string & |
str, |
|
|
const std::string & |
filename |
|
) |
| |
|
static |
Definition at line 70 of file fileio.cpp.
78 FILE* stream =
File::Open(filename.c_str(),
"rb");
79 if (stream ==
nullptr)
return false;
80 InputBuffer in(stream);
The documentation for this class was generated from the following files: