You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by pe...@apache.org on 2002/07/16 17:42:47 UTC
cvs commit: xml-xerces/c/src/xercesc/util/Platforms/OS400 OS400PlatformUtils.cpp
peiyongz 2002/07/16 08:42:47
Modified: c/src/xercesc/util/Platforms/OS400 OS400PlatformUtils.cpp
Log:
openFileToWrite(), writeBufferToFile()
Revision Changes Path
1.3 +59 -1 xml-xerces/c/src/xercesc/util/Platforms/OS400/OS400PlatformUtils.cpp
Index: OS400PlatformUtils.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Platforms/OS400/OS400PlatformUtils.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- OS400PlatformUtils.cpp 21 May 2002 20:31:47 -0000 1.2
+++ OS400PlatformUtils.cpp 16 Jul 2002 15:42:47 -0000 1.3
@@ -262,6 +262,30 @@
return retVal;
}
+FileHandle XMLPlatformUtils::openFileToWrite(const XMLCh* const fileName)
+{
+ const char* tmpFileName = XMLString::transcode(fileName);
+ ArrayJanitor<char> janText((char*)tmpFileName);
+
+ return openFileToWrite(tmpFileName);
+}
+
+FileHandle XMLPlatformUtils::openFileToWrite(const char* const fileName)
+{
+ char errno_id[7];
+ errno = 0;
+ FileHandle retVal = (FILE*)fopen( fileName , "wb" );
+
+ if (retVal == NULL)
+ {
+ send_message((char*)fileName,FILE_OPEN_PROBLEMS,'d');
+ convert_errno(errno_id,errno);
+ send_message(NULL,errno_id,'d');
+ return 0;
+ }
+
+ return retVal;
+}
unsigned int
XMLPlatformUtils::readFileBuffer( FileHandle theFile
@@ -277,6 +301,40 @@
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)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org