00001 #ifndef __ARC_FILEACCESS_H__
00002 #define __ARC_FILEACCESS_H__
00003
00004 #include <string>
00005
00006 #include <sys/stat.h>
00007 #include <sys/types.h>
00008
00009 #include <glibmm.h>
00010
00011 #ifdef WIN32
00012 #ifndef uid_t
00013 #define uid_t int
00014 #endif
00015 #ifndef gid_t
00016 #define gid_t int
00017 #endif
00018 #endif
00019
00020 namespace Arc {
00021
00022 class Run;
00023
00025
00030 class FileAccess {
00031 public:
00032 FileAccess(void);
00033 ~FileAccess(void);
00035 bool ping(void);
00038 bool setuid(int uid,int gid);
00040 bool mkdir(const std::string& path, mode_t mode);
00043 bool mkdirp(const std::string& path, mode_t mode);
00045 bool link(const std::string& oldpath, const std::string& newpath);
00047 bool softlink(const std::string& oldpath, const std::string& newpath);
00050 bool copy(const std::string& oldpath, const std::string& newpath, mode_t mode);
00052 bool chmod(const std::string& path,mode_t mode);
00054 bool stat(const std::string& path, struct stat& st);
00056 bool lstat(const std::string& path, struct stat& st);
00058 bool fstat(struct stat& st);
00060 bool ftruncate(off_t length);
00062 off_t fallocate(off_t length);
00064 bool readlink(const std::string& path, std::string& linkpath);
00066 bool remove(const std::string& path);
00068 bool unlink(const std::string& path);
00070 bool rmdir(const std::string& path);
00072 bool rmdirr(const std::string& path);
00075 bool opendir(const std::string& path);
00077 bool closedir(void);
00079 bool readdir(std::string& name);
00082 bool open(const std::string& path, int flags, mode_t mode);
00084 bool close(void);
00088 bool mkstemp(std::string& path, mode_t mode);
00090 off_t lseek(off_t offset, int whence);
00092 ssize_t read(void* buf,size_t size);
00094 ssize_t write(const void* buf,size_t size);
00096 ssize_t pread(void* buf,size_t size,off_t offset);
00098 ssize_t pwrite(const void* buf,size_t size,off_t offset);
00101 int geterrno() { return errno_; };
00103 operator bool(void) { return (file_access_ != NULL); };
00105 bool operator!(void) { return (file_access_ == NULL); };
00107 static void testtune(void);
00108 private:
00109 Glib::Mutex lock_;
00110 Run* file_access_;
00111 int errno_;
00112 uid_t uid_;
00113 gid_t gid_;
00114 public:
00115 typedef struct {
00116 unsigned int size;
00117 unsigned int cmd;
00118 } header_t;
00119 };
00120
00121 }
00122
00123 #endif // __ARC_FILEACCESS_H__
00124