зеркало из https://github.com/mozilla/gecko-dev.git
Added constructors from new nsIFileSpec
This commit is contained in:
Родитель
43bdebd085
Коммит
a7567e39b2
|
@ -23,6 +23,7 @@
|
|||
#include "nsFileStream.h"
|
||||
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsIStringStream.h"
|
||||
|
||||
#include <string.h>
|
||||
|
@ -291,17 +292,56 @@ nsInputFileStream::nsInputFileStream(
|
|||
nsISupports* stream;
|
||||
if (NS_FAILED(NS_NewIOFileStream(&stream, inFile, nsprMode, accessMode)))
|
||||
return;
|
||||
AssignFrom(stream);
|
||||
NS_RELEASE(stream);
|
||||
} // nsInputFileStream::nsInputFileStream
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsInputFileStream::nsInputFileStream(nsIFileSpec* inSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsIInputStream* stream;
|
||||
if (NS_FAILED(inSpec->GetInputStream(&stream)))
|
||||
return;
|
||||
AssignFrom(stream);
|
||||
NS_RELEASE(stream);
|
||||
} // nsInputFileStream::nsInputFileStream
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsInputFileStream::AssignFrom(nsISupports* stream)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mFile = nsQueryInterface(stream);
|
||||
mInputStream = nsQueryInterface(stream);
|
||||
mStore = nsQueryInterface(stream);
|
||||
mFileInputStream = nsQueryInterface(stream);
|
||||
NS_RELEASE(stream);
|
||||
} // nsInputFileStream::nsInputFileStream
|
||||
}
|
||||
|
||||
//========================================================================================
|
||||
// nsOutputFileStream
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsOutputFileStream::nsOutputFileStream(nsIFileSpec* inSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsIOutputStream* stream;
|
||||
if (NS_FAILED(inSpec->GetOutputStream(&stream)))
|
||||
return;
|
||||
AssignFrom(stream);
|
||||
NS_RELEASE(stream);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsOutputFileStream::AssignFrom(nsISupports* stream)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mFile = nsQueryInterface(stream);
|
||||
mOutputStream = nsQueryInterface(stream);
|
||||
mStore = nsQueryInterface(stream);
|
||||
mFileOutputStream = nsQueryInterface(stream);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsOutputFileStream::flush()
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
|
|
@ -94,6 +94,7 @@ class nsFileSpec;
|
|||
class nsString;
|
||||
class nsIInputStream;
|
||||
class nsIOutputStream;
|
||||
class nsIFileSpec;
|
||||
|
||||
//========================================================================================
|
||||
// Compiler-specific macros, as needed
|
||||
|
@ -471,6 +472,7 @@ public:
|
|||
const nsFileSpec& inFile,
|
||||
int nsprMode = kDefaultMode,
|
||||
PRIntn accessMode = 00700); // <- OCTAL
|
||||
nsInputFileStream(nsIFileSpec* inFile);
|
||||
|
||||
void Open(
|
||||
const nsFileSpec& inFile,
|
||||
|
@ -487,6 +489,9 @@ public:
|
|||
nsInputStream& operator >> (nsInputStream& (*pf)(nsInputStream&))
|
||||
{ return nsInputStream::operator >>(pf); }
|
||||
|
||||
protected:
|
||||
void AssignFrom(nsISupports* stream);
|
||||
|
||||
// DATA
|
||||
protected:
|
||||
nsCOMPtr<nsIFileInputStream> mFileInputStream;
|
||||
|
@ -577,27 +582,22 @@ public:
|
|||
nsOutputFileStream() {}
|
||||
nsOutputFileStream(nsIOutputStream* inStream)
|
||||
{
|
||||
mFile = nsQueryInterface(inStream);
|
||||
mOutputStream = nsQueryInterface(inStream);
|
||||
mStore = nsQueryInterface(inStream);
|
||||
mFileOutputStream = nsQueryInterface(inStream);
|
||||
AssignFrom(inStream);
|
||||
}
|
||||
nsOutputFileStream(
|
||||
const nsFileSpec& inFile,
|
||||
int nsprMode = kDefaultMode,
|
||||
PRIntn accessMode = 00700) // <- OCTAL
|
||||
{
|
||||
{
|
||||
nsISupports* stream;
|
||||
if (NS_FAILED(NS_NewIOFileStream(
|
||||
&stream,
|
||||
inFile, nsprMode, accessMode)))
|
||||
return;
|
||||
mFile = nsQueryInterface(stream);
|
||||
mOutputStream = nsQueryInterface(stream);
|
||||
mStore = nsQueryInterface(stream);
|
||||
mFileOutputStream = nsQueryInterface(stream);
|
||||
AssignFrom(stream);
|
||||
NS_RELEASE(stream);
|
||||
}
|
||||
nsOutputFileStream(nsIFileSpec* inFile);
|
||||
|
||||
virtual void flush();
|
||||
virtual void abort();
|
||||
|
@ -622,6 +622,9 @@ public:
|
|||
nsOutputStream& operator << (nsOutputStream& (*pf)(nsOutputStream&))
|
||||
{ return nsOutputStream::operator << (pf); }
|
||||
|
||||
protected:
|
||||
void AssignFrom(nsISupports* stream);
|
||||
|
||||
// DATA
|
||||
protected:
|
||||
nsCOMPtr<nsIFileOutputStream> mFileOutputStream;
|
||||
|
@ -690,7 +693,7 @@ public:
|
|||
const nsFileSpec& inFile,
|
||||
int nsprMode = kDefaultMode,
|
||||
PRIntn accessMode = 00700) // <- OCTAL
|
||||
: nsInputFileStream(nsnull)
|
||||
: nsInputFileStream((nsIInputStream*)nsnull)
|
||||
, nsOutputStream(nsnull)
|
||||
{
|
||||
nsISupports* stream;
|
||||
|
|
Загрузка…
Ссылка в новой задаче