StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StHyperUtilFilesystem.h
1 // StHyperUtilFilesystem.h
2 #ifndef __ST_HYPERUTILFILESYSTEM_H
3 #define __ST_HYPERUTILFILESYSTEM_H
4 
5 #include <string>
6 #include <fstream>
7 
8 namespace StHyperUtilFilesystem
9 {
10 
11 // calculate free space percentage from path (/tmp, /scratch etc)
12 double get_free_space_percentage(const char* path, size_t& bytes_free, size_t& bytes_total);
13 
14 // delete files using FIFO or LRU policy
15 bool remove_dir_fifo(std::string unlink_path, const std::string& base_path, double bytes_free);
16 bool remove_dir_lru(std::string unlink_path, const std::string& base_path, double bytes_free);
17 
18 // check if file exists on disk
19 bool path_exists (const std::string& file);
20 
21 // converts relative path to full path
22 std::string resolve_path(const std::string& path);
23 
24 void create_dir_recursive(std::string path);
25 
26 // unlink path, constrained by base_path so no tricks with relative paths will work
27 unsigned long remove_dir_recursive(std::string unlink_path, const std::string& base_path);
28 
29 // get file size in bytes
30 std::ifstream::pos_type filesize(const char* filename);
31 
32 } // namespace StHyperUtilFilesystem
33 
34 #endif // __ST_HYPERUTILFILESYSTEM_H