ARC SDK
FileUtils.h
1 #include <glibmm.h>
2 
3 #include <arc/Thread.h>
4 
5 #ifdef WIN32
6 #ifndef uid_t
7 #define uid_t int
8 #endif
9 #ifndef gid_t
10 #define gid_t int
11 #endif
12 #endif
13 
14 namespace Arc {
15 
16  // Utility functions for handling files and directories.
17  // These functions offer possibility to access files and directories
18  // under user and group ids different from those of current user.
19  // Id switching is done in a safe way for multi-threaded applications.
20  // If any of specified ids is 0 then such id is not switched and
21  // current id is used instead.
22 
26 
27 
28  bool FileCopy(const std::string& source_path,const std::string& destination_path, uid_t uid, gid_t gid);
29 
31  bool FileCopy(const std::string& source_path,const std::string& destination_path);
32 
34  bool FileCopy(const std::string& source_path,int destination_handle);
35 
37  bool FileCopy(int source_handle,const std::string& destination_path);
38 
40  bool FileCopy(int source_handle,int destination_handle);
41 
43 
47  bool FileRead(const std::string& filename, std::list<std::string>& data, uid_t uid=0, gid_t gid=0);
48 
50 
51  bool FileRead(const std::string& filename, std::string& data, uid_t uid=0, gid_t gid=0);
52 
54 
59  bool FileCreate(const std::string& filename, const std::string& data, uid_t uid=0, gid_t gid=0, mode_t mode = 0);
60 
62  bool FileStat(const std::string& path,struct stat *st,bool follow_symlinks);
63 
65 
66  bool FileStat(const std::string& path,struct stat *st,uid_t uid,gid_t gid,bool follow_symlinks);
67 
69  bool FileLink(const std::string& oldpath,const std::string& newpath, bool symbolic);
70 
72 
73  bool FileLink(const std::string& oldpath,const std::string& newpath,uid_t uid,gid_t gid,bool symbolic);
74 
76  std::string FileReadLink(const std::string& path);
77 
79 
80  std::string FileReadLink(const std::string& path,uid_t uid,gid_t gid);
81 
83  bool FileDelete(const std::string& path);
84 
86 
87  bool FileDelete(const std::string& path,uid_t uid,gid_t gid);
88 
90  bool DirCreate(const std::string& path,mode_t mode,bool with_parents = false);
91 
93 
94  bool DirCreate(const std::string& path,uid_t uid,gid_t gid,mode_t mode,bool with_parents = false);
95 
97 
98  bool DirDelete(const std::string& path, bool recursive = true);
99 
101 
103  bool DirDelete(const std::string& path, bool recursive, uid_t uid, gid_t gid);
104 
106 
108  bool TmpDirCreate(std::string& path);
109 
111 
116  bool TmpFileCreate(std::string& filename, const std::string& data, uid_t uid=0, gid_t gid=0, mode_t mode = 0);
117 
119 
123  bool CanonicalDir(std::string& name, bool leading_slash = true);
124 
126 } // namespace Arc
127