FACT++  1.0
int64_t DimWriteStatistics::GetFileSizeOnDisk ( const std::string &  file,
MessageImp log 
)
static

Returns the size on disk of a given file.

Retrieves the size on disk of a given file, in bytes

Parameters
filethe filename for which the size should be retrieved
Returns
the size of the file, in bytes

Definition at line 81 of file DimWriteStatistics.cc.

References MessageImp::Error(), and str.

82 {
83  errno = 0;
84  struct stat st;
85  if (!stat(file.c_str(), &st))
86  return st.st_size;
87 
88  //ignoring error #2: no such file or directory is not an error for new files
89  if (errno == 0 || errno == 2)
90  return 0;
91 
92  ostringstream str;
93  str << "stat() failed for '" << file << "': " << strerror(errno) << " [errno=" << errno << "]";
94  log.Error(str);
95 
96  return -1;
97 }
char str[80]
Definition: test_client.c:7
int Error(const std::string &str)
Definition: MessageImp.h:49

+ Here is the call graph for this function: