• <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 橙子 閱讀(6060) 評論(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

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

            <2008年2月>
            272829303112
            3456789
            10111213141516
            17181920212223
            2425262728291
            2345678

            導航

            統計

            常用鏈接

            留言簿(10)

            隨筆分類

            隨筆檔案

            相冊

            收藏夾

            搜索

            最新評論

            閱讀排行榜

            久久综合九色综合久99| 一本久久精品一区二区| 久久夜色tv网站| 国产日韩欧美久久| 久久妇女高潮几次MBA| 久久99精品久久久久久动态图 | 国产精品99久久久久久宅男 | 日本道色综合久久影院| 无码任你躁久久久久久| 久久久久99精品成人片试看| 99久久人人爽亚洲精品美女| 久久国语露脸国产精品电影| 狠狠狠色丁香婷婷综合久久俺| 亚洲国产成人久久综合一区77| 国产精品免费福利久久| 久久人妻AV中文字幕| 国产毛片久久久久久国产毛片| 久久久久久久女国产乱让韩| 久久精品国产黑森林| …久久精品99久久香蕉国产| 国产精品久久久久久久人人看 | 99久久精品午夜一区二区| 一本一道久久a久久精品综合| 狠狠色丁香婷婷综合久久来 | 久久一本综合| 久久久久九九精品影院| 青青青青久久精品国产| 久久久精品免费国产四虎| 国产精品久久精品| 国产精品美女久久久m| 午夜人妻久久久久久久久| 久久精品国产亚洲av麻豆蜜芽| 日产久久强奸免费的看| 午夜精品久久久久9999高清| 久久精品国产黑森林| 久久综合一区二区无码| 亚洲AⅤ优女AV综合久久久| 午夜精品久久久内射近拍高清| 久久精品亚洲福利| 色天使久久综合网天天| 国产精品久久久久免费a∨|