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

FXDir.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * D i r e c t o r y E n u m e r a t o r *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2005,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXDir.h,v 1.24 2006/01/22 17:58:00 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXDIR_H
25 #define FXDIR_H
26 
27 namespace FX {
28 
29 
30 /// Directory enumerator
31 class FXAPI FXDir {
32 private:
33  FXuval space[256];
34 private:
35  FXDir(const FXDir&);
36  FXDir &operator=(const FXDir&);
37 public:
38 
39  /// Options for listing files
40  enum {
41  MatchAll = 0, /// Matching files and directories
42  NoFiles = 1, /// Don't list any files
43  NoDirs = 2, /// Don't list any directories
44  AllFiles = 4, /// List all files
45  AllDirs = 8, /// List all directories
46  HiddenFiles = 16, /// List hidden files also
47  HiddenDirs = 32, /// List hidden directories also
48  NoParent = 64, /// Don't include '..' in the listing
49  CaseFold = 128 /// Matching is case-insensitive
50  };
51 
52 public:
53 
54  /// Construct directory enumerator
55  FXDir();
56 
57  /// Construct directory enumerator open on path
58  FXDir(const FXString& path);
59 
60  /// Open directory to path, return true if ok.
61  virtual bool open(const FXString& path);
62 
63  /// Returns true if the directory is open
64  virtual bool isOpen() const;
65 
66  /// Go to next one
67  virtual bool next();
68 
69  /// Return current file name
70  virtual FXString name() const;
71 
72  /// Close directory
73  virtual void close();
74 
75  /// Create directory
76  static bool create(const FXString& path,FXuint mode=FXIO::OwnerFull|FXIO::GroupFull|FXIO::OtherFull);
77 
78  /// Remove directory
79  static bool remove(const FXString& path);
80 
81  /// Rename or move srcpath to dstpath
82  static bool rename(const FXString& srcpath,const FXString& dstpath);
83 
84  /**
85  * List files in a given directory.
86  * Returns the number of files in the string-array list which matched the
87  * pattern or satisfied the flag conditions.
88  */
89  static FXint listFiles(FXString*& filelist,const FXString& path,const FXString& pattern="*",FXuint flags=FXDir::MatchAll);
90 
91  /**
92  * List drives, i.e. roots of directory trees.
93  * Return the number of drives in the string array.
94  */
95  static FXint listDrives(FXString*& drivelist);
96 
97 
98  /// Destructor
99  virtual ~FXDir();
100  };
101 
102 }
103 
104 #endif
unsigned int FXuint
Definition: fxdefs.h:396
Matching files and directories.
Definition: FXDir.h:36
#define FXAPI
Definition: fxdefs.h:122
Others have full access.
Definition: FXIO.h:48
FXString name(const FXString &file)
Return name and extension part of the path name.
int FXint
Definition: fxdefs.h:397
Owner has full access.
Definition: FXIO.h:60
unsigned long FXuval
Definition: fxdefs.h:436
Directory enumerator.
Definition: FXDir.h:31
Group has full access.
Definition: FXIO.h:54
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33

Copyright © 1997-2005 Jeroen van der Zijp