sbDirectoryEnumerator.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 :miv */
3 /*
4 //
5 // BEGIN SONGBIRD GPL
6 //
7 // This file is part of the Songbird web player.
8 //
9 // Copyright(c) 2005-2009 POTI, Inc.
10 // http://songbirdnest.com
11 //
12 // This file may be licensed under the terms of of the
13 // GNU General Public License Version 2 (the "GPL").
14 //
15 // Software distributed under the License is distributed
16 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
17 // express or implied. See the GPL for the specific language
18 // governing rights and limitations.
19 //
20 // You should have received a copy of the GPL along with this
21 // program. If not, go to http://www.gnu.org/licenses/gpl.html
22 // or write to the Free Software Foundation, Inc.,
23 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 // END SONGBIRD GPL
26 //
27 */
28 
29 #ifndef __SB_DIRECTORY_ENUMERATOR_H__
30 #define __SB_DIRECTORY_ENUMERATOR_H__
31 
32 //------------------------------------------------------------------------------
33 //------------------------------------------------------------------------------
34 //
35 // Songbird directory enumerator defs.
36 //
37 //------------------------------------------------------------------------------
38 //------------------------------------------------------------------------------
39 
45 //------------------------------------------------------------------------------
46 //
47 // Songbird directory enumerator imported services.
48 //
49 //------------------------------------------------------------------------------
50 
51 // Songbird imports.
52 #include <sbIDirectoryEnumerator.h>
53 
54 // Mozilla imports.
55 #include <nsCOMArray.h>
56 #include <nsCOMPtr.h>
57 #include <nsISimpleEnumerator.h>
58 
59 
60 //------------------------------------------------------------------------------
61 //
62 // Songbird directory enumerator definitions.
63 //
64 //------------------------------------------------------------------------------
65 
66 //
67 // Songbird directory enumerator XPCOM component definitions.
68 //
69 
70 #define SB_DIRECTORYENUMERATOR_CLASSNAME "sbDirectoryEnumerator"
71 #define SB_DIRECTORYENUMERATOR_DESCRIPTION "Songbird Directory Enumerator"
72 #define SB_DIRECTORYENUMERATOR_CID \
73 { \
74  0x7065ab15, \
75  0x8b5f, \
76  0x4e02, \
77  { 0x96, 0x5e, 0xcf, 0x49, 0x9b, 0xd9, 0xca, 0x3a } \
78 }
79 
80 //------------------------------------------------------------------------------
81 //
82 // Songbird directory enumerator classes.
83 //
84 //------------------------------------------------------------------------------
85 
91 {
92  //----------------------------------------------------------------------------
93  //
94  // Public interface.
95  //
96  //----------------------------------------------------------------------------
97 
98 public:
99 
100  //
101  // Implemented interfaces.
102  //
103 
105  NS_DECL_SBIDIRECTORYENUMERATOR
106 
107 
108  //
109  // Public services.
110  //
111 
113 
114  virtual ~sbDirectoryEnumerator();
115 
116  nsresult Initialize();
117 
118  void Finalize();
119 
120 
121  //----------------------------------------------------------------------------
122  //
123  // Private interface.
124  //
125  //----------------------------------------------------------------------------
126 
127 private:
128  //
129  // mIsInitialized If true, directory enumerator has been
130  // initialized.
131  // mEnumeratorLock Lock for the enumerator.
132  // mEntriesEnumStack Stack of directory entry enumerators.
133  // mNextFile Next file in enumeration.
134  // mMaxDepth Maximum depth of enumeration.
135  // mDirectoriesOnly If true, enumerate only directories.
136  // mFilesOnly If true, enumerate only files.
137  //
138 
139  PRBool mIsInitialized;
140  PRLock* mEnumeratorLock;
141  nsCOMArray<nsISimpleEnumerator>
142  mEntriesEnumStack;
143  nsCOMPtr<nsIFile> mNextFile;
144  PRUint32 mMaxDepth;
145  PRBool mDirectoriesOnly;
146  PRBool mFilesOnly;
147 
148 
149  //
150  // Public services.
151  //
152 
153  nsresult ScanForNextFile();
154 };
155 
156 
157 #endif /* __SB_DIRECTORY_ENUMERATOR_H__ */
158 
NS_DECL_ISUPPORTS NS_DECL_SBIDIRECTORYENUMERATOR sbDirectoryEnumerator()