sbIDirectoryEnumerator.idl
Go to the documentation of this file.
1 /* -*- Mode: IDL; 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 #include "nsISupports.idl"
30 
43 interface nsIFile;
44 interface nsISimpleEnumerator;
45 
46 [scriptable, uuid(508bc51e-001f-4f3e-b036-d7dbff91e8dd)]
48 {
55  attribute unsigned long maxDepth;
56 
57 
62  attribute boolean directoriesOnly;
63 
64 
69  attribute boolean filesOnly;
70 
71 
78  void enumerate(in nsIFile aDirectory);
79 
80 
87  boolean hasMoreElements();
88 
89 
96  nsIFile getNext();
97 };
98 
99 
100 //
101 // C++ defs.
102 //
103 
104 %{C++
105 #define SB_DIRECTORYENUMERATOR_CONTRACTID \
106  "@songbirdnest.com/Songbird/DirectoryEnumerator;1"
107 
108 #include <nsAutoPtr.h>
109 #include <nsComponentManagerUtils.h>
110 
111  inline nsresult sbGetDirectoryEntries(
112  nsIFile * aFile,
113  sbIDirectoryEnumerator ** aDirEntryEnumerator)
114  {
115  nsresult rv;
116  nsCOMPtr<sbIDirectoryEnumerator> dirEntries =
117  do_CreateInstance(SB_DIRECTORYENUMERATOR_CONTRACTID, &rv);
118  NS_ENSURE_SUCCESS(rv, rv);
119 
120  rv = dirEntries->SetFilesOnly(PR_FALSE);
121  NS_ENSURE_SUCCESS(rv, rv);
122  rv = dirEntries->SetMaxDepth(1);
123  NS_ENSURE_SUCCESS(rv, rv);
124  rv = dirEntries->Enumerate(aFile);
125  NS_ENSURE_SUCCESS(rv, rv);
126 
127  dirEntries.forget(aDirEntryEnumerator);
128 
129  return NS_OK;
130  }
131 %}C++
132 
133 
nsIFile getNext()
Return the next file in the enumeration.
return NS_OK
attribute unsigned long maxDepth
Maximum depth to which to enumerate. A depth of 0 will enumerate to an unlimited depth. A depth of 1 will enumerate only the base directory (same as getDirectoryEntries).
nsresult sbGetDirectoryEntries(nsIFile *aFile, sbIDirectoryEnumerator **aDirEntryEnumerator)
var uuid
#define SB_DIRECTORYENUMERATOR_CONTRACTID
function C(H)
attribute boolean filesOnly
If true, only return files in getNext.
attribute boolean directoriesOnly
If true, only return directories in getNext.
boolean hasMoreElements()
Return true if more elements are available to enumerate.
void enumerate(in nsIFile aDirectory)
Enumerate the directory specified by aDirectory.