Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
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,2006 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (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 GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************* 00022 * $Id: FXDir.h,v 1.24 2006/01/22 17:58:00 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXDIR_H 00025 #define FXDIR_H 00026 00027 namespace FX { 00028 00029 00030 /// Directory enumerator 00031 class FXAPI FXDir { 00032 private: 00033 FXuval space[256]; 00034 private: 00035 FXDir(const FXDir&); 00036 FXDir &operator=(const FXDir&); 00037 public: 00038 00039 /// Options for listing files 00040 enum { 00041 MatchAll = 0, /// Matching files and directories 00042 NoFiles = 1, /// Don't list any files 00043 NoDirs = 2, /// Don't list any directories 00044 AllFiles = 4, /// List all files 00045 AllDirs = 8, /// List all directories 00046 HiddenFiles = 16, /// List hidden files also 00047 HiddenDirs = 32, /// List hidden directories also 00048 NoParent = 64, /// Don't include '..' in the listing 00049 CaseFold = 128 /// Matching is case-insensitive 00050 }; 00051 00052 public: 00053 00054 /// Construct directory enumerator 00055 FXDir(); 00056 00057 /// Construct directory enumerator open on path 00058 FXDir(const FXString& path); 00059 00060 /// Open directory to path, return true if ok. 00061 virtual bool open(const FXString& path); 00062 00063 /// Returns true if the directory is open 00064 virtual bool isOpen() const; 00065 00066 /// Go to next one 00067 virtual bool next(); 00068 00069 /// Return current file name 00070 virtual FXString name() const; 00071 00072 /// Close directory 00073 virtual void close(); 00074 00075 /// Create directory 00076 static bool create(const FXString& path,FXuint mode=FXIO::OwnerFull|FXIO::GroupFull|FXIO::OtherFull); 00077 00078 /// Remove directory 00079 static bool remove(const FXString& path); 00080 00081 /// Rename or move srcpath to dstpath 00082 static bool rename(const FXString& srcpath,const FXString& dstpath); 00083 00084 /** 00085 * List files in a given directory. 00086 * Returns the number of files in the string-array list which matched the 00087 * pattern or satisfied the flag conditions. 00088 */ 00089 static FXint listFiles(FXString*& filelist,const FXString& path,const FXString& pattern="*",FXuint flags=FXDir::MatchAll); 00090 00091 /** 00092 * List drives, i.e. roots of directory trees. 00093 * Return the number of drives in the string array. 00094 */ 00095 static FXint listDrives(FXString*& drivelist); 00096 00097 00098 /// Destructor 00099 virtual ~FXDir(); 00100 }; 00101 00102 } 00103 00104 #endif
Copyright © 1997-2005 Jeroen van der Zijp |