26 #ifndef SHORE_MISC_PATHOPS_HPP__
27 #define SHORE_MISC_PATHOPS_HPP__
36 #include <boost/cstdint.hpp>
55 std::string
path_leaf(
const std::string& path);
58 std::string
path_trunk(
const std::string& path);
61 std::string
path_clean(
const std::string& path);
65 std::string
path_enum(
const std::string& path,
const std::string& suffix,
66 int& num_ofs,
const char sep=
'_');
70 std::string
path_enum(
const std::string& path,
71 const std::string& suffix=std::string());
78 std::string
mktempdir(
const std::string& prefix);
82 const std::string& env=std::string());
85 uint64_t
file_size(
const std::string &fn);
93 const std::string& env=std::string())
98 std::string msg=
"Program not found: "+command+
"\n\n";
99 msg+=
"\tPlease make sure that "+command+
" is in your path";
102 std::string uccmd=command;
105 msg+=
",\n\tor set the environment variable '"+env
106 +
"' to the folder with the "+command+
" binary."\
107 "\n\n\tFor example, bash users type or permantely set in ~/.bashrc:"\
108 "\n\n\t\texport "+env+
"=FOLDER_TO_"+uccmd+
"\n\n";
117 std::string
which(
const std::string& command,
const std::string& env=std::string());
120 void glob(Iter b,Iter e,std::vector<std::string> &ret)
122 for(Iter i=b;i!=e;++i)
126 const int e=glob(
to_string(*i).c_str(),GLOB_TILDE,0,&globbuf);
128 const int e=glob(
to_string(*i).c_str(),0,0,&globbuf);
133 for(
size_t j=0;j<globbuf.gl_pathc;++j)
135 ret.push_back(globbuf.gl_pathv[j]);
144 throw std::runtime_error(
"glob error");
151 std::vector<std::string> glob(Iter b,Iter e)
153 std::vector<std::string> ret;
159 void glob(
const std::string& pattern,std::vector<std::string> &ret);
162 std::vector<std::string> glob(
const std::string& pattern);
164 typedef boost::uint64_t uint64_t;
167 uint64_t
get_mtime(
const std::string &path);
170 bool is_older(
const std::string &path1,
const std::string &path2);
174 #endif // SHORE_MISC_PATHOPS_HPP__