• <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 閱讀(824) 評論(0)  編輯 收藏 引用 所屬分類: Boost
            777米奇久久最新地址| 久久人人爽人人爽人人片AV东京热| 久久久噜噜噜久久中文字幕色伊伊 | 久久精品国产久精国产果冻传媒| 国产精品久久久久久久久软件 | 国产精品狼人久久久久影院| 久久久WWW免费人成精品| 思思久久好好热精品国产| 久久免费的精品国产V∧| 99久久精品免费观看国产| 久久亚洲精品无码aⅴ大香| 青青青青久久精品国产| 久久夜色精品国产亚洲| 狠狠综合久久综合中文88| 色综合久久久久久久久五月| 国产精品gz久久久| 国产成人无码久久久精品一| 久久伊人影视| 国产激情久久久久影院小草| 久久免费的精品国产V∧| 久久久久久国产精品无码下载| www性久久久com| 色综合久久综合中文综合网| 久久久久这里只有精品| 免费观看成人久久网免费观看| 精品国产乱码久久久久软件| 久久影院久久香蕉国产线看观看| 久久久久国产一级毛片高清版| 久久99精品久久只有精品 | 国产精品99久久久久久宅男| 久久国产免费观看精品3| 久久婷婷五月综合色奶水99啪| 久久午夜无码鲁丝片秋霞| 亚洲另类欧美综合久久图片区| 久久久久国产日韩精品网站| 日韩精品国产自在久久现线拍| 久久se精品一区精品二区| 精品久久777| 久久国产香蕉一区精品| 99久久国产免费福利| 久久99精品久久久久久齐齐|