1 ////////////////////////////////////////////////////////////////////////////////
3 // Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez.
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
12 // The above copyright notice and this permission notice shall be included
13 // in all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 // http://www.opensource.org/licenses/mit-license.php
25 ////////////////////////////////////////////////////////////////////////////////
43 explicit Path (const Path&);
44 Path (const std::string&);
46 Path& operator= (const Path&);
47 bool operator== (const Path&);
48 Path& operator+= (const std::string&);
49 operator std::string () const;
51 std::string name () const;
52 std::string parent () const;
53 std::string extension () const;
55 bool is_directory () const;
56 bool is_absolute () const;
57 bool is_link () const;
58 bool readable () const;
59 bool writable () const;
60 bool executable () const;
61 bool rename (const std::string&);
64 static std::string expand (const std::string&);
65 static std::vector<std::string> glob (const std::string&);
68 std::string _original;
72 class File : public Path
76 explicit File (const Path&);
77 explicit File (const File&);
78 File (const std::string&);
81 File& operator= (const File&);
83 virtual bool create (int mode = 0640);
84 virtual bool remove () const;
92 void read (std::string&);
93 void read (std::vector <std::string>&);
95 void append (const std::string&);
96 void append (const std::vector <std::string>&);
97 void write_raw (const std::string&);
101 virtual mode_t mode ();
102 virtual size_t size () const;
103 virtual time_t mtime () const;
104 virtual time_t ctime () const;
105 virtual time_t btime () const;
107 static bool create (const std::string&, int mode = 0640);
108 static bool read (const std::string&, std::string&);
109 static bool read (const std::string&, std::vector <std::string>&);
110 static bool write (const std::string&, const std::string&);
111 static bool write (const std::string&, const std::vector <std::string>&, bool addNewlines = true);
112 static bool remove (const std::string&);
113 static bool copy (const std::string&, const std::string&);
114 static bool move (const std::string&, const std::string&);
115 static std::string removeBOM (const std::string&);
123 class Directory : public File
127 explicit Directory (const Directory&);
128 explicit Directory (const File&);
129 explicit Directory (const Path&);
130 Directory (const std::string&);
132 Directory& operator= (const Directory&);
134 virtual bool create (int mode = 0755);
135 virtual bool remove () const;
137 std::vector <std::string> list ();
138 std::vector <std::string> listRecursive ();
140 static std::string cwd ();
145 void list (const std::string&, std::vector <std::string>&, bool);
146 bool remove_directory (const std::string&) const;