Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/fsize is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_fsize
0005 #define tools_fsize
0006 
0007 #include <string>
0008 #include <cstdio>
0009 
0010 namespace tools {
0011 namespace file {
0012 
0013 inline bool size(const std::string& a_file,long& a_size){
0014   FILE* file = ::fopen(a_file.c_str(),"rb");
0015   if(!file) {
0016     a_size = 0L;
0017     return false;
0018   }
0019   //::rewind(file);
0020   ::fseek(file,0L,SEEK_END);
0021   a_size = ::ftell(file);
0022   ::fclose(file);
0023   return true;
0024 }
0025 
0026 inline bool is_empty(const std::string& a_file){
0027   long sz;
0028   if(!size(a_file,sz)) return true; //if not existing, consider it empty.
0029   return (sz==0L)?true:false;
0030 }
0031 
0032 }}
0033 
0034 #endif