PhoenixMock  1.8.7
Tools to split/merge/print mock used in Phoenix
phoenix_getFileSize.cpp
Go to the documentation of this file.
1 /***************************************
2  Auteur : Pierre Aubert
3  Mail : pierre.aubert@lapp.in2p3.fr
4  Licence : CeCILL-C
5 ****************************************/
6 
7 #include <iostream>
8 #include "phoenix_getFileSize.h"
9 
11 
14 size_t phoenix_getFileSize(FILE* fs){
15  //Then the number of compressed bytes
16  //Get and save the number of bytes of the compressed file
17  fseek(fs, 0, SEEK_END);
18  size_t fileSize(ftell(fs));
19  fseek(fs, 0, SEEK_SET);
20  return fileSize;
21 }
22 
24 
27 size_t phoenix_getFileSize(const std::string & fileName){
28  FILE* compressedFs = fopen(fileName.c_str(), "r");
29  if(compressedFs == NULL){
30  return 0lu;
31  }
32  size_t fileSize(phoenix_getFileSize(compressedFs));
33  fclose(compressedFs);
34  return fileSize;
35 }
36 
37 
38 
39 
phoenix_getFileSize
size_t phoenix_getFileSize(FILE *fs)
Get the size of the given file in bytes.
Definition: phoenix_getFileSize.cpp:14
phoenix_getFileSize.h