19 #ifndef FILESYSTEM_HELPERS_HPP 20 #define FILESYSTEM_HELPERS_HPP 23 #include <qi/session.hpp> 25 #include <boost/filesystem.hpp> 26 #include <boost/filesystem/operations.hpp> 27 #include <boost/algorithm/string/replace.hpp> 43 boost::algorithm::replace_all(rootFolder,
"\\\\",
"\\");
44 boost::filesystem::path folderPath(rootFolder);
45 if (boost::filesystem::exists(folderPath)){
46 boost::filesystem::directory_iterator end_itr;
48 for (boost::filesystem::directory_iterator dirIte(rootFolder); dirIte != end_itr; ++dirIte )
50 boost::filesystem::path filePath(dirIte->path());
52 if (!boost::filesystem::is_directory(dirIte->status()) )
54 file_size = file_size + boost::filesystem::file_size(filePath);
58 }
catch(std::exception& e){
59 std::cout << e.what() << std::endl;
65 inline void getFiles(
const boost::filesystem::path& root,
const std::string& ext, std::vector<boost::filesystem::path>& ret)
67 if(!boost::filesystem::exists(root) || !boost::filesystem::is_directory(root))
return;
69 boost::filesystem::recursive_directory_iterator it(root);
70 boost::filesystem::recursive_directory_iterator endit;
74 if(boost::filesystem::is_regular_file(*it) && it->path().extension() == ext)
76 ret.push_back(it->path().filename());
82 inline void getFilesSize(
const boost::filesystem::path& root,
long& file_size)
84 std::vector<boost::filesystem::path> files_path;
86 for (std::vector<boost::filesystem::path>::const_iterator it=files_path.begin();
87 it!=files_path.end(); it++)
90 file_size = file_size + boost::filesystem::file_size(*it);
91 }
catch(std::exception& e){
92 std::cout << e.what() << std::endl;
103 std::cout <<
"found a catkin prefix " << path << std::endl;
106 static std::string path = qi::path::findData(
"/", boot_config_file_name );
107 std::cout <<
"found a qibuild path " << path << std::endl;
113 inline std::string&
getURDF( std::string filename )
117 std::cout <<
"found a catkin URDF " << path << std::endl;
120 static std::string path = qi::path::findData(
"/urdf/", filename );
121 std::cout <<
"found a qibuild URDF " << path << std::endl;
std::string & getURDF(std::string filename)
void getFiles(const boost::filesystem::path &root, const std::string &ext, std::vector< boost::filesystem::path > &ret)
static const long folderMaximumSize
ROSLIB_DECL std::string getPath(const std::string &package_name)
void getFoldersize(std::string rootFolder, long &file_size)
std::string & getBootConfigFile()
static const std::string boot_config_file_name
void getFilesSize(const boost::filesystem::path &root, long &file_size)