Lines Matching refs:filename

37 bool FileExists(char const* filename) {  in FileExists()  argument
39 if (!filename || !filename[0]) { in FileExists()
42 fp = fopen(filename, "rb"); in FileExists()
50 size_t GetFileSize(char const* filename) { in GetFileSize() argument
52 FILE* fp = fopen(filename, "rb"); in GetFileSize()
61 size_t GetFileSize_S(char const* filename, size_t max_size) { in GetFileSize_S() argument
62 size_t size = GetFileSize(filename); in GetFileSize_S()
81 void* NewBufferFromFile(const char* filename, size_t* size) { in NewBufferFromFile() argument
87 if (!FileExists(filename)) { in NewBufferFromFile()
88 log_error("cannot access '%s'", filename); in NewBufferFromFile()
92 len = GetFileSize_S(filename, SIZE_MAX); in NewBufferFromFile()
94 log_error("cannot load empty file '%s'", filename); in NewBufferFromFile()
101 if (0 != ReadLoud(filename, buffer, len)) { in NewBufferFromFile()
115 int ReadBufferFromFile(const char* filename, void* buffer, size_t size) { in ReadBufferFromFile() argument
121 file = fopen(filename, "rb"); in ReadBufferFromFile()
150 int WriteBufferToFile(const void* buffer, size_t size, const char* filename) { in WriteBufferToFile() argument
156 file = fopen(filename, "wb"); in WriteBufferToFile()
175 int ReadLoud(char const* filename, void* buf, size_t size) { in ReadLoud() argument
184 log_msg("reading %s", filename); in ReadLoud()
187 if (!FileExists(filename)) { in ReadLoud()
188 log_error("cannot access '%s' for reading", filename); in ReadLoud()
192 if (size != GetFileSize(filename)) { in ReadLoud()
193 log_error("unexpected file size for '%s'. Expected: %d; got: %d", filename, in ReadLoud()
194 (int)size, (int)GetFileSize(filename)); in ReadLoud()
198 result = ReadBufferFromFile(filename, buf, size); in ReadLoud()
200 log_error("failed to read from `%s`", filename); in ReadLoud()
211 int WriteLoud(void* buf, size_t size, char const* filename) { in WriteLoud() argument
220 log_msg("writing %s", filename); in WriteLoud()
223 result = WriteBufferToFile(buf, size, filename); in WriteLoud()
226 log_error("failed to write to `%s`", filename); in WriteLoud()