gareth 2002/11/19 05:04:33 Modified: c/src/xercesc/util/Platforms/OpenServer OpenServerPlatformUtils.cpp Log: Bug# 14661 Caldera implemented openFileToWrite and writeBufferToFile. Patch from Cameron Dorrat. Revision Changes Path 1.4 +53 -1 xml-xerces/c/src/xercesc/util/Platforms/OpenServer/OpenServerPlatformUtils.cpp Index: OpenServerPlatformUtils.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Platforms/OpenServer/OpenServerPlatformUtils.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- OpenServerPlatformUtils.cpp 4 Nov 2002 15:13:01 -0000 1.3 +++ OpenServerPlatformUtils.cpp 19 Nov 2002 13:04:32 -0000 1.4 @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.4 2002/11/19 13:04:32 gareth + * Bug# 14661 Caldera implemented openFileToWrite and writeBufferToFile. Patch from Cameron Dorrat. + * * Revision 1.3 2002/11/04 15:13:01 tng * C++ Namespace Support. * @@ -271,6 +274,18 @@ return retVal; } +FileHandle XMLPlatformUtils::openFileToWrite(const XMLCh* const fileName) +{ + const char* tmpFileName = XMLString::transcode(fileName); + ArrayJanitor<char> janText((char*)tmpFileName); + return fopen( tmpFileName , "wb" ); +} + +FileHandle XMLPlatformUtils::openFileToWrite(const char* const fileName) +{ + return fopen( fileName , "wb" ); +} + FileHandle XMLPlatformUtils::openStdInHandle() { return (FileHandle)fdopen(dup(0), "rb"); @@ -291,6 +306,41 @@ return (unsigned int)noOfItemsRead; } +void +XMLPlatformUtils::writeBufferToFile( FileHandle const theFile + , long toWrite + , const XMLByte* const toFlush) +{ + if (!theFile || + (toWrite <= 0 ) || + !toFlush ) + return; + + const XMLByte* tmpFlush = (const XMLByte*) toFlush; + size_t bytesWritten = 0; + + while (true) + { + bytesWritten=fwrite(tmpFlush, sizeof(XMLByte), toWrite, (FILE*)theFile); + + if(ferror((FILE*)theFile)) + { + ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotWriteToFile); + } + + if (bytesWritten < toWrite) //incomplete write + { + tmpFlush+=bytesWritten; + toWrite-=bytesWritten; + bytesWritten=0; + } + else + return; + } + + return; +} + void XMLPlatformUtils::resetFile(FileHandle theFile) { if (fseek((FILE*)theFile, 0, SEEK_SET)) @@ -312,7 +362,9 @@ ArrayJanitor<char> janText(newSrc); // Use a local buffer that is big enough for the largest legal path - char *absPath = new char[pathconf(newSrc, _PC_PATH_MAX)]; + // Without the *3 we get exceptions with gcc on OpenServer 5.0.5/6 when + // relative paths are passed in + char *absPath = new char[pathconf(newSrc, _PC_PATH_MAX)*3]; ArrayJanitor<char> janText2(absPath); // Get the absolute path char* retPath = realpath(newSrc, absPath);
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]