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

            閱讀排行榜

            2020最新久久久视精品爱| 国产高潮国产高潮久久久91 | 亚洲精品无码久久毛片| 久久影院亚洲一区| 久久精品中文字幕无码绿巨人| 97超级碰碰碰久久久久| 亚洲精品国产综合久久一线| 国产精品美女久久久久| 亚洲Av无码国产情品久久| 久久久av波多野一区二区| 香蕉久久永久视频| 美女写真久久影院| 亚洲精品无码久久一线| 久久久艹| 国产精品美女久久久久AV福利 | 久久综合综合久久97色| 一个色综合久久| 久久亚洲国产精品五月天婷| 久久国产乱子精品免费女| av色综合久久天堂av色综合在| 久久99精品久久久久久秒播| 久久久久无码精品国产| 久久久久久精品久久久久| 国产精品九九久久精品女同亚洲欧美日韩综合区 | 99久久香蕉国产线看观香| 91精品国产综合久久香蕉| 久久久久久亚洲精品成人 | 久久精品国产精品青草| 成人综合伊人五月婷久久| 浪潮AV色综合久久天堂| 7777久久久国产精品消防器材| 久久频这里精品99香蕉久| 亚洲欧洲精品成人久久奇米网| 久久国产午夜精品一区二区三区| 久久这里只精品国产99热| 99久久精品国产高清一区二区 | 亚洲午夜久久久影院伊人| AV无码久久久久不卡蜜桃| 久久久噜噜噜久久中文福利| 99久久综合狠狠综合久久止| 久久r热这里有精品视频|