util.h

Go to the documentation of this file.
00001 /* -*- Mode: c++ -*- */
00002 /*
00003  *  this is part of Spm
00004  *
00005  *  Copyright (c) 2003-2006 Guillaume Chevallereau
00006  *
00007  *  This program is free software. You can redistribute it and/or modify it 
00008  *  under the terms of the GNU General Public License as published by the 
00009  *  Free Software Foundation. Either version 2 of the license or (at your 
00010  *  option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be usefull but WITHOUT
00013  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
00014  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
00015  *  more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License along 
00018  *  with this program; if not, write to the Free Software Foundation, Inc., 
00019  *  59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
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

Generated on Sat Mar 21 17:00:14 2009 for libSpm by  doxygen 1.5.2