• <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é)這個(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ù)  更多評論   

            # 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ù)  更多評論   

            <2010年12月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿(10)

            隨筆分類

            隨筆檔案

            相冊

            收藏夾

            搜索

            最新評論

            閱讀排行榜

            7777精品伊人久久久大香线蕉| 97久久精品人妻人人搡人人玩| 国产免费久久精品丫丫| 精品国产婷婷久久久| 天天影视色香欲综合久久| 亚洲精品无码久久久| 久久精品视频一| 国产精品久久久久久| 亚洲Av无码国产情品久久| 亚洲AV无码久久寂寞少妇| 亚洲狠狠久久综合一区77777| 久久久这里有精品| 久久国产热这里只有精品| 久久香蕉国产线看观看精品yw| 国内精品久久久久久久影视麻豆| 无码人妻少妇久久中文字幕蜜桃| 久久国产精品一区| 久久精品国产91久久麻豆自制| 美女久久久久久| 久久久久亚洲精品无码网址 | 久久99精品国产自在现线小黄鸭| 伊人色综合久久| 2021久久国自产拍精品| 国产偷久久久精品专区 | 国产∨亚洲V天堂无码久久久| 日韩久久久久中文字幕人妻| 国产成人精品久久亚洲| 国产精品视频久久久| 久久人妻少妇嫩草AV无码专区| 亚洲国产成人久久综合区| 狠狠人妻久久久久久综合蜜桃| 久久国产色AV免费观看| 精品乱码久久久久久久| 色诱久久久久综合网ywww| 伊人久久大香线蕉综合Av| 久久久久久精品成人免费图片| 久久精品国产男包| 久久99精品国产麻豆宅宅| 色综合久久中文字幕无码| 天天躁日日躁狠狠久久| 久久综合久久综合久久|