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

            Jiwu Bu

              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
              32 隨筆 :: 0 文章 :: 25 評論 :: 0 Trackbacks
            為了方便日常使用boost::filestream組件,將boost::filestream組件的基本封裝。

            /*
             * @file FileSystem.h
             * @brief Operation file or diretory
             * @author Jiwu Bu
             * @version 1.0.0
             * @date 2009-11-23
             
            */
            #ifndef FILESYSTEM_H_H
            #define FILESYSTEM_H_H

            #include 
            <iostream>
            #include 
            <vector>

            using namespace std;

            class CFileSystem
            {
            public:
                
            /*
                 * @brief Gets an array of dirctories from current direcoty,
                 *        using Recur value to determine whether to search 
                 *        subdirectories.
                 * @param SubDirVec Ouput parameter, return the search result
                 * @param DirPath
                 * @param Recur  Whether search subdirectories.
                 * 
                 * @return 
                 
            */
                
            static bool GetDirectories(vector<string>& SubDirVec, 
                    
            const string& DirPath, bool Recur = false);

                
            /*
                 * @brief Get the names of files in the specified directory that 
                 *        match the specified extensive name, using a value to 
                 *        determine whether to search subdirectories.
                 * 
                 * @param FileVec Ouput parameter, return the search result
                 * @param DirPath
                 * @param ExeName Extensive name, if ExeName equal  "*.*"  search all file
                 * @param Recur   Whether search subdirectories
                 * 
                 * @return 
                 
            */
                
            static bool GetFiles(vector<string>& FileVec, const string& DirPath, 
                    
            const string& ExeName, bool Recur = false);

                
            /*
                 * @brief Create a new directory.
                 * 
                 * @param Dir  New directory path. Example:/home/bujiwu/test
                 * 
                 * @return  true, if success
                 *          false, if failed
                 
            */
                
            static bool CreateDirectory(const string & Dir);

                
            /*
                 * @brief Judge whether this file or diretory exists.
                 * 
                 * @param Path
                 * 
                 * @return  true, if exists
                 *          false, if not exists
                 
            */
                
            static bool Exists(const string& Path);

                
            /*
                 * @brief Delete this file or directory
                 * 
                 * @param Path
                 
            */
                
            static void Delete(const string& Path);

                
            /*
                 * @brief Move file or directory from FromPath to ToPath.
                 * 
                 * @param FromPath
                 * @param ToPath
                 
            */
                
            static void Move(const string& FromPath, const string& ToPath);

                
            /*
                 * @brief Copy file or directory from FromPath to ToPath.
                 * 
                 * @param FromPath
                 * @param ToPath
                 
            */
                
            static void Copy(const string& FromPath, const string& ToPath);

                
            /*
                 * @brief Get file size
                 * 
                 * @param FilePath
                 * 
                 * @return 
                 
            */
                
            static unsigned long GetFileSize(const string& FilePath);
            };

            #endif

            測試用例:
            #include "../FileSystem/FileSystem.h"
            #include 
            <algorithm>
            #include 
            <iterator>
            #include 
            <string>

            using namespace std;

            int main(int argc, char* argv[])
            {
                vector
            <string> MyVec;

                
            string Path = "/home/bujiwu/EncapDirectory";
                
                CFileSystem::Copy(
            "/home/bujiwu/epoll", Path);

                CFileSystem::GetFiles(MyVec, Path, 
            "*.*"true);

                copy(MyVec.begin(), MyVec.end(), ostream_iterator
            <string>(cout , "\n") );

                
            return 0;
            }

            http://www.shnenglu.com/Files/bujiwu/FileSystem.rar

            posted on 2009-11-23 13:44 bujiwu 閱讀(831) 評論(0)  編輯 收藏 引用 所屬分類: Boost
            2021最新久久久视精品爱| 麻豆成人久久精品二区三区免费 | 久久青青国产| 亚洲国产精品无码久久青草 | 国内精品久久久久影院网站| 久久免费视频观看| 久久黄视频| 久久久无码一区二区三区| 亚洲嫩草影院久久精品| 日韩欧美亚洲国产精品字幕久久久| 漂亮人妻被中出中文字幕久久 | 久久亚洲国产欧洲精品一| 99久久精品国产一区二区蜜芽| 青青草国产97免久久费观看| 欧美午夜精品久久久久免费视| 久久精品草草草| 亚洲精品国产美女久久久| 国产精品激情综合久久| 久久亚洲AV成人无码国产| 青青草原综合久久大伊人导航| 国产精品久久永久免费| 久久丫忘忧草产品| 久久久久综合国产欧美一区二区| 久久永久免费人妻精品下载| 久久综合狠狠综合久久97色| 久久青青草原国产精品免费 | 国产亚洲精品自在久久| 色青青草原桃花久久综合| 久久99精品国产麻豆婷婷| 久久99热狠狠色精品一区| 久久99精品久久久久久hb无码| 香蕉久久久久久狠狠色| 久久婷婷午色综合夜啪| 亚洲日韩欧美一区久久久久我 | 久久久WWW成人| 久久美女人爽女人爽| 伊人久久大香线焦综合四虎| 成人久久久观看免费毛片| 亚洲嫩草影院久久精品| 久久99精品九九九久久婷婷| 亚洲欧美日韩精品久久亚洲区 |