From dd79f3130c170c8e914d31fcefdc1bd580bcb6a3 Mon Sep 17 00:00:00 2001 From: "mcmullen%netscape.com" Date: Fri, 11 Dec 1998 18:17:22 +0000 Subject: [PATCH] And again. --- base/public/nsFileStream.h | 64 +++++++++++++++++++++----------------- base/src/nsFileStream.cpp | 32 +++++++++---------- xpcom/io/nsFileStream.cpp | 32 +++++++++---------- xpcom/io/nsFileStream.h | 64 +++++++++++++++++++++----------------- 4 files changed, 104 insertions(+), 88 deletions(-) diff --git a/base/public/nsFileStream.h b/base/public/nsFileStream.h index 88ce60a622c..949a4139543 100644 --- a/base/public/nsFileStream.h +++ b/base/public/nsFileStream.h @@ -92,6 +92,8 @@ #define NS_NAMESPACE namespace #define NS_NAMESPACE_END #define BASIC_STREAMBUF basic_streambuf +#define IOS_BASE ios_base + #include using std::ios_base; using std::basic_streambuf; @@ -103,13 +105,18 @@ using std::basic_ostream; using std::basic_iostream; using std::char_traits; + #else -#include + #define NS_NAMESPACE_PROTOTYPE static #define NS_NAMESPACE struct #define NS_NAMESPACE_END ; #define BASIC_STREAMBUF streambuf -#endif +#define IOS_BASE ios + +#include + +#endif // NS_USING_NAMESPACE #ifdef __MWERKS__ @@ -128,7 +135,8 @@ #define NS_READ_LOCK(mut) #define NS_WRITE_LOCK(mut) -#endif //==================== End Compiler-specific macros =============================== +#endif // __MWERKS__ +//=========================== End Compiler-specific macros =============================== //======================================================================================== NS_NAMESPACE nsFileStreamHelpers @@ -138,7 +146,7 @@ NS_NAMESPACE nsFileStreamHelpers { NS_NAMESPACE_PROTOTYPE PRFileDesc* open( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode); } NS_NAMESPACE_END // nsFileStreamHelpers @@ -172,7 +180,7 @@ public: bool is_open() const; filebuf_type* open( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode); filebuf_type* close(); @@ -181,10 +189,10 @@ protected: virtual int_type pbackfail(int_type c=traits::eof()); virtual int_type underflow(); virtual pos_type seekoff( - off_type off, ios::seekdir way, - ios::openmode which=ios::in|ios::out); + off_type off, IOS_BASE::seekdir way, + IOS_BASE::openmode which=IOS_BASE::in|IOS_BASE::out); virtual pos_type seekpos(pos_type sp, - ios::openmode which=ios::in|ios::out); + IOS_BASE::openmode which=IOS_BASE::in|IOS_BASE::out); virtual BASIC_STREAMBUF* setbuf(char_type* s, streamsize n); virtual int sync(); virtual int_type uflow(); @@ -195,7 +203,7 @@ protected: private: PRFileDesc* mFileDesc; - ios::openmode mode_; + IOS_BASE::openmode mode_; }; // class nsFileBufferT //======================================================================================== @@ -216,7 +224,7 @@ public: nsInputFileStreamT(); explicit nsInputFileStreamT( const nsFilePath& inFile, - ios::openmode mode=ios::in, + IOS_BASE::openmode mode=IOS_BASE::in, PRIntn accessMode = 0x00400); virtual ~nsInputFileStreamT(); @@ -225,7 +233,7 @@ public: inline bool is_open(); inline void open( const nsFilePath& inFile, - ios::openmode mode=ios::in, + IOS_BASE::openmode mode=IOS_BASE::in, PRIntn accessMode = 0x00400); inline void close(); @@ -251,7 +259,7 @@ public: nsOutputFileStreamT(); explicit nsOutputFileStreamT( const nsFilePath& inFile, - ios::openmode mode = ios::out|ios::trunc, + IOS_BASE::openmode mode = IOS_BASE::out|IOS_BASE::trunc, PRIntn accessMode = 0x00200); virtual ~nsOutputFileStreamT(); @@ -260,7 +268,7 @@ public: inline bool is_open(); inline void open( const nsFilePath& inFile, - ios::openmode mode = ios::out|ios::trunc, + IOS_BASE::openmode mode = IOS_BASE::out|IOS_BASE::trunc, PRIntn accessMode = 0x00200); inline void close(); @@ -310,7 +318,7 @@ nsFileBufferT::is_open() const template nsFileBufferT* nsFileBufferT::open( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- { @@ -501,18 +509,18 @@ nsFileBufferT::showmanyc() template nsFileBufferT::pos_type nsFileBufferT::seekoff( off_type off, - ios::seekdir way, - ios::openmode /* which */) + IOS_BASE::seekdir way, + IOS_BASE::openmode /* which */) //---------------------------------------------------------------------------------------- { - if (!mFileDesc || ((way&ios::beg) && off<0) || ((way&ios::end) && off > 0)) + if (!mFileDesc || ((way&IOS_BASE::beg) && off<0) || ((way&IOS_BASE::end) && off > 0)) return pos_type(-1); PRSeekWhence poseek = PR_SEEK_CUR; switch (way) { - case ios::beg : poseek= PR_SEEK_SET; + case IOS_BASE::beg : poseek= PR_SEEK_SET; break; - case ios::end : poseek= PR_SEEK_END; + case IOS_BASE::end : poseek= PR_SEEK_END; break; } PRInt32 position = PR_Seek(mFileDesc, off, poseek); @@ -524,7 +532,7 @@ nsFileBufferT::pos_type nsFileBufferT::seekoff( //---------------------------------------------------------------------------------------- template nsFileBufferT::pos_type -nsFileBufferT::seekpos(pos_type sp, ios::openmode) +nsFileBufferT::seekpos(pos_type sp, IOS_BASE::openmode) //---------------------------------------------------------------------------------------- { if (!mFileDesc || sp==pos_type(-1)) @@ -552,7 +560,7 @@ inline nsInputFileStreamT::nsInputFileStreamT() template inline nsInputFileStreamT::nsInputFileStreamT( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- : basic_istream(&mBuffer) @@ -592,7 +600,7 @@ template inline void nsInputFileStreamT::open( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- { @@ -626,7 +634,7 @@ inline nsOutputFileStreamT::nsOutputFileStreamT() template nsOutputFileStreamT::nsOutputFileStreamT( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- : basic_ostream(&mBuffer) @@ -664,7 +672,7 @@ inline bool nsOutputFileStreamT:: is_open() template inline void nsOutputFileStreamT::open( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- { @@ -698,7 +706,7 @@ public: nsIOFileStreamT(); explicit nsIOFileStreamT( const nsFilePath& inFile, - ios::openmode mode = ios::in|ios::out, + IOS_BASE::openmode mode = IOS_BASE::in|IOS_BASE::out, PRIntn accessMode = 0x00600); virtual ~nsIOFileStreamT(); @@ -707,7 +715,7 @@ public: inline bool is_open(); inline void open( const nsFilePath& inFile, - ios::openmode mode = ios::in|ios::out, + IOS_BASE::openmode mode = IOS_BASE::in|IOS_BASE::out, PRIntn accessMode = 0x00600); inline void close(); @@ -732,7 +740,7 @@ inline nsIOFileStreamT::nsIOFileStreamT() template inline nsIOFileStreamT::nsIOFileStreamT( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- : mBuffer(), basic_iostream(&mBuffer) @@ -770,7 +778,7 @@ template inline void nsIOFileStreamT::open( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- { diff --git a/base/src/nsFileStream.cpp b/base/src/nsFileStream.cpp index d61508c3f18..96e34b2465a 100644 --- a/base/src/nsFileStream.cpp +++ b/base/src/nsFileStream.cpp @@ -29,25 +29,25 @@ //---------------------------------------------------------------------------------------- PRFileDesc* nsFileStreamHelpers::open( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- { PRFileDesc* descriptor = 0; - const ios::openmode valid_modes[]= + const IOS_BASE::openmode valid_modes[]= { - ios::out, - ios::out | ios::app, - ios::out | ios::trunc, - ios::in, - ios::in | ios::out, - ios::in | ios::out | ios::trunc, -// ios::out | ios::binary, -// ios::out | ios::app | ios::binary, -// ios::out | ios::trunc | ios::binary, -// ios::in | ios::binary, -// ios::in | ios::out | ios::binary, -// ios::in | ios::out | ios::trunc | ios::binary, + IOS_BASE::out, + IOS_BASE::out | IOS_BASE::app, + IOS_BASE::out | IOS_BASE::trunc, + IOS_BASE::in, + IOS_BASE::in | IOS_BASE::out, + IOS_BASE::in | IOS_BASE::out | IOS_BASE::trunc, +// IOS_BASE::out | IOS_BASE::binary, +// IOS_BASE::out | IOS_BASE::app | IOS_BASE::binary, +// IOS_BASE::out | IOS_BASE::trunc | IOS_BASE::binary, +// IOS_BASE::in | IOS_BASE::binary, +// IOS_BASE::in | IOS_BASE::out | IOS_BASE::binary, +// IOS_BASE::in | IOS_BASE::out | IOS_BASE::trunc | IOS_BASE::binary, 0 }; @@ -67,7 +67,7 @@ PRFileDesc* nsFileStreamHelpers::open( // "w+b", 0 }; int ind=0; - while (valid_modes[ind] && valid_modes[ind] != (mode&~ios::ate)) + while (valid_modes[ind] && valid_modes[ind] != (mode&~IOS_BASE::ate)) ++ind; if (!nspr_modes[ind]) return 0; @@ -118,7 +118,7 @@ PRFileDesc* nsFileStreamHelpers::open( // Platforms other than Macintosh... if ((descriptor = PR_Open(inFile, nspr_modes[ind], accessMode)) != 0) #endif - if (mode&ios::ate && PR_Seek(descriptor, 0, PR_SEEK_END) >= 0) + if (mode&IOS_BASE::ate && PR_Seek(descriptor, 0, PR_SEEK_END) >= 0) { PR_Close(descriptor); descriptor = 0; diff --git a/xpcom/io/nsFileStream.cpp b/xpcom/io/nsFileStream.cpp index d61508c3f18..96e34b2465a 100644 --- a/xpcom/io/nsFileStream.cpp +++ b/xpcom/io/nsFileStream.cpp @@ -29,25 +29,25 @@ //---------------------------------------------------------------------------------------- PRFileDesc* nsFileStreamHelpers::open( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- { PRFileDesc* descriptor = 0; - const ios::openmode valid_modes[]= + const IOS_BASE::openmode valid_modes[]= { - ios::out, - ios::out | ios::app, - ios::out | ios::trunc, - ios::in, - ios::in | ios::out, - ios::in | ios::out | ios::trunc, -// ios::out | ios::binary, -// ios::out | ios::app | ios::binary, -// ios::out | ios::trunc | ios::binary, -// ios::in | ios::binary, -// ios::in | ios::out | ios::binary, -// ios::in | ios::out | ios::trunc | ios::binary, + IOS_BASE::out, + IOS_BASE::out | IOS_BASE::app, + IOS_BASE::out | IOS_BASE::trunc, + IOS_BASE::in, + IOS_BASE::in | IOS_BASE::out, + IOS_BASE::in | IOS_BASE::out | IOS_BASE::trunc, +// IOS_BASE::out | IOS_BASE::binary, +// IOS_BASE::out | IOS_BASE::app | IOS_BASE::binary, +// IOS_BASE::out | IOS_BASE::trunc | IOS_BASE::binary, +// IOS_BASE::in | IOS_BASE::binary, +// IOS_BASE::in | IOS_BASE::out | IOS_BASE::binary, +// IOS_BASE::in | IOS_BASE::out | IOS_BASE::trunc | IOS_BASE::binary, 0 }; @@ -67,7 +67,7 @@ PRFileDesc* nsFileStreamHelpers::open( // "w+b", 0 }; int ind=0; - while (valid_modes[ind] && valid_modes[ind] != (mode&~ios::ate)) + while (valid_modes[ind] && valid_modes[ind] != (mode&~IOS_BASE::ate)) ++ind; if (!nspr_modes[ind]) return 0; @@ -118,7 +118,7 @@ PRFileDesc* nsFileStreamHelpers::open( // Platforms other than Macintosh... if ((descriptor = PR_Open(inFile, nspr_modes[ind], accessMode)) != 0) #endif - if (mode&ios::ate && PR_Seek(descriptor, 0, PR_SEEK_END) >= 0) + if (mode&IOS_BASE::ate && PR_Seek(descriptor, 0, PR_SEEK_END) >= 0) { PR_Close(descriptor); descriptor = 0; diff --git a/xpcom/io/nsFileStream.h b/xpcom/io/nsFileStream.h index 88ce60a622c..949a4139543 100644 --- a/xpcom/io/nsFileStream.h +++ b/xpcom/io/nsFileStream.h @@ -92,6 +92,8 @@ #define NS_NAMESPACE namespace #define NS_NAMESPACE_END #define BASIC_STREAMBUF basic_streambuf +#define IOS_BASE ios_base + #include using std::ios_base; using std::basic_streambuf; @@ -103,13 +105,18 @@ using std::basic_ostream; using std::basic_iostream; using std::char_traits; + #else -#include + #define NS_NAMESPACE_PROTOTYPE static #define NS_NAMESPACE struct #define NS_NAMESPACE_END ; #define BASIC_STREAMBUF streambuf -#endif +#define IOS_BASE ios + +#include + +#endif // NS_USING_NAMESPACE #ifdef __MWERKS__ @@ -128,7 +135,8 @@ #define NS_READ_LOCK(mut) #define NS_WRITE_LOCK(mut) -#endif //==================== End Compiler-specific macros =============================== +#endif // __MWERKS__ +//=========================== End Compiler-specific macros =============================== //======================================================================================== NS_NAMESPACE nsFileStreamHelpers @@ -138,7 +146,7 @@ NS_NAMESPACE nsFileStreamHelpers { NS_NAMESPACE_PROTOTYPE PRFileDesc* open( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode); } NS_NAMESPACE_END // nsFileStreamHelpers @@ -172,7 +180,7 @@ public: bool is_open() const; filebuf_type* open( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode); filebuf_type* close(); @@ -181,10 +189,10 @@ protected: virtual int_type pbackfail(int_type c=traits::eof()); virtual int_type underflow(); virtual pos_type seekoff( - off_type off, ios::seekdir way, - ios::openmode which=ios::in|ios::out); + off_type off, IOS_BASE::seekdir way, + IOS_BASE::openmode which=IOS_BASE::in|IOS_BASE::out); virtual pos_type seekpos(pos_type sp, - ios::openmode which=ios::in|ios::out); + IOS_BASE::openmode which=IOS_BASE::in|IOS_BASE::out); virtual BASIC_STREAMBUF* setbuf(char_type* s, streamsize n); virtual int sync(); virtual int_type uflow(); @@ -195,7 +203,7 @@ protected: private: PRFileDesc* mFileDesc; - ios::openmode mode_; + IOS_BASE::openmode mode_; }; // class nsFileBufferT //======================================================================================== @@ -216,7 +224,7 @@ public: nsInputFileStreamT(); explicit nsInputFileStreamT( const nsFilePath& inFile, - ios::openmode mode=ios::in, + IOS_BASE::openmode mode=IOS_BASE::in, PRIntn accessMode = 0x00400); virtual ~nsInputFileStreamT(); @@ -225,7 +233,7 @@ public: inline bool is_open(); inline void open( const nsFilePath& inFile, - ios::openmode mode=ios::in, + IOS_BASE::openmode mode=IOS_BASE::in, PRIntn accessMode = 0x00400); inline void close(); @@ -251,7 +259,7 @@ public: nsOutputFileStreamT(); explicit nsOutputFileStreamT( const nsFilePath& inFile, - ios::openmode mode = ios::out|ios::trunc, + IOS_BASE::openmode mode = IOS_BASE::out|IOS_BASE::trunc, PRIntn accessMode = 0x00200); virtual ~nsOutputFileStreamT(); @@ -260,7 +268,7 @@ public: inline bool is_open(); inline void open( const nsFilePath& inFile, - ios::openmode mode = ios::out|ios::trunc, + IOS_BASE::openmode mode = IOS_BASE::out|IOS_BASE::trunc, PRIntn accessMode = 0x00200); inline void close(); @@ -310,7 +318,7 @@ nsFileBufferT::is_open() const template nsFileBufferT* nsFileBufferT::open( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- { @@ -501,18 +509,18 @@ nsFileBufferT::showmanyc() template nsFileBufferT::pos_type nsFileBufferT::seekoff( off_type off, - ios::seekdir way, - ios::openmode /* which */) + IOS_BASE::seekdir way, + IOS_BASE::openmode /* which */) //---------------------------------------------------------------------------------------- { - if (!mFileDesc || ((way&ios::beg) && off<0) || ((way&ios::end) && off > 0)) + if (!mFileDesc || ((way&IOS_BASE::beg) && off<0) || ((way&IOS_BASE::end) && off > 0)) return pos_type(-1); PRSeekWhence poseek = PR_SEEK_CUR; switch (way) { - case ios::beg : poseek= PR_SEEK_SET; + case IOS_BASE::beg : poseek= PR_SEEK_SET; break; - case ios::end : poseek= PR_SEEK_END; + case IOS_BASE::end : poseek= PR_SEEK_END; break; } PRInt32 position = PR_Seek(mFileDesc, off, poseek); @@ -524,7 +532,7 @@ nsFileBufferT::pos_type nsFileBufferT::seekoff( //---------------------------------------------------------------------------------------- template nsFileBufferT::pos_type -nsFileBufferT::seekpos(pos_type sp, ios::openmode) +nsFileBufferT::seekpos(pos_type sp, IOS_BASE::openmode) //---------------------------------------------------------------------------------------- { if (!mFileDesc || sp==pos_type(-1)) @@ -552,7 +560,7 @@ inline nsInputFileStreamT::nsInputFileStreamT() template inline nsInputFileStreamT::nsInputFileStreamT( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- : basic_istream(&mBuffer) @@ -592,7 +600,7 @@ template inline void nsInputFileStreamT::open( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- { @@ -626,7 +634,7 @@ inline nsOutputFileStreamT::nsOutputFileStreamT() template nsOutputFileStreamT::nsOutputFileStreamT( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- : basic_ostream(&mBuffer) @@ -664,7 +672,7 @@ inline bool nsOutputFileStreamT:: is_open() template inline void nsOutputFileStreamT::open( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- { @@ -698,7 +706,7 @@ public: nsIOFileStreamT(); explicit nsIOFileStreamT( const nsFilePath& inFile, - ios::openmode mode = ios::in|ios::out, + IOS_BASE::openmode mode = IOS_BASE::in|IOS_BASE::out, PRIntn accessMode = 0x00600); virtual ~nsIOFileStreamT(); @@ -707,7 +715,7 @@ public: inline bool is_open(); inline void open( const nsFilePath& inFile, - ios::openmode mode = ios::in|ios::out, + IOS_BASE::openmode mode = IOS_BASE::in|IOS_BASE::out, PRIntn accessMode = 0x00600); inline void close(); @@ -732,7 +740,7 @@ inline nsIOFileStreamT::nsIOFileStreamT() template inline nsIOFileStreamT::nsIOFileStreamT( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- : mBuffer(), basic_iostream(&mBuffer) @@ -770,7 +778,7 @@ template inline void nsIOFileStreamT::open( const nsFilePath& inFile, - ios::openmode mode, + IOS_BASE::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- {