All Classes Namespaces Functions Variables Enumerations Enumerator Pages
filesystem.h
1 /*
2  Copyright (c) 2014 by Elvis Angelaccio
3 
4  Permission is hereby granted, free of charge, to any person obtaining a copy
5  of this software and associated documentation files (the "Software"), to deal
6  in the Software without restriction, including without limitation the rights
7  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  copies of the Software, and to permit persons to whom the Software is
9  furnished to do so, subject to the following conditions:
10 
11  The above copyright notice and this permission notice shall be included in
12  all copies or substantial portions of the Software.
13 
14  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  THE SOFTWARE.
21 */
22 
23 #ifndef FILESYSTEM_H
24 #define FILESYSTEM_H
25 
26 #include <string>
27 #include <vector>
28 #include <stdexcept>
29 
31 namespace filesystem
32 {
33  static const int MAX_PATH_SIZE = 2048;
39  bool existFile(const std::string& path);
40 
45  bool existDirectory(const std::string& path);
46 
52  bool existDirectory(const std::string& parentDirectory, const std::string& name);
53 
59  void listDirectory(const std::string& path, std::vector<std::string>& entries);
60 
65  void createDirectory(const std::string& path);
66 
72  void createDirectory(const std::string& parentDirectory, const std::string& name);
73 
78  void removeDirectory(const std::string& path);
79 
84  void renameDirectory(const std::string& path, const std::string& newPath);
85 
91  long long getFileSize(const std::string& path);
92 
97  std::string getCurrentDirectory();
98 
103  bool isAbsolutePath(const std::string& path);
104 
108  class FileSystemError : public std::runtime_error
109  {
110  public:
111  FileSystemError(const std::string& msg) : std::runtime_error(msg) {}
112  };
113 
114 }
115 
116 
117 #endif
void renameDirectory(const std::string &path, const std::string &newPath)
bool isAbsolutePath(const std::string &path)
Definition: filesystem.cpp:200
void createDirectory(const std::string &path)
void listDirectory(const std::string &path, std::vector< std::string > &entries)
std::string getCurrentDirectory()
Definition: filesystem.cpp:151
long long getFileSize(const std::string &path)
bool existDirectory(const std::string &path)
bool existFile(const std::string &path)
Definition: filesystem.h:108
void removeDirectory(const std::string &path)