• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Life & Code

            代碼是咒語,我是魔法師

            boost::filesystem的文件遍歷

            ?

            #include? " boost/filesystem/operations.hpp "
            #include?
            " boost/filesystem/path.hpp "
            #include?
            < iostream >
            using ? namespace ?std;
            namespace ?fs? = ?boost::filesystem;

            void ?PrintAllFile(fs::path? & full_path);



            int ?main(? int ?argc,? char * ?argv[]?)
            {

            ????fs::path?full_path(?
            " D:\\ " ?,fs::native);
            ????PrintAllFile(full_path);
            }

            void ?PrintAllFile(fs::path? & full_path)
            {
            ?
            if (fs::exists(full_path))
            ?
            {
            ??fs::directory_iterator?item_begin(full_path);
            ??fs::directory_iterator?item_end;
            ??
            for (?;item_begin?? != ?item_end;?item_begin ++ )
            ??
            {
            ???
            ???
            if (fs::is_directory( * item_begin))
            ???
            {
            ????cout?
            << item_begin -> native_file_string() << " \t[dir] " << endl;
            ????PrintAllFile(
            * item_begin);
            ???}

            ???
            else
            ???
            {
            ????cout?
            << item_begin -> native_file_string() << endl;
            ???}

            ??}

            ?}

            }

            posted on 2006-12-13 00:29 橙子 閱讀(6067) 評論(3)  編輯 收藏 引用 所屬分類: C++ & STL

            評論

            # re: boost::filesystem的文件遍歷 2007-09-21 15:39 jazz

            我也剛學這個 貼個自己的例子

            #include <iostream>
            #include <string>
            #include <ctime>
            #pragma warning(push)
            #pragma warning(disable:4819)
            #pragma warning(disable:4996)
            #include <boost/filesystem/path.hpp>
            #include <boost/filesystem/operations.hpp>
            #include <boost/filesystem.hpp>
            #pragma warning(pop)

            using namespace std;
            using namespace boost;
            namespace fs = boost::filesystem;

            void RecusiveListFiles(fs::path& fpath)
            {
            fs::recursive_directory_iterator beg_iter(fpath);
            fs::recursive_directory_iterator end_iter;
            for (; beg_iter != end_iter; ++beg_iter)
            {
            if (fs::is_directory(*beg_iter))
            {
            continue;
            }
            else
            {
            cout<<beg_iter->path().file_string()<<'\n';

            time_t t = fs::last_write_time(*beg_iter);
            cout<<ctime(&t);
            uintmax_t filesize = fs::file_size(*beg_iter);
            cout<<filesize<<"\n\n";
            }
            }
            }

            int main(int argc, char* argv[])
            {
            try
            {
            if (argc < 2)
            {
            cout<<"Invalid arg --- You should input a Directory path as an argument.(ex: c:\\DELL)\n";
            return -1;
            }
            RecusiveListFiles(fs::path(string(argv[1]), fs::native));
            }
            catch (exception& e)
            {
            cout<<e.what()<<endl;
            }

            return 0;
            }  回復  更多評論   

            # re: boost::filesystem的文件遍歷 2008-12-29 00:46 Lingol

            fs::directory_iterator item_end;

            為何不需初始化?  回復  更多評論   

            # re: boost::filesystem的文件遍歷 2013-12-21 17:42 shit_engineer

            你確定這代碼能跑編過?  回復  更多評論   

            <2025年7月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            導航

            統計

            常用鏈接

            留言簿(10)

            隨筆分類

            隨筆檔案

            相冊

            收藏夾

            搜索

            最新評論

            閱讀排行榜

            久久久国产精品| 色综合久久久久综合体桃花网| 久久精品国产亚洲av水果派 | 天天久久狠狠色综合| 久久WWW免费人成—看片| 亚洲精品乱码久久久久久| 精品精品国产自在久久高清| 久久亚洲sm情趣捆绑调教| 久久久无码精品午夜| 国産精品久久久久久久| 久久亚洲精品国产精品婷婷| 欧美国产成人久久精品| 日韩AV无码久久一区二区| 亚洲午夜久久久久久久久电影网 | 久久亚洲AV无码西西人体| 中文精品99久久国产 | 色欲综合久久躁天天躁| 久久精品这里热有精品| 亚洲精品无码久久一线| 国产亚州精品女人久久久久久| 久久午夜羞羞影院免费观看| 日韩电影久久久被窝网| 一级做a爱片久久毛片| 国产—久久香蕉国产线看观看| 久久99精品九九九久久婷婷| 久久久久久九九99精品| 东方aⅴ免费观看久久av| 少妇久久久久久被弄到高潮| 国产精品久久久久乳精品爆| 9999国产精品欧美久久久久久| 久久久久亚洲AV无码观看| 国产成人精品综合久久久| 久久99精品国产麻豆婷婷| 日本免费一区二区久久人人澡| 一本色道久久99一综合| 国产aⅴ激情无码久久| 久久国产精品无| 伊人精品久久久久7777| 亚洲AⅤ优女AV综合久久久| 久久午夜福利电影| 99久久精品国产综合一区|