16#ifndef TESSERACT_TRAINING_FILEIO_H_
17#define TESSERACT_TRAINING_FILEIO_H_
33 std::vector<char> data;
38 std::string lines_str(&data[0], data.size());
39 *lines =
split(lines_str,
'\n');
44class TESS_UNICHARSET_TRAINING_API
File {
48 static FILE *OpenOrDie(
const std::string &filename,
const std::string &mode);
49 static FILE *Open(
const std::string &filename,
const std::string &mode);
53 static void WriteStringToFileOrDie(
const std::string &str,
const std::string &filename);
56 static bool Readable(
const std::string &filename);
58 static bool ReadFileToString(
const std::string &filename, std::string *out);
63 static std::string JoinPath(
const std::string &prefix,
const std::string &suffix);
65 static bool Delete(
const char *pathname);
66 static bool DeleteMatchingFiles(
const char *pattern);
81 bool Read(std::string *out);
101 void WriteString(
const std::string &str);
const std::vector< std::string > split(const std::string &s, char c)
bool LoadFileLinesToStrings(const char *filename, std::vector< std::string > *lines)
bool LoadDataFromFile(const char *filename, GenericVector< char > *data)
int Read(int fd, void *buf, unsigned int count)