diff --git a/base/public/nsFileSpec.h b/base/public/nsFileSpec.h index 53bee8a9b104..55a2416dd78a 100644 --- a/base/public/nsFileSpec.h +++ b/base/public/nsFileSpec.h @@ -158,13 +158,13 @@ class nsNativeFileSpec StringPtr GetLeafPName() { return mSpec.name; } ConstStr255Param GetLeafPName() const { return mSpec.name; } #else - bool Valid() const { return TRUE; } // Fixme. + bool Valid() const { return true; } // Fixme. #endif #if DEBUG - friend ostream& operator << (ostream& s, const nsNativeFileSpec& spec); + friend std::ostream& operator << (std::ostream& s, const nsNativeFileSpec& spec); #endif - string GetLeafName() const; + std::string GetLeafName() const; void SetLeafName(const std::string& inLeafName); bool Exists() const; void MakeUnique(); @@ -175,7 +175,7 @@ class nsNativeFileSpec #ifdef XP_MAC FSSpec mSpec; OSErr mError; -#elif defined(XP_UNIX) || defined(XP_WIN) +#elif defined(XP_UNIX) || defined(XP_PC) std::string mPath; #endif }; // class nsNativeFileSpec @@ -321,7 +321,7 @@ inline void nsNativeFileSpec::operator = (const nsFilePath& inPath) } #endif //XP_UNIX -#if defined(XP_UNIX) || defined(XP_WIN) +#if defined(XP_UNIX) || defined(XP_PC) //---------------------------------------------------------------------------------------- inline nsNativeFileSpec::nsNativeFileSpec(const nsNativeFileSpec& inSpec) //---------------------------------------------------------------------------------------- @@ -330,7 +330,7 @@ inline nsNativeFileSpec::nsNativeFileSpec(const nsNativeFileSpec& inSpec) } #endif //XP_UNIX -#if defined(XP_UNIX) || defined(XP_WIN) +#if defined(XP_UNIX) || defined(XP_PC) //---------------------------------------------------------------------------------------- inline nsNativeFileSpec::nsNativeFileSpec(const std::string& inString) //---------------------------------------------------------------------------------------- @@ -339,7 +339,7 @@ inline nsNativeFileSpec::nsNativeFileSpec(const std::string& inString) } #endif //XP_UNIX -#if defined(XP_UNIX) || defined(XP_WIN) +#if defined(XP_UNIX) || defined(XP_PC) //---------------------------------------------------------------------------------------- inline void nsNativeFileSpec::operator = (const nsNativeFileSpec& inSpec) //---------------------------------------------------------------------------------------- @@ -349,18 +349,18 @@ inline void nsNativeFileSpec::operator = (const nsNativeFileSpec& inSpec) #endif //XP_UNIX -#if defined(XP_UNIX) || defined(XP_WIN) +#if defined(XP_UNIX) || defined(XP_PC) //---------------------------------------------------------------------------------------- -inline nsNativeFileSpec::operator = (const std::string& inString) +inline void nsNativeFileSpec::operator = (const std::string& inString) //---------------------------------------------------------------------------------------- { mPath = inString; } #endif //XP_UNIX -#if (defined(XP_UNIX) || defined(XP_WIN)) && DEBUG +#if (defined(XP_UNIX) || defined(XP_PC)) && DEBUG //---------------------------------------------------------------------------------------- -inline ostream& operator << (ostream& s, const nsNativeFileSpec& spec) +inline std::ostream& operator << (std::ostream& s, const nsNativeFileSpec& spec) //---------------------------------------------------------------------------------------- { return (s << (std::string&)spec.mPath); diff --git a/base/public/nsFileStream.h b/base/public/nsFileStream.h index 4a265fbd401a..de06035e9d1e 100644 --- a/base/public/nsFileStream.h +++ b/base/public/nsFileStream.h @@ -110,7 +110,7 @@ namespace nsFileStreamHelpers { PRFileDesc* open( const nsFilePath& inFile, - ios_base::openmode mode, + std::ios_base::openmode mode, PRIntn accessMode); } // nsFileStreamHelpers @@ -122,9 +122,9 @@ namespace nsFileStreamHelpers template class nsFileBufferT //======================================================================================== -: public basic_streambuf +: public std::basic_streambuf { - typedef codecvt_base::result result; + typedef std::codecvt_base::result result; public: typedef charT char_type; @@ -135,8 +135,8 @@ public: typedef typename traits::state_type state_type; typedef nsFileBufferT filebuf_type; - typedef codecvt ofacet_type; - typedef codecvt ifacet_type; + typedef std::codecvt ofacet_type; + typedef std::codecvt ifacet_type; nsFileBufferT(); nsFileBufferT(PRFileDesc* pfile_arg); @@ -144,7 +144,7 @@ public: bool is_open() const; filebuf_type* open( const nsFilePath& inFile, - ios_base::openmode mode, + std::ios_base::openmode mode, PRIntn accessMode); filebuf_type* close(); @@ -153,28 +153,28 @@ protected: virtual int_type pbackfail(int_type c=traits::eof()); virtual int_type underflow(); virtual pos_type seekoff( - off_type off, ios_base::seekdir way, - ios_base::openmode which=ios_base::in|ios_base::out); + off_type off, std::ios_base::seekdir way, + std::ios_base::openmode which=std::ios_base::in|std::ios_base::out); virtual pos_type seekpos(pos_type sp, - ios_base::openmode which=ios_base::in|ios_base::out); - virtual basic_streambuf* setbuf(char_type* s, streamsize n); + std::ios_base::openmode which=std::ios_base::in|std::ios_base::out); + virtual std::basic_streambuf* setbuf(char_type* s, std::streamsize n); virtual int sync(); virtual int_type uflow(); - virtual void imbue(const locale& loc); - virtual streamsize showmanyc(); - virtual streamsize xsgetn(char_type* s, streamsize n); - virtual streamsize xsputn(const char_type* s, streamsize n); + virtual void imbue(const std::locale& loc); + virtual std::streamsize showmanyc(); + virtual std::streamsize xsgetn(char_type* s, std::streamsize n); + virtual std::streamsize xsputn(const char_type* s, std::streamsize n); private: PRFileDesc* mFileDesc; - ios_base::openmode mode_; + std::ios_base::openmode mode_; }; // class nsFileBufferT //======================================================================================== template class nsInputFileStreamT //======================================================================================== -: public basic_istream +: public std::basic_istream { typedef nsFileBufferT filebuf_type; @@ -188,7 +188,7 @@ public: nsInputFileStreamT(); explicit nsInputFileStreamT( const nsFilePath& inFile, - ios_base::openmode mode=ios_base::in, + std::ios_base::openmode mode=std::ios_base::in, PRIntn accessMode = 0x00400); virtual ~nsInputFileStreamT(); @@ -197,7 +197,7 @@ public: inline bool is_open(); inline void open( const nsFilePath& inFile, - ios_base::openmode mode=ios_base::in, + std::ios_base::openmode mode=std::ios_base::in, PRIntn accessMode = 0x00400); inline void close(); @@ -209,7 +209,7 @@ private: template class nsOutputFileStreamT //======================================================================================== -: public basic_ostream +: public std::basic_ostream { typedef nsFileBufferT filebuf_type; @@ -283,7 +283,7 @@ template nsFileBufferT::filebuf_type* nsFileBufferT::open( const nsFilePath& inFile, - ios_base::openmode mode, + std::ios_base::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- { @@ -319,8 +319,8 @@ nsFileBufferT:: sync() //---------------------------------------------------------------------------------------- template -inline basic_streambuf* -nsFileBufferT::setbuf(char_type*, streamsize) +inline std::basic_streambuf* +nsFileBufferT::setbuf(char_type*, std::streamsize) //---------------------------------------------------------------------------------------- { return (!mFileDesc) ? 0 : this; @@ -383,7 +383,7 @@ inline nsFileBufferT::int_type nsFileBufferT::unde //---------------------------------------------------------------------------------------- template -streamsize nsFileBufferT::xsputn(const char_type* s, streamsize n) +std::streamsize nsFileBufferT::xsputn(const char_type* s, std::streamsize n) //---------------------------------------------------------------------------------------- { #ifdef NS_EXPLICIT_FUNC_TEMPLATE_ARG @@ -449,36 +449,36 @@ inline nsFileBufferT::int_type nsFileBufferT::uflo //---------------------------------------------------------------------------------------- template -inline streamsize nsFileBufferT::xsgetn(char_type* s, streamsize n) +inline std::streamsize nsFileBufferT::xsgetn(char_type* s, std::streamsize n) //---------------------------------------------------------------------------------------- { - return mFileDesc ? (streamsize)PR_Read(mFileDesc, s, sizeof(char) * size_t(n)) : 0; + return mFileDesc ? (std::streamsize)PR_Read(mFileDesc, s, sizeof(char) * size_t(n)) : 0; } //---------------------------------------------------------------------------------------- template -inline void nsFileBufferT::imbue(const locale& loc_arg) +inline void nsFileBufferT::imbue(const std::locale& loc_arg) //---------------------------------------------------------------------------------------- { loc = loc_arg; } template -inline streamsize +inline std::streamsize nsFileBufferT::showmanyc() { - return (streamsize)PR_Available(mFileDesc); + return (std::streamsize)PR_Available(mFileDesc); } //---------------------------------------------------------------------------------------- template nsFileBufferT::pos_type nsFileBufferT::seekoff( off_type off, - ios_base::seekdir way, - ios_base::openmode /* which */) + std::ios_base::seekdir way, + std::ios_base::openmode /* which */) //---------------------------------------------------------------------------------------- { - if (!mFileDesc || ((way&ios_base::beg) && off<0) || ((way&ios_base::end) && off > 0)) + if (!mFileDesc || ((way&std::ios_base::beg) && off<0) || ((way&std::ios_base::end) && off > 0)) return pos_type(-1); PRSeekWhence poseek = PR_SEEK_CUR; switch (way) @@ -497,7 +497,7 @@ nsFileBufferT::pos_type nsFileBufferT::seekoff( //---------------------------------------------------------------------------------------- template nsFileBufferT::pos_type -nsFileBufferT::seekpos(pos_type sp, ios_base::openmode) +nsFileBufferT::seekpos(pos_type sp, std::ios_base::openmode) //---------------------------------------------------------------------------------------- { if (!mFileDesc || sp==pos_type(-1)) @@ -656,7 +656,7 @@ inline void nsOutputFileStreamT:: close() //======================================================================================== template -class nsIOFileStreamT : public basic_iostream +class nsIOFileStreamT : public std::basic_iostream //======================================================================================== { typedef nsFileBufferT filebuf_type; @@ -671,7 +671,7 @@ public: nsIOFileStreamT(); explicit nsIOFileStreamT( const nsFilePath& inFile, - ios_base::openmode mode = ios_base::in|ios_base::out, + std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out, PRIntn accessMode = 0x00600); virtual ~nsIOFileStreamT(); @@ -680,7 +680,7 @@ public: inline bool is_open(); inline void open( const nsFilePath& inFile, - ios_base::openmode mode = ios_base::in|ios_base::out, + std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out, PRIntn accessMode = 0x00600); inline void close(); @@ -765,16 +765,16 @@ nsIOFileStreamT::close() // Specializations of the stream templates //======================================================================================== -typedef nsFileBufferT > nsFileBuffer; -typedef nsInputFileStreamT > nsInputFileStream; -typedef nsOutputFileStreamT > nsOutputFileStream; -typedef nsIOFileStreamT > nsIOFileStream; +typedef nsFileBufferT > nsFileBuffer; +typedef nsInputFileStreamT > nsInputFileStream; +typedef nsOutputFileStreamT > nsOutputFileStream; +typedef nsIOFileStreamT > nsIOFileStream; #ifdef NS_USING_WIDE_CHAR -typedef nsFileBufferT > nsWideFileBuffer; -typedef nsInputFileStreamT > nsWideInputFileStream; -typedef nsOutputFileStreamT > nsWideOutputFileStream; -typedef nsIOFileStreamT > nsWideIOFileStream; +typedef nsFileBufferT > nsWideFileBuffer; +typedef nsInputFileStreamT > nsWideInputFileStream; +typedef nsOutputFileStreamT > nsWideOutputFileStream; +typedef nsIOFileStreamT > nsWideIOFileStream; #endif // NS_USING_WIDE_CHAR #endif /* _FILESTREAM_H_ */ diff --git a/base/src/nsFileSpec.cpp b/base/src/nsFileSpec.cpp index dfb71190bcbd..99888d5ab790 100644 --- a/base/src/nsFileSpec.cpp +++ b/base/src/nsFileSpec.cpp @@ -70,7 +70,7 @@ std::string nsFileSpecHelpers::GetLeaf(const std::string& inPath, char inSeparat #ifdef XP_MAC #include "nsFileSpecMac.cpp" // Macintosh-specific implementations -#elif defined(XP_WIN) +#elif defined(XP_PC) #include "nsFileSpecWin.cpp" // Windows-specific implementations #elif defined(XP_UNIX) #include "nsFileSpecUnix.cpp" // Unix-specific implementations @@ -128,7 +128,7 @@ void nsFileURL::operator = (const nsFileURL& inOther) nsFileURL::nsFileURL(const nsFilePath& inOther) //---------------------------------------------------------------------------------------- { - mURL = kFileURLPrefix + ((string&)inOther); + mURL = kFileURLPrefix + ((std::string&)inOther); #ifdef XP_MAC mNativeFileSpec = inOther.GetNativeSpec(); #endif @@ -137,7 +137,7 @@ nsFileURL::nsFileURL(const nsFilePath& inOther) void nsFileURL::operator = (const nsFilePath& inOther) //---------------------------------------------------------------------------------------- { - mURL = kFileURLPrefix + ((string&)inOther); + mURL = kFileURLPrefix + ((std::string&)inOther); #ifdef XP_MAC mNativeFileSpec = inOther.GetNativeSpec(); #endif @@ -180,8 +180,8 @@ nsFilePath::nsFilePath(const std::string& inString) //---------------------------------------------------------------------------------------- nsFilePath::nsFilePath(const nsFileURL& inOther) //---------------------------------------------------------------------------------------- -: mPath(((string&)inOther).substr( - kFileURLPrefixLength, ((string&)inOther).length() - kFileURLPrefixLength)) +: mPath(((std::string&)inOther).substr( + kFileURLPrefixLength, ((std::string&)inOther).length() - kFileURLPrefixLength)) #ifdef XP_MAC , mNativeFileSpec(inOther.GetNativeSpec()) #endif @@ -203,8 +203,8 @@ void nsFilePath::operator = (const std::string& inString) void nsFilePath::operator = (const nsFileURL& inOther) //---------------------------------------------------------------------------------------- { - mPath = ((string&)inOther).substr( - kFileURLPrefixLength, ((string&)inOther).length() - kFileURLPrefixLength); + mPath = ((std::string&)inOther).substr( + kFileURLPrefixLength, ((std::string&)inOther).length() - kFileURLPrefixLength); #ifdef XP_MAC mNativeFileSpec = inOther.GetNativeSpec(); #endif @@ -258,8 +258,8 @@ void nsNativeFileSpec::MakeUnique() if ( ++index > 999 ) // something's very wrong return; char buf[nsFileSpecHelpers::kMaxFilenameLength + 1]; - ostrstream newName(buf, nsFileSpecHelpers::kMaxFilenameLength); - newName << altName.c_str() << "-" << index << suffix.c_str() << ends; + std::ostrstream newName(buf, nsFileSpecHelpers::kMaxFilenameLength); + newName << altName.c_str() << "-" << index << suffix.c_str() << std::ends; SetLeafName(newName.str()); // or: SetLeafName(buf) } } // nsNativeFileSpec::MakeUnique diff --git a/base/src/nsFileStream.cpp b/base/src/nsFileStream.cpp index 6a35185d4e72..bd64d35127fb 100644 --- a/base/src/nsFileStream.cpp +++ b/base/src/nsFileStream.cpp @@ -26,6 +26,8 @@ #include #endif +using std::ios_base; + //---------------------------------------------------------------------------------------- PRFileDesc* nsFileStreamHelpers::open( const nsFilePath& inFile, diff --git a/base/src/windows/nsFileSpecWin.cpp b/base/src/windows/nsFileSpecWin.cpp index fcc076458433..f8371e0fe460 100644 --- a/base/src/windows/nsFileSpecWin.cpp +++ b/base/src/windows/nsFileSpecWin.cpp @@ -41,17 +41,39 @@ void nsNativeFileSpec::operator = (const nsFilePath& inPath) } } // nsNativeFileSpec::operator = +//---------------------------------------------------------------------------------------- +nsFilePath::nsFilePath(const nsNativeFileSpec& inSpec) +//---------------------------------------------------------------------------------------- +{ + // Convert '\' to '/' + std::string& str = (std::string&)inSpec; + for (std::string::size_type i = 0; i < str.length(); i++) + { + char c = str[i]; + if (c == '\\') + c = '/'; + mPath.append(&c, 1); + } +} // nsFilePath::nsFilePath + //---------------------------------------------------------------------------------------- void nsNativeFileSpec::SetLeafName(const std::string& inLeafName) //---------------------------------------------------------------------------------------- { - nsFileHelpers::LeafReplace(mPath, '\\', inLeafName); + nsFileSpecHelpers::LeafReplace(mPath, '\\', inLeafName); } // nsNativeFileSpec::SetLeafName //---------------------------------------------------------------------------------------- std::string nsNativeFileSpec::GetLeafName() const //---------------------------------------------------------------------------------------- { - return nsFileHelpers::GetLeaf(mPath, '\\'); + return nsFileSpecHelpers::GetLeaf(mPath, '\\'); } // nsNativeFileSpec::GetLeafName +//---------------------------------------------------------------------------------------- +bool nsNativeFileSpec::Exists() const +//---------------------------------------------------------------------------------------- +{ + return false; // fixme +} // nsNativeFileSpec::Exists + diff --git a/xpcom/io/nsFileSpec.cpp b/xpcom/io/nsFileSpec.cpp index dfb71190bcbd..99888d5ab790 100644 --- a/xpcom/io/nsFileSpec.cpp +++ b/xpcom/io/nsFileSpec.cpp @@ -70,7 +70,7 @@ std::string nsFileSpecHelpers::GetLeaf(const std::string& inPath, char inSeparat #ifdef XP_MAC #include "nsFileSpecMac.cpp" // Macintosh-specific implementations -#elif defined(XP_WIN) +#elif defined(XP_PC) #include "nsFileSpecWin.cpp" // Windows-specific implementations #elif defined(XP_UNIX) #include "nsFileSpecUnix.cpp" // Unix-specific implementations @@ -128,7 +128,7 @@ void nsFileURL::operator = (const nsFileURL& inOther) nsFileURL::nsFileURL(const nsFilePath& inOther) //---------------------------------------------------------------------------------------- { - mURL = kFileURLPrefix + ((string&)inOther); + mURL = kFileURLPrefix + ((std::string&)inOther); #ifdef XP_MAC mNativeFileSpec = inOther.GetNativeSpec(); #endif @@ -137,7 +137,7 @@ nsFileURL::nsFileURL(const nsFilePath& inOther) void nsFileURL::operator = (const nsFilePath& inOther) //---------------------------------------------------------------------------------------- { - mURL = kFileURLPrefix + ((string&)inOther); + mURL = kFileURLPrefix + ((std::string&)inOther); #ifdef XP_MAC mNativeFileSpec = inOther.GetNativeSpec(); #endif @@ -180,8 +180,8 @@ nsFilePath::nsFilePath(const std::string& inString) //---------------------------------------------------------------------------------------- nsFilePath::nsFilePath(const nsFileURL& inOther) //---------------------------------------------------------------------------------------- -: mPath(((string&)inOther).substr( - kFileURLPrefixLength, ((string&)inOther).length() - kFileURLPrefixLength)) +: mPath(((std::string&)inOther).substr( + kFileURLPrefixLength, ((std::string&)inOther).length() - kFileURLPrefixLength)) #ifdef XP_MAC , mNativeFileSpec(inOther.GetNativeSpec()) #endif @@ -203,8 +203,8 @@ void nsFilePath::operator = (const std::string& inString) void nsFilePath::operator = (const nsFileURL& inOther) //---------------------------------------------------------------------------------------- { - mPath = ((string&)inOther).substr( - kFileURLPrefixLength, ((string&)inOther).length() - kFileURLPrefixLength); + mPath = ((std::string&)inOther).substr( + kFileURLPrefixLength, ((std::string&)inOther).length() - kFileURLPrefixLength); #ifdef XP_MAC mNativeFileSpec = inOther.GetNativeSpec(); #endif @@ -258,8 +258,8 @@ void nsNativeFileSpec::MakeUnique() if ( ++index > 999 ) // something's very wrong return; char buf[nsFileSpecHelpers::kMaxFilenameLength + 1]; - ostrstream newName(buf, nsFileSpecHelpers::kMaxFilenameLength); - newName << altName.c_str() << "-" << index << suffix.c_str() << ends; + std::ostrstream newName(buf, nsFileSpecHelpers::kMaxFilenameLength); + newName << altName.c_str() << "-" << index << suffix.c_str() << std::ends; SetLeafName(newName.str()); // or: SetLeafName(buf) } } // nsNativeFileSpec::MakeUnique diff --git a/xpcom/io/nsFileSpec.h b/xpcom/io/nsFileSpec.h index 53bee8a9b104..55a2416dd78a 100644 --- a/xpcom/io/nsFileSpec.h +++ b/xpcom/io/nsFileSpec.h @@ -158,13 +158,13 @@ class nsNativeFileSpec StringPtr GetLeafPName() { return mSpec.name; } ConstStr255Param GetLeafPName() const { return mSpec.name; } #else - bool Valid() const { return TRUE; } // Fixme. + bool Valid() const { return true; } // Fixme. #endif #if DEBUG - friend ostream& operator << (ostream& s, const nsNativeFileSpec& spec); + friend std::ostream& operator << (std::ostream& s, const nsNativeFileSpec& spec); #endif - string GetLeafName() const; + std::string GetLeafName() const; void SetLeafName(const std::string& inLeafName); bool Exists() const; void MakeUnique(); @@ -175,7 +175,7 @@ class nsNativeFileSpec #ifdef XP_MAC FSSpec mSpec; OSErr mError; -#elif defined(XP_UNIX) || defined(XP_WIN) +#elif defined(XP_UNIX) || defined(XP_PC) std::string mPath; #endif }; // class nsNativeFileSpec @@ -321,7 +321,7 @@ inline void nsNativeFileSpec::operator = (const nsFilePath& inPath) } #endif //XP_UNIX -#if defined(XP_UNIX) || defined(XP_WIN) +#if defined(XP_UNIX) || defined(XP_PC) //---------------------------------------------------------------------------------------- inline nsNativeFileSpec::nsNativeFileSpec(const nsNativeFileSpec& inSpec) //---------------------------------------------------------------------------------------- @@ -330,7 +330,7 @@ inline nsNativeFileSpec::nsNativeFileSpec(const nsNativeFileSpec& inSpec) } #endif //XP_UNIX -#if defined(XP_UNIX) || defined(XP_WIN) +#if defined(XP_UNIX) || defined(XP_PC) //---------------------------------------------------------------------------------------- inline nsNativeFileSpec::nsNativeFileSpec(const std::string& inString) //---------------------------------------------------------------------------------------- @@ -339,7 +339,7 @@ inline nsNativeFileSpec::nsNativeFileSpec(const std::string& inString) } #endif //XP_UNIX -#if defined(XP_UNIX) || defined(XP_WIN) +#if defined(XP_UNIX) || defined(XP_PC) //---------------------------------------------------------------------------------------- inline void nsNativeFileSpec::operator = (const nsNativeFileSpec& inSpec) //---------------------------------------------------------------------------------------- @@ -349,18 +349,18 @@ inline void nsNativeFileSpec::operator = (const nsNativeFileSpec& inSpec) #endif //XP_UNIX -#if defined(XP_UNIX) || defined(XP_WIN) +#if defined(XP_UNIX) || defined(XP_PC) //---------------------------------------------------------------------------------------- -inline nsNativeFileSpec::operator = (const std::string& inString) +inline void nsNativeFileSpec::operator = (const std::string& inString) //---------------------------------------------------------------------------------------- { mPath = inString; } #endif //XP_UNIX -#if (defined(XP_UNIX) || defined(XP_WIN)) && DEBUG +#if (defined(XP_UNIX) || defined(XP_PC)) && DEBUG //---------------------------------------------------------------------------------------- -inline ostream& operator << (ostream& s, const nsNativeFileSpec& spec) +inline std::ostream& operator << (std::ostream& s, const nsNativeFileSpec& spec) //---------------------------------------------------------------------------------------- { return (s << (std::string&)spec.mPath); diff --git a/xpcom/io/nsFileSpecWin.cpp b/xpcom/io/nsFileSpecWin.cpp index fcc076458433..f8371e0fe460 100644 --- a/xpcom/io/nsFileSpecWin.cpp +++ b/xpcom/io/nsFileSpecWin.cpp @@ -41,17 +41,39 @@ void nsNativeFileSpec::operator = (const nsFilePath& inPath) } } // nsNativeFileSpec::operator = +//---------------------------------------------------------------------------------------- +nsFilePath::nsFilePath(const nsNativeFileSpec& inSpec) +//---------------------------------------------------------------------------------------- +{ + // Convert '\' to '/' + std::string& str = (std::string&)inSpec; + for (std::string::size_type i = 0; i < str.length(); i++) + { + char c = str[i]; + if (c == '\\') + c = '/'; + mPath.append(&c, 1); + } +} // nsFilePath::nsFilePath + //---------------------------------------------------------------------------------------- void nsNativeFileSpec::SetLeafName(const std::string& inLeafName) //---------------------------------------------------------------------------------------- { - nsFileHelpers::LeafReplace(mPath, '\\', inLeafName); + nsFileSpecHelpers::LeafReplace(mPath, '\\', inLeafName); } // nsNativeFileSpec::SetLeafName //---------------------------------------------------------------------------------------- std::string nsNativeFileSpec::GetLeafName() const //---------------------------------------------------------------------------------------- { - return nsFileHelpers::GetLeaf(mPath, '\\'); + return nsFileSpecHelpers::GetLeaf(mPath, '\\'); } // nsNativeFileSpec::GetLeafName +//---------------------------------------------------------------------------------------- +bool nsNativeFileSpec::Exists() const +//---------------------------------------------------------------------------------------- +{ + return false; // fixme +} // nsNativeFileSpec::Exists + diff --git a/xpcom/io/nsFileStream.cpp b/xpcom/io/nsFileStream.cpp index 6a35185d4e72..bd64d35127fb 100644 --- a/xpcom/io/nsFileStream.cpp +++ b/xpcom/io/nsFileStream.cpp @@ -26,6 +26,8 @@ #include #endif +using std::ios_base; + //---------------------------------------------------------------------------------------- PRFileDesc* nsFileStreamHelpers::open( const nsFilePath& inFile, diff --git a/xpcom/io/nsFileStream.h b/xpcom/io/nsFileStream.h index 4a265fbd401a..de06035e9d1e 100644 --- a/xpcom/io/nsFileStream.h +++ b/xpcom/io/nsFileStream.h @@ -110,7 +110,7 @@ namespace nsFileStreamHelpers { PRFileDesc* open( const nsFilePath& inFile, - ios_base::openmode mode, + std::ios_base::openmode mode, PRIntn accessMode); } // nsFileStreamHelpers @@ -122,9 +122,9 @@ namespace nsFileStreamHelpers template class nsFileBufferT //======================================================================================== -: public basic_streambuf +: public std::basic_streambuf { - typedef codecvt_base::result result; + typedef std::codecvt_base::result result; public: typedef charT char_type; @@ -135,8 +135,8 @@ public: typedef typename traits::state_type state_type; typedef nsFileBufferT filebuf_type; - typedef codecvt ofacet_type; - typedef codecvt ifacet_type; + typedef std::codecvt ofacet_type; + typedef std::codecvt ifacet_type; nsFileBufferT(); nsFileBufferT(PRFileDesc* pfile_arg); @@ -144,7 +144,7 @@ public: bool is_open() const; filebuf_type* open( const nsFilePath& inFile, - ios_base::openmode mode, + std::ios_base::openmode mode, PRIntn accessMode); filebuf_type* close(); @@ -153,28 +153,28 @@ protected: virtual int_type pbackfail(int_type c=traits::eof()); virtual int_type underflow(); virtual pos_type seekoff( - off_type off, ios_base::seekdir way, - ios_base::openmode which=ios_base::in|ios_base::out); + off_type off, std::ios_base::seekdir way, + std::ios_base::openmode which=std::ios_base::in|std::ios_base::out); virtual pos_type seekpos(pos_type sp, - ios_base::openmode which=ios_base::in|ios_base::out); - virtual basic_streambuf* setbuf(char_type* s, streamsize n); + std::ios_base::openmode which=std::ios_base::in|std::ios_base::out); + virtual std::basic_streambuf* setbuf(char_type* s, std::streamsize n); virtual int sync(); virtual int_type uflow(); - virtual void imbue(const locale& loc); - virtual streamsize showmanyc(); - virtual streamsize xsgetn(char_type* s, streamsize n); - virtual streamsize xsputn(const char_type* s, streamsize n); + virtual void imbue(const std::locale& loc); + virtual std::streamsize showmanyc(); + virtual std::streamsize xsgetn(char_type* s, std::streamsize n); + virtual std::streamsize xsputn(const char_type* s, std::streamsize n); private: PRFileDesc* mFileDesc; - ios_base::openmode mode_; + std::ios_base::openmode mode_; }; // class nsFileBufferT //======================================================================================== template class nsInputFileStreamT //======================================================================================== -: public basic_istream +: public std::basic_istream { typedef nsFileBufferT filebuf_type; @@ -188,7 +188,7 @@ public: nsInputFileStreamT(); explicit nsInputFileStreamT( const nsFilePath& inFile, - ios_base::openmode mode=ios_base::in, + std::ios_base::openmode mode=std::ios_base::in, PRIntn accessMode = 0x00400); virtual ~nsInputFileStreamT(); @@ -197,7 +197,7 @@ public: inline bool is_open(); inline void open( const nsFilePath& inFile, - ios_base::openmode mode=ios_base::in, + std::ios_base::openmode mode=std::ios_base::in, PRIntn accessMode = 0x00400); inline void close(); @@ -209,7 +209,7 @@ private: template class nsOutputFileStreamT //======================================================================================== -: public basic_ostream +: public std::basic_ostream { typedef nsFileBufferT filebuf_type; @@ -283,7 +283,7 @@ template nsFileBufferT::filebuf_type* nsFileBufferT::open( const nsFilePath& inFile, - ios_base::openmode mode, + std::ios_base::openmode mode, PRIntn accessMode) //---------------------------------------------------------------------------------------- { @@ -319,8 +319,8 @@ nsFileBufferT:: sync() //---------------------------------------------------------------------------------------- template -inline basic_streambuf* -nsFileBufferT::setbuf(char_type*, streamsize) +inline std::basic_streambuf* +nsFileBufferT::setbuf(char_type*, std::streamsize) //---------------------------------------------------------------------------------------- { return (!mFileDesc) ? 0 : this; @@ -383,7 +383,7 @@ inline nsFileBufferT::int_type nsFileBufferT::unde //---------------------------------------------------------------------------------------- template -streamsize nsFileBufferT::xsputn(const char_type* s, streamsize n) +std::streamsize nsFileBufferT::xsputn(const char_type* s, std::streamsize n) //---------------------------------------------------------------------------------------- { #ifdef NS_EXPLICIT_FUNC_TEMPLATE_ARG @@ -449,36 +449,36 @@ inline nsFileBufferT::int_type nsFileBufferT::uflo //---------------------------------------------------------------------------------------- template -inline streamsize nsFileBufferT::xsgetn(char_type* s, streamsize n) +inline std::streamsize nsFileBufferT::xsgetn(char_type* s, std::streamsize n) //---------------------------------------------------------------------------------------- { - return mFileDesc ? (streamsize)PR_Read(mFileDesc, s, sizeof(char) * size_t(n)) : 0; + return mFileDesc ? (std::streamsize)PR_Read(mFileDesc, s, sizeof(char) * size_t(n)) : 0; } //---------------------------------------------------------------------------------------- template -inline void nsFileBufferT::imbue(const locale& loc_arg) +inline void nsFileBufferT::imbue(const std::locale& loc_arg) //---------------------------------------------------------------------------------------- { loc = loc_arg; } template -inline streamsize +inline std::streamsize nsFileBufferT::showmanyc() { - return (streamsize)PR_Available(mFileDesc); + return (std::streamsize)PR_Available(mFileDesc); } //---------------------------------------------------------------------------------------- template nsFileBufferT::pos_type nsFileBufferT::seekoff( off_type off, - ios_base::seekdir way, - ios_base::openmode /* which */) + std::ios_base::seekdir way, + std::ios_base::openmode /* which */) //---------------------------------------------------------------------------------------- { - if (!mFileDesc || ((way&ios_base::beg) && off<0) || ((way&ios_base::end) && off > 0)) + if (!mFileDesc || ((way&std::ios_base::beg) && off<0) || ((way&std::ios_base::end) && off > 0)) return pos_type(-1); PRSeekWhence poseek = PR_SEEK_CUR; switch (way) @@ -497,7 +497,7 @@ nsFileBufferT::pos_type nsFileBufferT::seekoff( //---------------------------------------------------------------------------------------- template nsFileBufferT::pos_type -nsFileBufferT::seekpos(pos_type sp, ios_base::openmode) +nsFileBufferT::seekpos(pos_type sp, std::ios_base::openmode) //---------------------------------------------------------------------------------------- { if (!mFileDesc || sp==pos_type(-1)) @@ -656,7 +656,7 @@ inline void nsOutputFileStreamT:: close() //======================================================================================== template -class nsIOFileStreamT : public basic_iostream +class nsIOFileStreamT : public std::basic_iostream //======================================================================================== { typedef nsFileBufferT filebuf_type; @@ -671,7 +671,7 @@ public: nsIOFileStreamT(); explicit nsIOFileStreamT( const nsFilePath& inFile, - ios_base::openmode mode = ios_base::in|ios_base::out, + std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out, PRIntn accessMode = 0x00600); virtual ~nsIOFileStreamT(); @@ -680,7 +680,7 @@ public: inline bool is_open(); inline void open( const nsFilePath& inFile, - ios_base::openmode mode = ios_base::in|ios_base::out, + std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out, PRIntn accessMode = 0x00600); inline void close(); @@ -765,16 +765,16 @@ nsIOFileStreamT::close() // Specializations of the stream templates //======================================================================================== -typedef nsFileBufferT > nsFileBuffer; -typedef nsInputFileStreamT > nsInputFileStream; -typedef nsOutputFileStreamT > nsOutputFileStream; -typedef nsIOFileStreamT > nsIOFileStream; +typedef nsFileBufferT > nsFileBuffer; +typedef nsInputFileStreamT > nsInputFileStream; +typedef nsOutputFileStreamT > nsOutputFileStream; +typedef nsIOFileStreamT > nsIOFileStream; #ifdef NS_USING_WIDE_CHAR -typedef nsFileBufferT > nsWideFileBuffer; -typedef nsInputFileStreamT > nsWideInputFileStream; -typedef nsOutputFileStreamT > nsWideOutputFileStream; -typedef nsIOFileStreamT > nsWideIOFileStream; +typedef nsFileBufferT > nsWideFileBuffer; +typedef nsInputFileStreamT > nsWideInputFileStream; +typedef nsOutputFileStreamT > nsWideOutputFileStream; +typedef nsIOFileStreamT > nsWideIOFileStream; #endif // NS_USING_WIDE_CHAR #endif /* _FILESTREAM_H_ */