• <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++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              32 隨筆 :: 0 文章 :: 25 評(píng)論 :: 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 閱讀(830) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Boost
            久久久久99精品成人片牛牛影视| 99久久香蕉国产线看观香| 国产美女久久精品香蕉69| 国产精品久久久久aaaa| segui久久国产精品| 2021久久精品免费观看| 丰满少妇人妻久久久久久 | 久久久久香蕉视频| 国内精品久久久久久久久电影网| 久久精品国产精品亚洲精品| 无码国内精品久久综合88| 久久综合综合久久97色| 国产偷久久久精品专区| 精品国产乱码久久久久久浪潮 | 99久久精品免费看国产一区二区三区| 久久人人爽人人爽人人片AV不| 久久精品国产色蜜蜜麻豆| 精品亚洲综合久久中文字幕| 久久亚洲国产成人影院| 国产伊人久久| 青青草国产精品久久久久| 久久久一本精品99久久精品66| 99久久做夜夜爱天天做精品| 久久97久久97精品免视看秋霞| 99久久精品国内| 91精品国产9l久久久久| 亚洲精品国精品久久99热一| 热RE99久久精品国产66热| 久久激情亚洲精品无码?V| 女人香蕉久久**毛片精品| 久久精品国产第一区二区三区| 久久人人爽人人爽人人片AV麻烦| 区亚洲欧美一级久久精品亚洲精品成人网久久久久 | 中文字幕久久精品| 久久亚洲国产最新网站| 亚洲精品乱码久久久久久蜜桃| 久久久久亚洲AV综合波多野结衣| 国产呻吟久久久久久久92| 国产精品成人99久久久久| 国産精品久久久久久久| 国产伊人久久|