diff options
author | Kurt Zenker <kz@openoffice.org> | 2005-01-13 18:18:18 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2005-01-13 18:18:18 +0000 |
commit | 8fbae71fd6194a5a8bab7ef3e6fdb2fcefce13be (patch) | |
tree | d4a85a9ffd940157bb8f68c3f8dabbfcb9dd87a1 /transex3 | |
parent | 70de584b266bceb604585fccea6a00365c92d991 (diff) |
INTEGRATION: CWS babelfish (1.4.4); FILE MERGED
2004/12/21 14:21:55 ihi 1.4.4.6: Write plattform dependend line ends
2004/12/17 20:08:47 ihi 1.4.4.5: Remove destination file before move
2004/12/17 18:33:41 ihi 1.4.4.4: #i35278# Strip comments
2004/12/01 18:18:22 ihi 1.4.4.3: RESYNC: (1.4-1.5); FILE MERGED
2004/12/01 17:42:05 ihi 1.4.4.2: msg cosmetic
2004/11/19 20:16:47 ihi 1.4.4.1: #i36953# dmake helpex multiprocessing
Diffstat (limited to 'transex3')
-rw-r--r-- | transex3/source/xmlparse.cxx | 137 |
1 files changed, 86 insertions, 51 deletions
diff --git a/transex3/source/xmlparse.cxx b/transex3/source/xmlparse.cxx index ad7319080f4a..d20df825c4b3 100644 --- a/transex3/source/xmlparse.cxx +++ b/transex3/source/xmlparse.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlparse.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: rt $ $Date: 2004-11-18 08:17:50 $ + * last change: $Author: kz $ $Date: 2005-01-13 19:18:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -73,6 +73,12 @@ #endif #include "xmlparse.hxx" +#include <fstream> +#include <iostream> +#include "osl/mutex.hxx" + +using namespace std; +using namespace osl; // // class XMLChildNode @@ -305,45 +311,70 @@ extern "C" void Signal_handler(int signo){ BOOL XMLFile::Write( String &rFileName ) /*****************************************************************************/ { + ByteString aFilename( rFileName , RTL_TEXTENCODING_ASCII_US ); if ( rFileName.Len()) { - signal( SIGINT, &::Signal_handler ); - - // -- Multithreading bug in SvStream ? Retry one time if creation fails - SvFileStream aStreamTest( rFileName, STREAM_STD_WRITE | STREAM_TRUNC ); - ByteString sFileName( rFileName , RTL_TEXTENCODING_ASCII_US ); - if( aStreamTest.IsOpen() ) aStreamTest.Close(); - //else printf("Prozess ID = %d -> Can't create file %s\nRetrying ....\n" , getpid() , sFileName.GetBuffer() ); - // -- -- - - SvFileStream aStream( rFileName, STREAM_STD_WRITE | STREAM_TRUNC ); - if ( aStream.IsOpen()) { - BOOL bReturn = Write( aStream ); - aStream.Close(); - signal(SIGINT,SIG_DFL); // Enable Ctrl+C - return bReturn; - }else{ - printf("ERROR: Can't create file %s\n" , ByteString( rFileName , RTL_TEXTENCODING_ASCII_US ).GetBuffer() ); - signal(SIGINT,SIG_DFL); // Enable Ctrl+C - exit( -1 ); - } - signal(SIGINT,SIG_DFL); // Enable Ctrl+C - } + //signal( SIGINT, &::Signal_handler ); + + // retry if there is a NFS problem + bool isOk = false; + for( int x = 0 ; !isOk && x < 200 ; x++ ){ + DirEntry aTemp( Export::GetTempFile()); + ByteString sTempFile( aTemp.GetFull(), RTL_TEXTENCODING_ASCII_US ); + + ofstream aFStream( sTempFile.GetBuffer() , ios::out | ios::trunc ); + + if( !aFStream ){ + cerr << "ERROR: - helpex - Can't create tempfile " << sTempFile.GetBuffer() << " No#" << x << "\n"; + // signal(SIGINT,SIG_DFL); // Enable Ctrl+C + // isOk = false; + // exit ( -1 ); + } + else + { + Write( aFStream ); + aFStream.close(); + // signal(SIGINT,SIG_DFL); // Enable Ctrl+C + + DirEntry aTarget( aFilename ); + aTarget.Kill(); + aTemp.MoveTo( aTarget ) ; + + FileStat aFileStat( aTarget ); + if( aFileStat.GetSize() < 1 ){ + cerr << "WARNING: - helpex - Can't create file " << aFilename.GetBuffer() << " No#" << x << "\n"; + //exit( -1 ); + aTarget.Kill(); + aTemp.Kill(); + }else{ + return true; + } + + } + } + cerr << "ERROR: - helpex - Can't create file " << aFilename.GetBuffer() << "\nDisk full ? Mounted NFS volume broken ?\n"; + exit( -1 ); + return FALSE; + } // for + cerr << "ERROR: - helpex - Empty file name\n"; + exit( -1 ); return FALSE; } /*****************************************************************************/ -void XMLFile::WriteString( SvStream &rStream, const String &sString ) -/*****************************************************************************/ +//void XMLFile::WriteString( SvStream &rStream, const String &sString ) +void XMLFile::WriteString( ofstream &rStream, const String &sString ) + /*****************************************************************************/ { ByteString sText( sString, RTL_TEXTENCODING_UTF8 ); - sText.ConvertLineEnd(LINEEND_CRLF); + //sText.ConvertLineEnd(LINEEND_CRLF); rStream << sText.GetBuffer(); } /*****************************************************************************/ -BOOL XMLFile::Write( SvStream &rStream , XMLNode *pCur ) +//BOOL XMLFile::Write( SvStream &rStream , XMLNode *pCur ) +BOOL XMLFile::Write( ofstream &rStream , XMLNode *pCur ) /*****************************************************************************/ { XMLUtil& xmlutil=XMLUtil::Instance(); @@ -359,7 +390,7 @@ BOOL XMLFile::Write( SvStream &rStream , XMLNode *pCur ) break; case XML_NODE_TYPE_ELEMENT: { XMLElement *pElement = ( XMLElement * ) pCur; - rStream << "<"; + rStream << "<"; WriteString( rStream, pElement->GetName()); if ( pElement->GetAttributeList()) for ( ULONG j = 0; j < pElement->GetAttributeList()->Count(); j++ ) { @@ -850,6 +881,7 @@ OUString XMLElement::ToOUString(){ /*****************************************************************************/ void XMLElement::Print(XMLNode *pCur, OUStringBuffer& buffer , bool rootelement){ /*****************************************************************************/ + const String COMMENT = String::CreateFromAscii("comment"); XMLUtil& xmlutil=XMLUtil::Instance(); if(pCur!=NULL){ if(rootelement){ @@ -869,30 +901,33 @@ void XMLElement::Print(XMLNode *pCur, OUStringBuffer& buffer , bool rootelement) switch( pCur->GetNodeType()) { case XML_NODE_TYPE_ELEMENT: { XMLElement *pElement = ( XMLElement * ) pCur; - buffer.append( OUString::createFromAscii("\\<") ); - buffer.append( pElement->GetName() ); - if ( pElement->GetAttributeList()) - for ( ULONG j = 0; j < pElement->GetAttributeList()->Count(); j++ ){ - buffer.append( OUString::createFromAscii(" ") ); - buffer.append( *pElement->GetAttributeList()->GetObject( j ) ); - buffer.append( OUString::createFromAscii("=") ); - buffer.append( OUString::createFromAscii("\\\"") ); - buffer.append( pElement->GetAttributeList()->GetObject( j )->GetValue() ); - buffer.append( OUString::createFromAscii("\\\"") ); - } - if ( !pElement->GetChildList()) - buffer.append( OUString::createFromAscii("/\\>") ); - else { - buffer.append( OUString::createFromAscii("\\>") ); - XMLChildNode* tmp=NULL; - for ( ULONG k = 0; k < pElement->GetChildList()->Count(); k++ ){ - tmp=pElement->GetChildList()->GetObject( k ); - Print( tmp, buffer , false); - } - buffer.append( OUString::createFromAscii("\\</") ); + if( !pElement->GetName().EqualsIgnoreCaseAscii( COMMENT ) ){ + buffer.append( OUString::createFromAscii("\\<") ); buffer.append( pElement->GetName() ); - buffer.append( OUString::createFromAscii("\\>") ); + if ( pElement->GetAttributeList()) + for ( ULONG j = 0; j < pElement->GetAttributeList()->Count(); j++ ){ + buffer.append( OUString::createFromAscii(" ") ); + buffer.append( *pElement->GetAttributeList()->GetObject( j ) ); + buffer.append( OUString::createFromAscii("=") ); + buffer.append( OUString::createFromAscii("\\\"") ); + buffer.append( pElement->GetAttributeList()->GetObject( j )->GetValue() ); + buffer.append( OUString::createFromAscii("\\\"") ); + } + if ( !pElement->GetChildList()) + buffer.append( OUString::createFromAscii("/\\>") ); + else { + buffer.append( OUString::createFromAscii("\\>") ); + XMLChildNode* tmp=NULL; + for ( ULONG k = 0; k < pElement->GetChildList()->Count(); k++ ){ + tmp=pElement->GetChildList()->GetObject( k ); + Print( tmp, buffer , false); + } + buffer.append( OUString::createFromAscii("\\</") ); + buffer.append( pElement->GetName() ); + buffer.append( OUString::createFromAscii("\\>") ); + } } + } break; case XML_NODE_TYPE_DATA: { |