23 #include <boost/filesystem.hpp>
38 return static_cast< std::string
>(boost::filesystem::extension(file_name));
60 return !boost::filesystem::extension(file_name).empty();
80 const std::string &ext_name,
81 bool case_sensitive =
false)
88 file_ext.begin(), file_ext.end(), file_ext.begin(), ::tolower);
91 return ext_name.compare(file_ext) == 0;
100 const char *ext_name,
101 bool case_sensitive =
false)
104 std::string(file_name), std::string(ext_name), case_sensitive);
113 const std::vector< std::string > &ext_names,
114 bool case_sensitive =
false)
117 ext_names.cbegin(), ext_names.cend(), [&](
const std::string &ext) {
118 return has_extension(file_name, ext, case_sensitive);
130 boost::filesystem::path p(file_name);
131 boost::filesystem::path file_full_name = p.filename();
132 return static_cast< std::string
>(file_full_name.stem().string());
154 boost::filesystem::path p(file_name);
155 return static_cast< std::string
>(p.filename().string());
165 std::ifstream myfile(file_name);
166 myfile.unsetf(std::ios_base::skipws);
168 unsigned int line_count =
static_cast< unsigned int >(
169 std::count(std::istreambuf_iterator< char >(myfile),
170 std::istreambuf_iterator< char >(),
172 return line_count + 1;
193 return static_cast< std::string
>(
194 boost::filesystem::path(file_name).branch_path().string());
210 std::getline(input, str);
213 if((!str.empty()) && (str.back() ==
'\r'))
238 while(std::getline(input, line))
241 if(! (line.empty() || line[0] ==
'#' || line[0] ==
'\r'))
245 return static_cast< bool >(input);
262 std::istringstream &line_ss)
268 return static_cast< bool >(input);
281 copy_file(
const std::string &from,
const std::string &to)
287 catch(
const boost::filesystem::filesystem_error &e)
289 std::cout <<
"Copy_file WARNING: " << e.what() << std::endl;
303 boost::filesystem::create_directory(dirname);
316 boost::filesystem::remove_all(dirname);
327 return boost::filesystem::current_path().string();
340 boost::filesystem::current_path(dirname);
356 std::string contents;
358 std::ifstream in(file_name, std::ios::in | std::ios::binary);
361 in.seekg(0, std::ios::end);
362 contents.resize(in.tellg());
363 in.seekg(0, std::ios::beg);
364 in.read(&contents[0], contents.size());
369 std::cout <<
"FEVV::FileUtils::load_file: failed to open file '"