]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/dir.h
Added drag-shrinking.
[wxWidgets.git] / include / wx / dir.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/dir.h
3// Purpose: wxDir is a class for enumerating the files in a directory
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 08.12.99
7// RCS-ID: $Id$
8// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_DIR_H_
13#define _WX_DIR_H_
14
15#ifdef __GNUG__
16 #pragma interface "dir.h"
17#endif
18
19#ifndef WX_PRECOMP
20 #include "wx/string.h"
21#endif
22
23// ----------------------------------------------------------------------------
24// constants
25// ----------------------------------------------------------------------------
26
27// these flags define what kind of filenames is included in the list of files
28// enumerated by GetFirst/GetNext
29enum
30{
31 wxDIR_FILES = 0x0001, // include files
32 wxDIR_DIRS = 0x0002, // include directories
33 wxDIR_HIDDEN = 0x0004, // include hidden files
34 wxDIR_DOTDOT = 0x0008, // include '.' and '..'
35
36 // by default, enumerate everything except '.' and '..'
37 wxDIR_DEFAULT = wxDIR_FILES | wxDIR_DIRS | wxDIR_HIDDEN
38};
39
40// ----------------------------------------------------------------------------
41// wxDir: portable equivalent of {open/read/close}dir functions
42// ----------------------------------------------------------------------------
43
44class WXDLLEXPORT wxDir
45{
46public:
47 // test for existence of a directory with the given name
48 static bool Exists(const wxString& dir);
49
50 // ctors
51 // -----
52
53 // default, use Open()
54 wxDir() { m_data = NULL; }
55
56 // opens the directory for enumeration, use IsOpened() to test success
57 wxDir(const wxString& dir);
58
59 // dtor cleans up the associated ressources
60 ~wxDir();
61
62 // open the directory for enumerating
63 bool Open(const wxString& dir);
64
65 // returns TRUE if the directory was successfully opened
66 bool IsOpened() const;
67
68 // file enumeration routines
69 // -------------------------
70
71 // start enumerating all files matching filespec (or all files if it is
72 // empty) and flags, return TRUE on success
73 bool GetFirst(wxString *filename,
74 const wxString& filespec = wxEmptyString,
75 int flags = wxDIR_DEFAULT) const;
76
77 // get next file in the enumeration started with either GetFirst() or
78 // GetFirstNormal()
79 bool GetNext(wxString *filename) const;
80
81 // TODO using scandir() when available later, emulating it otherwise
82#if 0
83 // get all files in the directory into an array, return TRUE on success
84 //
85 // this function uses Select() function to select the files
86 // unless the filespec is explicitly given and Compare() function to sort
87 // them
88 bool Read(wxArrayString& filenames,
89 const wxString& filespec = wxEmptyString) const;
90
91protected:
92 // this function is called by Read() if filespec is not specified in
93 // Read(): it should return TRUE if the file matches our selection
94 // criteria and FALSE otherwise
95 virtual bool Select(const wxChar* filename);
96
97 // This function is called by Read() to sort the array: it should return
98 // -1, 0 or +1 if the first file is less than, equal to or greater than
99 // the second. The base class version does
100 virtual int Compare(const wxChar *filename1, const wxChar *filename2);
101#endif // 0
102
103private:
104 friend class WXDLLEXPORT wxDirData;
105
106 wxDirData *m_data;
107};
108
109#endif // _WX_DIR_H_