guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
gfile.hpp
1 //
2 // Files and file paths
3 // Guit GUI Toolkit
4 // Copyright © 2019/2020 Eric Lecolinet. All rights reserved.
5 // http://www.telecom-paris.fr/~elc
6 //
7 
8 #ifndef Guit_File_hpp
9 #define Guit_File_hpp
10 #include <fstream>
11 #include <gstring.hpp>
12 namespace guit {
13 
19 bool openFile(std::ifstream&, GString const& path, const char* locale = nullptr);
20 
24 bool openFile(std::ofstream&, GString const& path, const char* locale = nullptr);
25 
26 
28 class GIFile : public std::ifstream {
29 public:
30  GIFile(GString const& path, const char* locale = {}) {
31  openFile(*this, path, locale);
32  }
33 };
34 
36 class GOFile : public std::ofstream {
37 public:
38  GOFile(GString const& path, const char* locale = {}) {
39  openFile(*this, path, locale);
40  }
41 };
42 
49 GString normPath(GString const& path, bool add_slash = false);
50 
53 bool fileExist(GString const& path);
54 
57 bool copyFile(GString const& from_file, GString const& to_file);
58 
60 int system(GString const& command);
61 
63 bool makeDir(GString const& path);
64 
66 GString parentPath(GString const& path);
67 
70 GString basename(GString const& path, bool with_extension = true);
71 
73 GString dirname(GString const& path);
74 
77 GString extname(GString const& path, bool with_dot = true);
78 
79 }
80 #endif