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/06/20 00:00:57 UTC

cvs commit: xml-xerces/c/src/xercesc/util/Platforms/HPUX HPPlatformUtils.cpp

peiyongz    2002/06/19 15:00:57

  Modified:    c/src/xercesc/util/Platforms/HPUX HPPlatformUtils.cpp
  Log:
  DOM3:DOMSave Interface support: openFiletoWrite(), writeBuffertoFile()
  
  Revision  Changes    Path
  1.3       +50 -0     xml-xerces/c/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp
  
  Index: HPPlatformUtils.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HPPlatformUtils.cpp	21 May 2002 20:31:47 -0000	1.2
  +++ HPPlatformUtils.cpp	19 Jun 2002 22:00:57 -0000	1.3
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.3  2002/06/19 22:00:57  peiyongz
  + * DOM3:DOMSave Interface support: openFiletoWrite(), writeBuffertoFile()
  + *
    * Revision 1.2  2002/05/21 20:31:47  tng
    * Minor update: Remove obsolete code
    *
  @@ -357,6 +360,17 @@
       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()
   {
  @@ -380,6 +394,42 @@
       return (unsigned int) noOfItemsRead;
   }
   
  +void
  +XMLPlatformUtils::writeBufferToFile( FileHandle     const  theFile
  +                                   , long                  toWrite
  +                                   , const XMLByte* const  toFlush)                                   
  +{
  +    if (!theFile        ||
  +        (toWrite <= 0 ) ||
  +        !toFlush        ||
  +        !*toFlush        )
  +        return;
  +
  +    const XMLByte* tmpFlush = (const XMLByte*) toFlush;
  +    unsigned long  bytesWritten = 0;
  +
  +    while (true)
  +    {
  +        fwrite(theFile, tmpFlush, toWrite, &bytesWritten, 0);
  +
  +        if(ferror((FILE*)theFile))
  +        {
  +            ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotReadFromFile);
  +          //ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotWriteToFile);
  +        }
  +
  +        if (bytesWritten < (unsigned long) 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