Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:43:50

0001 #ifndef FILE_UTILS_H
0002 #define FILE_UTILS_H
0003 
0004 /*!

0005  * @file FileUtils.h

0006  * @author Bryan BERTHOU

0007  * @version 2.0

0008  * @date 28/04/2009

0009  * @date Updated 18/09/2014

0010  */
0011 
0012 #include <fstream> // needed
0013 #include <iostream>
0014 #include <string>
0015 #include <vector>
0016 
0017 //TODO commentaire et documentation

0018 //TODO improve exception, error, function name, ...

0019 
0020 namespace ElemUtils {
0021 
0022 /*!

0023  * @class FileUtils

0024  *

0025  * @brief Handle file system.

0026  */
0027 class FileUtils {
0028 public:
0029 
0030     static bool isReadable(const std::string & filePath);
0031 
0032     /**

0033      * By default open a file in write mode.

0034      * If the file exists, its content is deleted.

0035      *

0036      * @param fileOutputStream

0037      * @param filePath

0038      * @param openMode : by default open in write mode and content is deleted.z

0039      * @return

0040      */
0041     static bool open(std::ofstream &fileOutputStream,
0042             const std::string & filePath,
0043             const std::ios_base::openmode &openMode = std::ios_base::out
0044                     | std::ios_base::trunc);
0045     static void writeAndFlush(std::ofstream & fileOutputStream,
0046             const std::string & str);
0047     static void write(std::ofstream& fileOutputStream, const std::string& str);
0048     static void flush(std::ofstream& fileOutputStream);
0049 
0050     static void close(std::ofstream & fileOutputStream);
0051 
0052 //    static void write(const std::string & filePath, const std::string & str);

0053 //    static void writeLine(const std::string & filePath, const std::string & str);

0054     static std::string read(const std::string & filePath);
0055     static std::vector<std::string> readByLine(const std::string & filePath);
0056     static std::ifstream::pos_type getFileSize(const std::string & filetPath);
0057 
0058     static bool remove(const std::string &filePath);
0059 }
0060 ;
0061 
0062 } // namespace ElemUtils

0063 
0064 #endif /* FILE_UTILS_H */