]> pilppa.org Git - libplp.git/blob - src/FileUtil.hh
api fixes and cleanups
[libplp.git] / src / FileUtil.hh
1 /*
2  * FileUtil.hh
3  *
4  *  Created on: Mar 5, 2011
5  *      Author: lamikr
6  */
7
8 #ifndef FILEUTIL_HH_
9 #define FILEUTIL_HH_
10
11 #include <string>
12 #include <vector>
13
14 #include <dirent.h>
15
16 namespace plp {
17         class FileUtil {
18                 public:
19                         FileUtil();
20                         virtual ~FileUtil();
21                         static std::string concat_paths(std::string path_start, std::string path_end);
22                         static std::string concat_paths(const char *path_start, const char *path_end);
23                         static bool is_subdirectory(const char *path, dirent *direntry);
24                         static bool is_datafile(const char *path, dirent *direntry);
25                         static std::vector<std::string> get_subdirectories(const std::string& path);
26                         static std::vector<std::string> get_data_files(const std::string& path);
27                         static std::string parse_directory_path(const char *file_name_with_path);
28                         static bool mkdirs(const char *path);
29                         /*
30                          * Creates file to given path by first checking whether
31                          * the directories exist and have enough permissions.
32                          */
33                         static bool mkfile(const char *file_name_with_path, bool writable);
34                         /*
35                          * Check whether file exist with specified access rights
36                          */
37                         static bool file_exist(const char *file_name_with_path, bool writable);
38                         static std::ofstream *open_for_writing(const char *path);
39         };
40 }
41
42 #endif /* FILEUTIL_HH_ */