• <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 橙子 閱讀(6066) 評論(3)  編輯 收藏 引用 所屬分類: C++ & STL

            評論

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

            我也剛學(xué)這個 貼個自己的例子

            #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;
            }  回復(fù)  更多評論   

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

            fs::directory_iterator item_end;

            為何不需初始化?  回復(fù)  更多評論   

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

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

            <2025年6月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            293012345

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿(10)

            隨筆分類

            隨筆檔案

            相冊

            收藏夾

            搜索

            最新評論

            閱讀排行榜

            亚洲国产天堂久久综合| 99久久精品国产麻豆| 久久人人爽人人爽人人片AV东京热| 色综合久久综合网观看| 久久天天躁狠狠躁夜夜2020老熟妇 | 欧美噜噜久久久XXX| 日韩一区二区久久久久久| 一本色道久久88综合日韩精品 | av国内精品久久久久影院 | 亚洲国产成人精品女人久久久 | 久久亚洲精品无码播放| 热re99久久6国产精品免费| 精品熟女少妇aⅴ免费久久| av色综合久久天堂av色综合在| 成人资源影音先锋久久资源网| 亚洲伊人久久成综合人影院| 国产欧美久久久精品| 久久精品青青草原伊人| 久久99精品国产麻豆蜜芽| 久久大香香蕉国产| 亚洲一区精品伊人久久伊人| 国产99久久久久久免费看| 无遮挡粉嫩小泬久久久久久久| 久久男人中文字幕资源站| 国产精品99久久久久久猫咪| 精品国产福利久久久| 国产精品久久久久9999| 欧洲人妻丰满av无码久久不卡 | 精品国产99久久久久久麻豆| 国产精品久久久久影院色| 无码国内精品久久综合88| 亚洲性久久久影院| 一级做a爰片久久毛片免费陪| 久久精品亚洲欧美日韩久久| 久久精品国产精品国产精品污| 国产成人精品三上悠亚久久| 亚洲中文字幕伊人久久无码| 人人狠狠综合久久亚洲| 青青草原综合久久大伊人| 欧美性猛交xxxx免费看久久久| 国产巨作麻豆欧美亚洲综合久久|