• <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 橙子 閱讀(6083) 評(píng)論(3)  編輯 收藏 引用 所屬分類(lèi): 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)論   

            <2025年9月>
            31123456
            78910111213
            14151617181920
            21222324252627
            2829301234
            567891011

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿(10)

            隨筆分類(lèi)

            隨筆檔案

            相冊(cè)

            收藏夾

            搜索

            最新評(píng)論

            閱讀排行榜

            亚洲午夜无码久久久久| 91精品婷婷国产综合久久| 狠狠色丁香久久婷婷综合| 1000部精品久久久久久久久| 色噜噜狠狠先锋影音久久| 亚洲色欲久久久久综合网| 久久伊人五月天论坛| 久久99精品国产麻豆宅宅| 精品久久香蕉国产线看观看亚洲| 久久精品一区二区影院 | 热综合一本伊人久久精品| 久久99精品久久久大学生| 久久精品国产一区二区三区不卡| 色播久久人人爽人人爽人人片AV| 国产叼嘿久久精品久久| 91精品国产综合久久婷婷| 亚洲精品蜜桃久久久久久| 久久人妻少妇嫩草AV无码蜜桃 | 亚洲AV伊人久久青青草原| 精品久久久久久无码中文野结衣 | 亚洲va国产va天堂va久久| 一级做a爰片久久毛片看看| 国产精品永久久久久久久久久| 久久精品国产久精国产思思 | 久久精品成人欧美大片 | 亚洲午夜无码久久久久| 久久婷婷五月综合国产尤物app | 伊人久久精品无码av一区| 久久久久婷婷| 国内精品久久久久久久coent| 97精品久久天干天天天按摩| 久久久久人妻精品一区二区三区 | 久久精品视屏| 日本欧美国产精品第一页久久| 久久久久国产一区二区三区| 久久久99精品一区二区| 伊人久久大香线蕉精品不卡| 亚洲&#228;v永久无码精品天堂久久 | 国产美女亚洲精品久久久综合| 国产激情久久久久久熟女老人 | 久久91精品久久91综合|