• <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 橙子 閱讀(6060) 評論(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ù)  更多評論   

            <2006年9月>
            272829303112
            3456789
            10111213141516
            17181920212223
            24252627282930
            1234567

            導(dǎo)航

            統(tǒng)計

            常用鏈接

            留言簿(10)

            隨筆分類

            隨筆檔案

            相冊

            收藏夾

            搜索

            最新評論

            閱讀排行榜

            99国产欧美久久久精品蜜芽 | 精品久久8x国产免费观看| 国产成人久久精品一区二区三区 | 久久综合九色综合精品| 99久久国产免费福利| 午夜精品久久久久9999高清| 精品久久久久久中文字幕大豆网| 综合久久国产九一剧情麻豆| 日韩精品久久久久久| 中文字幕乱码久久午夜| 久久久精品波多野结衣| 久久中文字幕一区二区| 99精品久久精品一区二区| 色播久久人人爽人人爽人人片aV | 中文字幕无码久久精品青草| 久久精品国产91久久综合麻豆自制| 少妇被又大又粗又爽毛片久久黑人 | 天天综合久久一二三区| 精品人妻伦一二三区久久| 国内精品免费久久影院| 久久99国产精品一区二区| 97超级碰碰碰久久久久| 精品一区二区久久| 国产精品久久久天天影视香蕉 | 久久亚洲精品无码播放| 综合久久给合久久狠狠狠97色| 色综合久久综精品| 亚洲精品视频久久久| 99精品国产免费久久久久久下载 | 久久综合给合久久狠狠狠97色| 久久无码人妻一区二区三区| 久久99精品国产自在现线小黄鸭| 国产精品久久久久久一区二区三区 | 亚洲精品乱码久久久久久蜜桃| 思思久久99热只有频精品66| 久久久久亚洲AV无码永不| 国产精品伊人久久伊人电影 | 欧美亚洲另类久久综合| 亚洲中文字幕无码久久精品1| 久久99精品久久久久久动态图| 思思久久99热只有频精品66|