Lines Matching refs:filename

57 bool WasFileCorrectlyRead(FILE* file, const char* filename) {
59 fprintf(stderr, "error: file does not exist '%s'\n", filename);
65 fprintf(stderr, "error: error reading file '%s'\n", filename);
73 sizeof(T), filename);
80 // Appends the contents of the file named |filename| to |data|, assuming
82 // If |filename| is nullptr or "-", reads from the standard input, but
86 bool ReadBinaryFile(const char* filename, std::vector<T>* data) {
87 const bool use_file = filename && strcmp("-", filename);
90 fp = fopen(filename, "rb");
97 bool succeeded = WasFileCorrectlyRead<T>(fp, filename);
102 // Appends the contents of the file named |filename| to |data|, assuming
104 // If |filename| is nullptr or "-", reads from the standard input, but
108 bool ReadTextFile(const char* filename, std::vector<T>* data) {
109 const bool use_file = filename && strcmp("-", filename);
112 fp = fopen(filename, "r");
119 bool succeeded = WasFileCorrectlyRead<T>(fp, filename);
128 // Opens |filename| in the given mode. If |filename| is nullptr, the empty
130 OutputFile(const char* filename, const char* mode) : old_mode_(0) {
132 !filename || (filename[0] == '-' && filename[1] == '\0');
141 fp_ = fopen(filename, mode);
163 // Writes the given |data| into the file named as |filename| using the given
165 // |filename| is nullptr or "-", writes to standard output. If any error occurs,
168 bool WriteFile(const char* filename, const char* mode, const T* data,
170 OutputFile file(filename, mode);
173 fprintf(stderr, "error: could not open file '%s'\n", filename);
179 fprintf(stderr, "error: could not write to file '%s'\n", filename);