boost的filesystem使用示例
2017-01-13 14:24
295 查看
#include "boost/filesystem.hpp" // 包含所有需要的 Boost.Filesystem 声明 #include <iostream> // 使用 std::cout #include <string> #include <sstream> namespace fs = boost::filesystem; // 宏FSTEST:测试f的成员函数,输出成员函数名和结果 #define FSTEST(x) std::cout << #x##": " << f.x << std::endl int main(int argc, char **argv) { fs::path f("\\folder1\\folder2\\folder3\\filename.ext"); FSTEST(string()); FSTEST(root_name()); FSTEST(root_directory()); FSTEST(root_path()); FSTEST(relative_path()); FSTEST(filename()); FSTEST(parent_path()); FSTEST(stem()); FSTEST(extension()); FSTEST(replace_extension("new")); char buf[] = "hello"; FSTEST(append(buf, buf + sizeof(buf))); FSTEST(remove_filename()); // #define FSTEST2(x) std::cout << #x##": " << fs::x << std::endl FSTEST2(initial_path());//得到程序运行时的系统当前路径 FSTEST2(current_path());//得到系统当前路径 //要得到EXE文件所在的路径或AppData路径,只能通过调用Win API实现。 { std::cout << "convert to std::string()=>" << fs::initial_path().string(); } return 0; }
相关文章推荐
- boost之filesystem的使用
- boost::filesystem使用手册
- QTCreator + MSVC10编译器 使用boost::filesystem 时 error LNK2019: codecvt ... 问题的解决
- Boost::Thread使用示例
- Boost::Thread使用示例 - CG-Animation - 博客频道 - CSDN.NET
- 使用boost中的filesystem类库遍历某个目录所有的文件
- Boost::Thread使用示例
- boost中circular_buffer存储字符串的使用示例
- Boost FileSystem 库使用说明2
- boost::bind和boost::function使用示例
- boost::share_ptr智能指针使用示例
- 一个使用boost::thread_specific_ptr线程本地存储的示例,value将不受其它线程影响
- Boost::Thread使用示例
- Boost::filesystem的使用笔记
- Boost::filesystem 使用小笔记
- boost::share_ptr智能指针使用示例
- boost filesystem 使用
- boost::share_ptr智能指针使用示例
- php中的filesystem文件系统函数介绍及使用示例
- QTCreator + MSVC10编译器 使用boost::filesystem 时 error LNK2019: codecvt ... 问题的解决