зеркало из https://github.com/mozilla/gecko-dev.git
Made write and read do an implicit open. Added a FileContents attribute to allow simple conversion between an entire file and a string.
This commit is contained in:
Родитель
0fbaf895d9
Коммит
1305107e9a
|
@ -24,6 +24,7 @@
|
|||
|
||||
%{C++
|
||||
#include "nsFileSpec.h" // for factory method
|
||||
#include "nsIComponentManager.h" // for CreateInstance
|
||||
%}
|
||||
|
||||
interface nsIFileURL;
|
||||
|
@ -134,13 +135,42 @@ interface nsIDirectoryIterator : nsISupports
|
|||
};
|
||||
|
||||
%{C++
|
||||
// Factory methods
|
||||
// Factory methods if you link with xpcom
|
||||
NS_COM nsresult NS_NewFileSpecWithSpec(nsFileSpec aSrcFileSpec, nsIFileSpec **result);
|
||||
NS_COM nsresult NS_NewFileSpec(nsIFileSpec** result);
|
||||
NS_COM nsresult NS_NewDirectoryIterator(nsIDirectoryIterator** result);
|
||||
|
||||
#define NS_BOOL_ACCESSOR(_method) { PRBool rv; return NS_SUCCEEDED(f->_method(&rv)) && rv; }
|
||||
// Factory methods if you do not link with xpcom. Consider using these
|
||||
// with nsCOMPtr, too (though it requires linking with xpcom).
|
||||
inline nsIFileSpec* NS_CreateFileSpec()
|
||||
{
|
||||
// #include nsIComponentManager.h
|
||||
nsIFileSpec* spec = nsnull;
|
||||
nsresult rv = nsComponentManager::CreateInstance(
|
||||
(const char*)NS_FILESPEC_PROGID,
|
||||
(nsISupports*)nsnull,
|
||||
(const nsID&)nsIFileSpec::GetIID(),
|
||||
(void**)&spec);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "ERROR: Could not make a file spec.");
|
||||
return spec;
|
||||
}
|
||||
|
||||
inline nsIDirectoryIterator* NS_CreateDirectoryIterator()
|
||||
{
|
||||
// #include nsIComponentManager.h
|
||||
nsIDirectoryIterator* iter = nsnull;
|
||||
nsresult rv = nsComponentManager::CreateInstance(
|
||||
(const char*)NS_DIRECTORYITERATOR_PROGID,
|
||||
(nsISupports*)nsnull,
|
||||
(const nsID&)nsIDirectoryIterator::GetIID(),
|
||||
(void**)&iter);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "ERROR: Could not make a directory iterator.");
|
||||
return iter;
|
||||
}
|
||||
|
||||
#define NS_BOOL_ACCESSOR(_method) { PRBool yes; return NS_SUCCEEDED(f->_method(&yes)) && yes; }
|
||||
inline PRBool Exists(nsIFileSpec* f) NS_BOOL_ACCESSOR(exists)
|
||||
inline PRBool Exists(nsIDirectoryIterator* f) NS_BOOL_ACCESSOR(exists)
|
||||
inline PRBool IsDirectory(nsIFileSpec* f) NS_BOOL_ACCESSOR(isDirectory)
|
||||
|
||||
%}
|
||||
|
|
Загрузка…
Ссылка в новой задаче