9 #ifndef __libutilxx__sella__util__File_H__
10 #define __libutilxx__sella__util__File_H__
12 #include "../../common.h"
13 #include "FileException.h"
17 #include <sys/types.h>
21 #include <sys/types.h>
42 static const std::string any;
43 static const std::set<uint8_t> all;
44 static const std::set<uint8_t> regular;
45 static const std::set<uint8_t> files;
46 static const std::set<uint8_t> dirs;
49 static std::string getBaseName(
const std::string &fullpath)
throw ();
50 static std::string getDirName(
const std::string &fullpath)
throw ();
51 static std::string getRealPath(
const std::string &fullpath)
throw (FileException);
53 static std::vector<std::string> getDirectory(
const std::string &path,
const std::string ®ex = any,
const std::set<uint8_t> &types = all)
throw (FileException);
55 static std::string read(
const std::string &fullpath,
size_t limit = 0, std::ios_base::openmode mode = std::ios_base::in)
throw (FileException);
56 static std::string readline(
const std::string &fullpath,
char delim =
'\n', std::ios_base::openmode mode = std::ios_base::in)
throw (FileException);
57 static std::vector<std::string> readlines(
const std::string &fullpath,
size_t limit = 0,
char delim =
'\n', std::ios_base::openmode mode = std::ios_base::in)
throw (FileException);
59 static void write(
const std::string &fullpath,
const std::string &data, std::ios_base::openmode mode = std::ios_base::out)
throw (FileException);
61 static bool exists(
const std::string &fullpath,
bool followSymlink =
true)
throw ();
62 static bool isReadable(
const std::string &fullpath)
throw ();
63 static bool isRegularFile(
const std::string &fullpath,
bool followSymlink =
true)
throw (FileException);
64 static bool isDirectory(
const std::string &fullpath,
bool followSymlink =
true)
throw (FileException);
65 static bool isCharacterDevice(
const std::string &fullpath,
bool followSymlink =
true)
throw (FileException);
66 static bool isBlockDevice(
const std::string &fullpath,
bool followSymlink =
true)
throw (FileException);
67 static bool isFIFO(
const std::string &fullpath,
bool followSymlink =
true)
throw (FileException);
68 static bool isSymLink(
const std::string &fullpath)
throw (FileException);
69 static bool isSocket(
const std::string &fullpath,
bool followSymlink =
true)
throw (FileException);
71 static uid_t getUID(
const std::string &fullpath,
bool followSymlink =
true)
throw (FileException);
72 static gid_t getGID(
const std::string &fullpath,
bool followSymlink =
true)
throw (FileException);
73 static int64_t getSize(
const std::string &fullpath,
bool followSymlink =
true)
throw (FileException);
74 static int64_t getBlocks(
const std::string &fullpath,
bool followSymlink =
true)
throw (FileException);
75 static int64_t getBlockSize(
const std::string &fullpath,
bool followSymlink =
true)
throw (FileException);
76 static time_t getATime(
const std::string &fullpath,
bool followSymlink =
true)
throw (FileException);
77 static time_t getMTime(
const std::string &fullpath,
bool followSymlink =
true)
throw (FileException);
78 static time_t getCTime(
const std::string &fullpath,
bool followSymlink =
true)
throw (FileException);
80 static mode_t itomode(
int mode)
throw (FileException);
83 static struct stat getStat(const std::string &fullpath, bool followSymlink = true) throw (FileException);
84 static mode_t getMode(const std::string &fullpath, bool followSymlink = true) throw (FileException);