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

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

            <2008年12月>
            30123456
            78910111213
            14151617181920
            21222324252627
            28293031123
            45678910

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿(10)

            隨筆分類

            隨筆檔案

            相冊

            收藏夾

            搜索

            最新評(píng)論

            閱讀排行榜

            欧美一区二区三区久久综合| 18禁黄久久久AAA片| 亚洲国产成人久久精品动漫| 久久精品亚洲精品国产欧美| 久久天天躁狠狠躁夜夜躁2014| 香蕉久久av一区二区三区| 久久99精品久久久久久| 久久久久久久波多野结衣高潮| 色综合久久最新中文字幕| 18岁日韩内射颜射午夜久久成人| 热久久这里只有精品| 97久久婷婷五月综合色d啪蜜芽| 精品免费久久久久国产一区| 亚洲乱码中文字幕久久孕妇黑人 | 国产女人aaa级久久久级| 久久这里只有精品首页| 久久精品亚洲精品国产欧美| 99久久精品毛片免费播放| 亚洲成色WWW久久网站| 一极黄色视频久久网站| 国产亚洲精久久久久久无码AV| 99精品久久精品| avtt天堂网久久精品| 久久精品无码一区二区无码| 狠狠综合久久AV一区二区三区 | 久久笫一福利免费导航 | 亚洲精品无码久久不卡| 99久久国产综合精品网成人影院| 999久久久免费精品国产| 精品久久久久久久无码 | 少妇精品久久久一区二区三区| 欧美性猛交xxxx免费看久久久| 国产精自产拍久久久久久蜜| 日本免费久久久久久久网站 | 久久人人添人人爽添人人片牛牛| 久久99精品国产麻豆不卡| 丁香久久婷婷国产午夜视频| 久久久久国产| 亚洲国产成人久久综合区| 国产aⅴ激情无码久久| 国产69精品久久久久777|