19 #ifndef FILESYSTEM_HELPERS_HPP
20 #define FILESYSTEM_HELPERS_HPP
22 #include <qi/session.hpp>
24 #include <boost/filesystem.hpp>
25 #include <boost/filesystem/operations.hpp>
26 #include <boost/algorithm/string/replace.hpp>
29 #include <ros/package.h>
42 boost::algorithm::replace_all(rootFolder,
"\\\\",
"\\");
43 boost::filesystem::path folderPath(rootFolder);
44 if (boost::filesystem::exists(folderPath)){
45 boost::filesystem::directory_iterator end_itr;
47 for (boost::filesystem::directory_iterator dirIte(rootFolder); dirIte != end_itr; ++dirIte )
49 boost::filesystem::path filePath(dirIte->path());
51 if (!boost::filesystem::is_directory(dirIte->status()) )
53 file_size = file_size + boost::filesystem::file_size(filePath);
57 }
catch(std::exception& e){
58 std::cout << e.what() << std::endl;
64 inline void getFiles(
const boost::filesystem::path& root,
const std::string& ext, std::vector<boost::filesystem::path>& ret)
66 if(!boost::filesystem::exists(root) || !boost::filesystem::is_directory(root))
return;
68 boost::filesystem::recursive_directory_iterator it(root);
69 boost::filesystem::recursive_directory_iterator endit;
73 if(boost::filesystem::is_regular_file(*it) && it->path().extension() == ext)
75 ret.push_back(it->path().filename());
81 inline void getFilesSize(
const boost::filesystem::path& root,
long& file_size)
83 std::vector<boost::filesystem::path> files_path;
85 for (std::vector<boost::filesystem::path>::const_iterator it=files_path.begin();
86 it!=files_path.end(); it++)
89 file_size = file_size + boost::filesystem::file_size(*it);
90 }
catch(std::exception& e){
91 std::cout << e.what() << std::endl;
102 std::cout <<
"found a catkin prefix " << path << std::endl;
105 static std::string path = qi::path::findData(
"/", boot_config_file_name );
106 std::cout <<
"found a qibuild path " << path << std::endl;
112 inline std::string&
getURDF( std::string filename )
115 static std::string path = ros::package::getPath(
"naoqi_driver")+
"/share/urdf/"+filename;
116 std::cout <<
"found a catkin URDF " << path << std::endl;
119 static std::string path = qi::path::findData(
"/urdf/", filename );
120 std::cout <<
"found a qibuild URDF " << path << std::endl;
std::string & getURDF(std::string filename)
Definition: filesystem_helpers.hpp:112
void getFiles(const boost::filesystem::path &root, const std::string &ext, std::vector< boost::filesystem::path > &ret)
Definition: filesystem_helpers.hpp:64
static const long folderMaximumSize
Definition: filesystem_helpers.hpp:39
void getFoldersize(std::string rootFolder, long &file_size)
Definition: filesystem_helpers.hpp:41
std::string & getBootConfigFile()
Definition: filesystem_helpers.hpp:98
static const std::string boot_config_file_name
Definition: filesystem_helpers.hpp:97
void getFilesSize(const boost::filesystem::path &root, long &file_size)
Definition: filesystem_helpers.hpp:81