From c9cbe3cdf9912d86dac424c8df0055b913757db5 Mon Sep 17 00:00:00 2001
From: Tinny Ng <tng@apache.org>
Date: Fri, 7 Mar 2003 20:34:16 +0000
Subject: [PATCH] [Bug 17774] Unixware platform utils not implemented .  Patch
 from Peter Crozier.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@174832 13f79535-47bb-0310-9956-ffa450edef68
---
 .../UnixWare/UnixWarePlatformUtils.cpp        | 49 +++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/src/xercesc/util/Platforms/UnixWare/UnixWarePlatformUtils.cpp b/src/xercesc/util/Platforms/UnixWare/UnixWarePlatformUtils.cpp
index cb2527931..75503fab9 100644
--- a/src/xercesc/util/Platforms/UnixWare/UnixWarePlatformUtils.cpp
+++ b/src/xercesc/util/Platforms/UnixWare/UnixWarePlatformUtils.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.5  2003/03/07 20:34:16  tng
+ * [Bug 17774] Unixware platform utils not implemented .  Patch from Peter Crozier.
+ *
  * Revision 1.4  2002/11/04 15:13:01  tng
  * C++ Namespace Support.
  *
@@ -320,6 +323,18 @@ FileHandle XMLPlatformUtils::openFile(const char* const fileName)
     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");
@@ -341,6 +356,40 @@ XMLPlatformUtils::readFileBuffer( FileHandle          theFile
     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)
 {
-- 
GitLab