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 
61  bool FileCreate(const std::string& filename, const std::string& data, uid_t uid=0, gid_t gid=0, mode_t mode = 0);
62 
64  bool FileStat(const std::string& path,struct stat *st,bool follow_symlinks);
65 
67 
68  bool FileStat(const std::string& path,struct stat *st,uid_t uid,gid_t gid,bool follow_symlinks);
69 
71  bool FileLink(const std::string& oldpath,const std::string& newpath, bool symbolic);
72 
74 
75  bool FileLink(const std::string& oldpath,const std::string& newpath,uid_t uid,gid_t gid,bool symbolic);
76 
78  std::string FileReadLink(const std::string& path);
79 
81 
82  std::string FileReadLink(const std::string& path,uid_t uid,gid_t gid);
83 
85  bool FileDelete(const std::string& path);
86 
88 
89  bool FileDelete(const std::string& path,uid_t uid,gid_t gid);
90 
92  bool DirCreate(const std::string& path,mode_t mode,bool with_parents = false);
93 
95 
96  bool DirCreate(const std::string& path,uid_t uid,gid_t gid,mode_t mode,bool with_parents = false);
97 
99 
100  bool DirDelete(const std::string& path, bool recursive = true);
101 
103 
105  bool DirDelete(const std::string& path, bool recursive, uid_t uid, gid_t gid);
106 
108 
110  bool TmpDirCreate(std::string& path);
111 
113 
123  bool TmpFileCreate(std::string& filename, const std::string& data, uid_t uid=0, gid_t gid=0, mode_t mode = 0);
124 
126 
130  bool CanonicalDir(std::string& name, bool leading_slash = true);
131 
133 } // namespace Arc
134