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:01:16 UTC

cvs commit: xml-xerces/c/src/xercesc/util/Platforms/Linux LinuxPlatformUtils.cpp

peiyongz    2002/06/19 15:01:14

  Modified:    c/src/xercesc/util/Platforms/Linux LinuxPlatformUtils.cpp
  Log:
  DOM3:DOMSave Interface support: openFiletoWrite(), writeBuffertoFile()
  
  Revision  Changes    Path
  1.3       +51 -1     xml-xerces/c/src/xercesc/util/Platforms/Linux/LinuxPlatformUtils.cpp
  
  Index: LinuxPlatformUtils.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Platforms/Linux/LinuxPlatformUtils.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LinuxPlatformUtils.cpp	21 May 2002 20:31:47 -0000	1.2
  +++ LinuxPlatformUtils.cpp	19 Jun 2002 22:01:14 -0000	1.3
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.3  2002/06/19 22:01:14  peiyongz
  + * DOM3:DOMSave Interface support: openFiletoWrite(), writeBuffertoFile()
  + *
    * Revision 1.2  2002/05/21 20:31:47  tng
    * Minor update: Remove obsolete code
    *
  @@ -356,10 +359,21 @@
       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");
  +    return (FileHandle)fdopen(dup(0), "rb");
   }
   
   
  @@ -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