00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __UTIL_H__
00022 #define __UTIL_H__
00023
00024 #include <list>
00025 #include <sstream>
00026 #include "compressed.h"
00027 #include "utilException.h"
00028 #include <boost/filesystem/operations.hpp>
00029 #include <boost/filesystem/exception.hpp>
00030
00031 namespace Spm
00032 {
00033 namespace Util
00034 {
00038 miniXml::ustring getUserName ();
00039
00043 boost::filesystem::path getUserHome ();
00044
00049 boost::filesystem::path getUserHome (const miniXml::ustring & user)
00050 throw (UnknownUserException);
00051
00055 boost::filesystem::path getSpmUserDir ();
00056
00061 boost::filesystem::path getSpmUserDir (const miniXml::ustring & user);
00062
00066 bool isRoot ();
00067
00072 void checkSpmDir (const boost::filesystem::path & dir);
00073
00079 bool haveEnoughRight (const boost::filesystem::path & dir);
00080
00081
00082 template <class T> miniXml::ustring toString (T t)
00083 {
00084 std::ostringstream oss;
00085 oss << t;
00086 return oss.str ();
00087 }
00088
00094 inline bool checkPath(const boost::filesystem::path & path)
00095 {
00096 try
00097 {
00098 return boost::filesystem::exists(path);
00099 }
00100 catch (boost::filesystem::filesystem_error & fse)
00101 {
00102 return false;
00103 }
00104 }
00105
00109 int numberOfProcessors ();
00110 }
00111 }
00112 #endif