comparison Core/SystemToolbox.cpp @ 3524:d96379a965de

merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 24 Sep 2019 18:06:56 +0200
parents 793c141be598
children 94f4a18a79cc
comparison
equal deleted inserted replaced
3523:c8e706b519cd 3524:d96379a965de
210 return size; 210 return size;
211 } 211 }
212 212
213 213
214 void SystemToolbox::ReadFile(std::string& content, 214 void SystemToolbox::ReadFile(std::string& content,
215 const std::string& path) 215 const std::string& path,
216 bool log)
216 { 217 {
217 if (!IsRegularFile(path)) 218 if (!IsRegularFile(path))
218 { 219 {
219 throw OrthancException(ErrorCode_RegularFileExpected, 220 throw OrthancException(ErrorCode_RegularFileExpected,
220 "The path does not point to a regular file: " + path); 221 "The path does not point to a regular file: " + path,
222 log);
221 } 223 }
222 224
223 boost::filesystem::ifstream f; 225 boost::filesystem::ifstream f;
224 f.open(path, std::ifstream::in | std::ifstream::binary); 226 f.open(path, std::ifstream::in | std::ifstream::binary);
225 if (!f.good()) 227 if (!f.good())
226 { 228 {
227 throw OrthancException(ErrorCode_InexistentFile); 229 throw OrthancException(ErrorCode_InexistentFile,
230 "File not found: " + path,
231 log);
228 } 232 }
229 233
230 std::streamsize size = GetStreamSize(f); 234 std::streamsize size = GetStreamSize(f);
231 content.resize(static_cast<size_t>(size)); 235 content.resize(static_cast<size_t>(size));
232 if (size != 0) 236 if (size != 0)