@@ -259,38 +259,48 @@ COMPV_IMAGE_FORMAT CompVFileUtils::getImageFormat(const char* pcPath)
259259 }
260260}
261261
262- COMPV_ERROR_CODE CompVFileUtils::read (const char * pcPath, CompVBufferPtrPtr buffer)
262+ COMPV_ERROR_CODE CompVFileUtils::read (const char * pcPath, CompVBufferPtrPtr buffer, bool quiet COMPV_DEFAULT ( false ) )
263263{
264264 COMPV_CHECK_EXP_RETURN (!pcPath || !buffer, COMPV_ERROR_CODE_E_INVALID_PARAMETER);
265265 CompVBufferPtr buffer_ = NULL ;
266266 size_t size_ = CompVFileUtils::getSize (pcPath);
267267if (!size_) {
268- COMPV_DEBUG_ERROR_EX (kModuleNameFileUtils , " File at %s is empty or doesn't exist" , pcPath);
268+ if (!quiet) {
269+ COMPV_DEBUG_ERROR_EX (kModuleNameFileUtils , " File at %s is empty or doesn't exist" , pcPath);
270+ }
269271return COMPV_ERROR_CODE_E_FAILED_TO_READ_FILE;
270272}
271273else {
272274 FILE* file_ = nullptr ;
273275 void * mem_ = nullptr ;
274276 if (!(file_ = CompVFileUtils::open (pcPath, " rb" ))) {
275- COMPV_DEBUG_ERROR_EX (kModuleNameFileUtils , " Can't open %s" , pcPath);
277+ if (!quiet) {
278+ COMPV_DEBUG_ERROR_EX (kModuleNameFileUtils , " Can't open %s" , pcPath);
279+ }
276280 return COMPV_ERROR_CODE_E_FILE_NOT_FOUND;
277281 }
278282 mem_ = CompVMem::malloc (size_ + 1 );
279283 if (!mem_) {
280- COMPV_DEBUG_ERROR_EX (kModuleNameFileUtils , " Failed to alloc mem with size = %zu" , size_);
284+ if (!quiet) {
285+ COMPV_DEBUG_ERROR_EX (kModuleNameFileUtils , " Failed to alloc mem with size = %zu" , size_);
286+ }
281287 fclose (file_);
282288 return COMPV_ERROR_CODE_E_OUT_OF_MEMORY;
283289 }
284290 size_t read_;
285291 if (size_ != (read_ = fread (mem_, 1 , size_, file_))) {
286- COMPV_DEBUG_ERROR_EX (kModuleNameFileUtils , " fread(%s) returned %zu instead of %zu" , pcPath, read_, size_);
292+ if (!quiet) {
293+ COMPV_DEBUG_ERROR_EX (kModuleNameFileUtils , " fread(%s) returned %zu instead of %zu" , pcPath, read_, size_);
294+ }
287295 fclose (file_);
288296 CompVMem::free (&mem_);
289297 return COMPV_ERROR_CODE_E_FAILED_TO_READ_FILE;
290298 }
291299*(reinterpret_cast <char *>(mem_) + size_) = ' \0 ' ; // !\ required when reading sources to avoid garbage (e.g OpenCL source *.cl)
292300 if (COMPV_ERROR_CODE_IS_NOK (CompVBuffer::newObjAndTakeData (&mem_, size_, &buffer_))) {
293- COMPV_DEBUG_ERROR_EX (kModuleNameFileUtils , " Failed to create new CompVBuffer object" );
301+ if (!quiet) {
302+ COMPV_DEBUG_ERROR_EX (kModuleNameFileUtils , " Failed to create new CompVBuffer object" );
303+ }
294304 }
295305 fclose (file_);
296306 CompVMem::free (&mem_);
0 commit comments