00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __libutilxx__sella__util__File_H__
00010 #define __libutilxx__sella__util__File_H__
00011
00012 #include "../../common.h"
00013 #include "FileException.h"
00014
00015 #include <limits.h>
00016 #include <stdlib.h>
00017 #include <sys/types.h>
00018 #include <sys/stat.h>
00019 #include <unistd.h>
00020
00021 #include <sys/types.h>
00022 #include <sys/stat.h>
00023 #include <time.h>
00024 #include <stdio.h>
00025 #include <stdlib.h>
00026
00027 #include <string>
00028
00029 namespace sella {
00030 namespace util {
00031 class File;
00032 }
00033 }
00034
00035 class sella::util::File {
00036 public:
00037 static std::string getBaseName(const std::string &path) throw ();
00038 static std::string getDirName(const std::string &path) throw ();
00039 static std::string getRealPath(const std::string &path) throw (FileException);
00040
00041 static bool exists(const std::string &fullpath, bool followSymlink = true) throw ();
00042 static bool isRegularFile(const std::string &fullpath, bool followSymlink = true) throw (FileException);
00043 static bool isDirectory(const std::string &fullpath, bool followSymlink = true) throw (FileException);
00044 static bool isCharacterDevice(const std::string &fullpath, bool followSymlink = true) throw (FileException);
00045 static bool isBlockDevice(const std::string &fullpath, bool followSymlink = true) throw (FileException);
00046 static bool isFIFO(const std::string &fullpath, bool followSymlink = true) throw (FileException);
00047 static bool isSymLink(const std::string &fullpath) throw (FileException);
00048 static bool isSocket(const std::string &fullpath, bool followSymlink = true) throw (FileException);
00049
00050 static uid_t getUID(const std::string &fullpath, bool followSymlink = true) throw (FileException);
00051 static gid_t getGID(const std::string &fullpath, bool followSymlink = true) throw (FileException);
00052 static int64_t getSize(const std::string &fullpath, bool followSymlink = true) throw (FileException);
00053 static int64_t getBlocks(const std::string &fullpath, bool followSymlink = true) throw (FileException);
00054 static int64_t getBlockSize(const std::string &fullpath, bool followSymlink = true) throw (FileException);
00055 static time_t getATime(const std::string &fullpath, bool followSymlink = true) throw (FileException);
00056 static time_t getMTime(const std::string &fullpath, bool followSymlink = true) throw (FileException);
00057 static time_t getCTime(const std::string &fullpath, bool followSymlink = true) throw (FileException);
00058
00059 private:
00060 static struct stat getStat(const std::string &fullpath, bool followSymlink = true) throw (FileException);
00061 static int getMode(const std::string &fullpath, bool followSymlink = true) throw (FileException);
00062 };
00063
00064 #endif
00065
00066
00067
00068