• <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

            代碼是咒語(yǔ),我是魔法師

            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) 評(píng)論(3)  編輯 收藏 引用 所屬分類: C++ & STL

            評(píng)論

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

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

            #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ù)  更多評(píng)論   

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

            fs::directory_iterator item_end;

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

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

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

            <2006年6月>
            28293031123
            45678910
            11121314151617
            18192021222324
            2526272829301
            2345678

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿(10)

            隨筆分類

            隨筆檔案

            相冊(cè)

            收藏夾

            搜索

            最新評(píng)論

            閱讀排行榜

            久久久久亚洲爆乳少妇无| 九九99精品久久久久久| 国内精品久久久久影院网站| 91超碰碰碰碰久久久久久综合| 久久综合久久综合久久| 三级韩国一区久久二区综合| 久久精品日日躁夜夜躁欧美| 久久99精品久久久久久久不卡 | 中文字幕亚洲综合久久| 精品久久久久中文字| 中文字幕久久亚洲一区| av国内精品久久久久影院| 中文字幕亚洲综合久久2| 精品久久久久成人码免费动漫| 久久精品亚洲一区二区三区浴池 | 精品久久久久久综合日本| 久久se精品一区精品二区国产| 亚洲va中文字幕无码久久不卡| 久久―日本道色综合久久| 久久久久久综合网天天| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 狠狠人妻久久久久久综合蜜桃| 伊人久久大香线蕉无码麻豆 | 久久久久亚洲AV成人片| 久久国产成人亚洲精品影院| 久久久老熟女一区二区三区| 国产成人综合久久精品红| 国产精品伊人久久伊人电影| 精品久久久久久中文字幕人妻最新| 色播久久人人爽人人爽人人片aV| 国产精品99久久久久久www| 久久丫精品国产亚洲av不卡 | 伊人久久大香线蕉AV色婷婷色| 久久久久综合国产欧美一区二区| 国产精品久久久久久久久免费| 伊人久久大香线蕉亚洲| 精品多毛少妇人妻AV免费久久| 日本精品久久久久影院日本| 久久精品国产99国产精品| 国产精品美女久久久免费| 久久精品成人免费国产片小草|