Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXDir.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                    D i r e c t o r y   E n u m e r a t o r                    *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2005,2009 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 *********************************************************************************
00021 * $Id: FXDir.h,v 1.48 2009/01/06 13:07:23 fox Exp $                             *
00022 ********************************************************************************/
00023 #ifndef FXDIR_H
00024 #define FXDIR_H
00025 
00026 namespace FX {
00027 
00028 
00029 /// Directory enumerator
00030 class FXAPI FXDir {
00031 private:
00032   FXuval space[256];
00033 private:
00034   FXDir(const FXDir&);
00035   FXDir &operator=(const FXDir&);
00036 public:
00037 
00038   /// Options for listing files
00039   enum {
00040     MatchAll    = 0,              /// Matching files and directories
00041     NoFiles     = 1,              /// Don't list any files
00042     NoDirs      = 2,              /// Don't list any directories
00043     AllFiles    = 4,              /// List all files
00044     AllDirs     = 8,              /// List all directories
00045     HiddenFiles = 16,             /// List hidden files also
00046     HiddenDirs  = 32,             /// List hidden directories also
00047     NoParent    = 64,             /// Don't include '.' and '..' in the listing
00048     CaseFold    = 128             /// Matching is case-insensitive
00049     };
00050 
00051 public:
00052 
00053   /// Construct directory enumerator
00054   FXDir();
00055 
00056   /// Construct directory enumerator open on path
00057   FXDir(const FXString& path);
00058 
00059   /// Open directory to path, return true if ok.
00060   virtual FXbool open(const FXString& path);
00061 
00062   /// Returns true if the directory is open
00063   virtual FXbool isOpen() const;
00064 
00065   /// Go to next directory entry and return its name
00066   virtual FXbool next(FXString& name);
00067 
00068   /// Close directory
00069   virtual void close();
00070 
00071 
00072   /// Create directory
00073   static FXbool create(const FXString& path,FXuint perm=FXIO::AllFull);
00074 
00075   /// Remove directory
00076   static FXbool remove(const FXString& path);
00077 
00078   /// Rename directory
00079   static FXbool rename(const FXString& srcpath,const FXString& dstpath);
00080 
00081 
00082   /**
00083   * List files in a given directory.
00084   * Returns the number of files in the string-array list which matched the
00085   * pattern or satisfied the flag conditions.
00086   */
00087   static FXint listFiles(FXString*& filelist,const FXString& path,const FXString& pattern="*",FXuint flags=FXDir::MatchAll);
00088 
00089   /**
00090   * List drives, i.e. roots of directory trees.
00091   * Return the number of drives in the string array.
00092   */
00093   static FXint listDrives(FXString*& drivelist);
00094 
00095 
00096   /// Create a directories recursively
00097   static FXbool createDirectories(const FXString& path,FXuint perm=FXIO::AllFull);
00098 
00099 
00100   /// Destructor
00101   virtual ~FXDir();
00102   };
00103 
00104 
00105 }
00106 
00107 #endif

Copyright © 1997-2009 Jeroen van der Zijp