• <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://m.shnenglu.com/Files/bujiwu/FileSystem.rar

            posted on 2009-11-23 13:44 bujiwu 閱讀(831) 評論(0)  編輯 收藏 引用 所屬分類: Boost
            国产精品青草久久久久福利99| 婷婷综合久久中文字幕蜜桃三电影| 久久免费的精品国产V∧| 久久久这里只有精品加勒比| 少妇熟女久久综合网色欲| 亚洲国产精品无码久久一线| 国产午夜精品理论片久久影视| 久久99久久成人免费播放| 99久久综合国产精品免费| 久久久久久国产精品无码超碰| 精品午夜久久福利大片| 一本色道久久88综合日韩精品 | 国产精品久久久久国产A级| 国产精品毛片久久久久久久| 久久一区二区三区免费| 午夜欧美精品久久久久久久| 久久国产精品波多野结衣AV| 无遮挡粉嫩小泬久久久久久久| 国产精品内射久久久久欢欢| 亚洲熟妇无码另类久久久| 久久精品国产99久久久香蕉| 久久精品国产亚洲AV嫖农村妇女| 日日狠狠久久偷偷色综合0 | 热RE99久久精品国产66热| 久久精品国产69国产精品亚洲| 亚洲国产日韩综合久久精品| 中文字幕亚洲综合久久2| 色婷婷综合久久久久中文 | 久久久久久久久66精品片| 99久久国产免费福利| 97久久精品无码一区二区 | 精品久久久久久成人AV| 久久精品国产久精国产果冻传媒| 国产AⅤ精品一区二区三区久久| 99久久无码一区人妻a黑| 亚洲精品乱码久久久久久按摩| 午夜福利91久久福利| 婷婷久久综合九色综合九七| 久久九九久精品国产| 日韩亚洲欧美久久久www综合网| 久久99精品国产麻豆|