1
#include "nsILocalFile.h"
2
#include "nsDependentString.h"
6
#include "nsIComponentRegistrar.h"
7
#include "nsIComponentManager.h"
8
#include "nsIServiceManager.h"
10
#include "nsXPIDLString.h"
11
#include "nsISimpleEnumerator.h"
14
PRBool LoopInDir(nsILocalFile* file)
17
nsCOMPtr<nsISimpleEnumerator> entries;
18
rv = file->GetDirectoryEntries(getter_AddRefs(entries));
19
if(NS_FAILED(rv) || !entries)
24
while(NS_SUCCEEDED(entries->HasMoreElements(&hasMore)) && hasMore)
26
nsCOMPtr<nsISupports> sup;
27
entries->GetNext(getter_AddRefs(sup));
31
nsCOMPtr<nsILocalFile> file = do_QueryInterface(sup);
36
if(NS_FAILED(file->GetNativeLeafName(name)))
40
printf("%s\n", name.get());
41
rv = file->IsDirectory(&isDir);
44
printf("IsDirectory Failed!!!\n");
50
nsCOMPtr<nsILocalFile> lfile = do_QueryInterface(file);
59
main(int argc, char* argv[])
63
nsCOMPtr<nsILocalFile> topDir;
65
nsCOMPtr<nsIServiceManager> servMan;
66
rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
67
if (NS_FAILED(rv)) return -1;
68
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
69
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
71
registrar->AutoRegister(nsnull);
73
if (argc > 1 && argv[1] != nsnull)
75
char* pathStr = argv[1];
76
NS_NewNativeLocalFile(nsDependentCString(pathStr), PR_FALSE, getter_AddRefs(topDir));
81
printf("No Top Dir\n");
84
PRInt32 startTime = PR_IntervalNow();
88
PRInt32 endTime = PR_IntervalNow();
90
printf("\nTime: %d\n", PR_IntervalToMilliseconds(endTime - startTime));
91
} // this scopes the nsCOMPtrs
92
// no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
93
rv = NS_ShutdownXPCOM(nsnull);
94
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");