Kaydet (Commit) eec2eb05 authored tarafından Krisztian Pinter's avatar Krisztian Pinter Kaydeden (comit) Andras Timar

fdo#39445 writing out tools/fsys.hxx (idl)

Removed uses of fsys from database.cxx, command.cxx, module.cxx, svidl.cxx.
Also removed a lot of cruft from svidl.cxx and command.hxx; unused variables
and code relating to them, eg. variables aCxxFile, aHxxFile, aSrcFile, aODLFile.
Changed some Strings to OUStrings in svidl.cxx and command.hxx.

Change-Id: I708284f70435c8f65cdcfc954af43976e28b8c9d
Reviewed-on: https://gerrit.libreoffice.org/2935Reviewed-by: 's avatarAndras Timar <atimar@suse.com>
Tested-by: 's avatarAndras Timar <atimar@suse.com>
üst 56a52889
...@@ -30,25 +30,18 @@ typedef ::std::vector< rtl::OString* > ByteStringList; ...@@ -30,25 +30,18 @@ typedef ::std::vector< rtl::OString* > ByteStringList;
class SvCommand class SvCommand
{ {
public: public:
String aDataBaseFile; OUString aDataBaseFile;
StringList aInFileList; StringList aInFileList;
String aListFile; OUString aListFile;
String aSlotMapFile; OUString aSlotMapFile;
String aSfxItemFile; OUString aSfxItemFile;
String aODLFile;
String aCallingFile;
String aCxxFile;
String aHxxFile;
String aSrcFile;
String aPath; String aPath;
String aCHeaderFile;
String aCSourceFile;
String aTargetFile; String aTargetFile;
String aHelpIdFile; OUString aHelpIdFile;
String aCSVFile; OUString aCSVFile;
String aExportFile; OUString aExportFile;
String aDocuFile; OUString aDocuFile;
::rtl::OUString m_DepFile; OUString m_DepFile;
sal_uInt32 nVerbosity; sal_uInt32 nVerbosity;
sal_uInt32 nFlags; sal_uInt32 nFlags;
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
#include <module.hxx> #include <module.hxx>
#include <globals.hxx> #include <globals.hxx>
#include <database.hxx> #include <database.hxx>
#include <tools/fsys.hxx>
#include <tools/debug.hxx> #include <tools/debug.hxx>
#include <osl/file.hxx>
SV_IMPL_META_FACTORY1( SvMetaModule, SvMetaExtern ); SV_IMPL_META_FACTORY1( SvMetaModule, SvMetaExtern );
...@@ -222,12 +222,16 @@ void SvMetaModule::ReadContextSvIdl( SvIdlDataBase & rBase, ...@@ -222,12 +222,16 @@ void SvMetaModule::ReadContextSvIdl( SvIdlDataBase & rBase,
SvToken * pTok = rInStm.GetToken_Next(); SvToken * pTok = rInStm.GetToken_Next();
if( pTok->IsString() ) if( pTok->IsString() )
{ {
DirEntry aFullName( rtl::OStringToOUString(pTok->GetString(), RTL_TEXTENCODING_ASCII_US) ); OUString aFullName(rtl::OStringToOUString(pTok->GetString(), RTL_TEXTENCODING_ASCII_US));
rBase.StartNewFile( aFullName.GetFull() ); rBase.StartNewFile( aFullName );
if( aFullName.Find( rBase.GetPath() ) ) osl::FileBase::RC searchError = osl::File::searchFileURL(aFullName, rBase.GetPath(), aFullName);
osl::FileBase::getSystemPathFromFileURL( aFullName, aFullName );
if( osl::FileBase::E_None == searchError )
{ {
rBase.AddDepFile(aFullName.GetFull()); rBase.AddDepFile( aFullName );
SvTokenStream aTokStm( aFullName.GetFull() ); SvTokenStream aTokStm( aFullName );
if( SVSTREAM_OK == aTokStm.GetStream().GetError() ) if( SVSTREAM_OK == aTokStm.GetStream().GetError() )
{ {
// rescue error from old file // rescue error from old file
...@@ -252,19 +256,15 @@ void SvMetaModule::ReadContextSvIdl( SvIdlDataBase & rBase, ...@@ -252,19 +256,15 @@ void SvMetaModule::ReadContextSvIdl( SvIdlDataBase & rBase,
} }
else else
{ {
rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM( rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("cannot open file: "));
"cannot open file: ")); aStr.append(rtl::OUStringToOString(aFullName, RTL_TEXTENCODING_UTF8));
aStr.append(rtl::OUStringToOString(aFullName.GetFull(),
RTL_TEXTENCODING_UTF8));
rBase.SetError(aStr.makeStringAndClear(), pTok); rBase.SetError(aStr.makeStringAndClear(), pTok);
} }
} }
else else
{ {
rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM( rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("cannot find file:"));
"cannot find file:")); aStr.append(rtl::OUStringToOString(aFullName, RTL_TEXTENCODING_UTF8));
aStr.append(rtl::OUStringToOString(aFullName.GetFull(),
RTL_TEXTENCODING_UTF8));
rBase.SetError(aStr.makeStringAndClear(), pTok); rBase.SetError(aStr.makeStringAndClear(), pTok);
} }
} }
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <command.hxx> #include <command.hxx>
#include <globals.hxx> #include <globals.hxx>
#include <database.hxx> #include <database.hxx>
#include <tools/fsys.hxx> #include "sal/config.h"
char const * SyntaxStrings[] = { char const * SyntaxStrings[] = {
"basic-type:", "basic-type:",
...@@ -320,7 +320,7 @@ SvCommand::SvCommand( int argc, char ** argv ) ...@@ -320,7 +320,7 @@ SvCommand::SvCommand( int argc, char ** argv )
{ // define include paths { // define include paths
String aName( aParam.Copy( 1 ) ); String aName( aParam.Copy( 1 ) );
if( aPath.Len() ) if( aPath.Len() )
aPath += DirEntry::GetSearchDelimiter(); aPath += OUString( SAL_PATHSEPARATOR );
aPath += aName; aPath += aName;
} }
else if( aParam.EqualsIgnoreCaseAscii( "rsc", 0, 3 ) ) else if( aParam.EqualsIgnoreCaseAscii( "rsc", 0, 3 ) )
...@@ -361,7 +361,7 @@ SvCommand::SvCommand( int argc, char ** argv ) ...@@ -361,7 +361,7 @@ SvCommand::SvCommand( int argc, char ** argv )
if( aInc.getLength() ) if( aInc.getLength() )
{ {
if( aPath.Len() ) if( aPath.Len() )
aPath += DirEntry::GetSearchDelimiter(); aPath += OUString( SAL_PATHSEPARATOR );
aPath += rtl::OStringToOUString(aInc, RTL_TEXTENCODING_ASCII_US); aPath += rtl::OStringToOUString(aInc, RTL_TEXTENCODING_ASCII_US);
} }
} }
......
...@@ -21,11 +21,11 @@ ...@@ -21,11 +21,11 @@
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <tools/fsys.hxx>
#include <tools/debug.hxx> #include <tools/debug.hxx>
#include <database.hxx> #include <database.hxx>
#include <globals.hxx> #include <globals.hxx>
#include <rtl/strbuf.hxx> #include <rtl/strbuf.hxx>
#include <osl/file.hxx>
SvIdlDataBase::SvIdlDataBase( const SvCommand& rCmd ) SvIdlDataBase::SvIdlDataBase( const SvCommand& rCmd )
: bExport( sal_False ) : bExport( sal_False )
...@@ -205,17 +205,17 @@ sal_Bool SvIdlDataBase::InsertId( const rtl::OString& rIdName, sal_uLong nVal ) ...@@ -205,17 +205,17 @@ sal_Bool SvIdlDataBase::InsertId( const rtl::OString& rIdName, sal_uLong nVal )
sal_Bool SvIdlDataBase::ReadIdFile( const String & rFileName ) sal_Bool SvIdlDataBase::ReadIdFile( const String & rFileName )
{ {
DirEntry aFullName( rFileName ); OUString aFullName;
aFullName.Find( GetPath() ); osl::File::searchFileURL( rFileName, GetPath(), aFullName);
osl::FileBase::getSystemPathFromFileURL( aFullName, aFullName );
for ( size_t i = 0, n = aIdFileList.size(); i < n; ++i ) for ( size_t i = 0, n = aIdFileList.size(); i < n; ++i )
if ( *aIdFileList[ i ] == rFileName ) if ( *aIdFileList[ i ] == rFileName )
return sal_True; return sal_True;
aIdFileList.push_back( new String( rFileName ) ); aIdFileList.push_back( new String( rFileName ) );
this->AddDepFile( aFullName );
this->AddDepFile(aFullName.GetFull()); SvTokenStream aTokStm( aFullName );
SvTokenStream aTokStm( aFullName.GetFull() );
if( aTokStm.GetStream().GetError() == SVSTREAM_OK ) if( aTokStm.GetStream().GetError() == SVSTREAM_OK )
{ {
SvToken * pTok = aTokStm.GetToken_Next(); SvToken * pTok = aTokStm.GetToken_Next();
...@@ -634,20 +634,22 @@ sal_Bool SvIdlWorkingBase::ReadSvIdl( SvTokenStream & rInStm, sal_Bool bImported ...@@ -634,20 +634,22 @@ sal_Bool SvIdlWorkingBase::ReadSvIdl( SvTokenStream & rInStm, sal_Bool bImported
pTok = rInStm.GetToken_Next(); pTok = rInStm.GetToken_Next();
if( pTok->IsString() ) if( pTok->IsString() )
{ {
DirEntry aFullName(rtl::OStringToOUString(pTok->GetString(), RTL_TEXTENCODING_ASCII_US)); OUString aFullName;
if( aFullName.Find( rPath ) ) if( osl::FileBase::E_None == osl::File::searchFileURL(
rtl::OStringToOUString(pTok->GetString(), RTL_TEXTENCODING_ASCII_US),
rPath,
aFullName) )
{ {
this->AddDepFile(aFullName.GetFull()); osl::FileBase::getSystemPathFromFileURL( aFullName, aFullName );
SvFileStream aStm( aFullName.GetFull(), this->AddDepFile(aFullName);
STREAM_STD_READ | STREAM_NOCREATE ); SvFileStream aStm( aFullName, STREAM_STD_READ | STREAM_NOCREATE );
Load( aStm ); Load( aStm );
if( aStm.GetError() != SVSTREAM_OK ) if( aStm.GetError() != SVSTREAM_OK )
{ {
if( aStm.GetError() == SVSTREAM_WRONGVERSION ) if( aStm.GetError() == SVSTREAM_WRONGVERSION )
{ {
rtl::OStringBuffer aStr("wrong version, file "); rtl::OStringBuffer aStr("wrong version, file ");
aStr.append(rtl::OUStringToOString( aStr.append(rtl::OUStringToOString( aFullName, RTL_TEXTENCODING_UTF8));
aFullName.GetFull(), RTL_TEXTENCODING_UTF8));
SetError(aStr.makeStringAndClear(), pTok); SetError(aStr.makeStringAndClear(), pTok);
WriteError( rInStm ); WriteError( rInStm );
bOk = sal_False; bOk = sal_False;
...@@ -656,7 +658,7 @@ sal_Bool SvIdlWorkingBase::ReadSvIdl( SvTokenStream & rInStm, sal_Bool bImported ...@@ -656,7 +658,7 @@ sal_Bool SvIdlWorkingBase::ReadSvIdl( SvTokenStream & rInStm, sal_Bool bImported
{ {
aStm.Seek( 0 ); aStm.Seek( 0 );
aStm.ResetError(); aStm.ResetError();
SvTokenStream aTokStm( aStm, aFullName.GetFull() ); SvTokenStream aTokStm( aStm, aFullName );
bOk = ReadSvIdl( aTokStm, sal_True, rPath ); bOk = ReadSvIdl( aTokStm, sal_True, rPath );
} }
} }
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
#include <database.hxx> #include <database.hxx>
#include <globals.hxx> #include <globals.hxx>
#include <command.hxx> #include <command.hxx>
#include <tools/fsys.hxx>
#include <tools/string.hxx> #include <tools/string.hxx>
#include <osl/file.hxx>
#define BR 0x8000 #define BR 0x8000
sal_Bool FileMove_Impl( const String & rFile1, const String & rFile2, sal_Bool bImmerVerschieben ) sal_Bool FileMove_Impl( const String & rFile1, const String & rFile2, sal_Bool bImmerVerschieben )
...@@ -61,22 +61,46 @@ sal_Bool FileMove_Impl( const String & rFile1, const String & rFile2, sal_Bool b ...@@ -61,22 +61,46 @@ sal_Bool FileMove_Impl( const String & rFile1, const String & rFile2, sal_Bool b
delete[] pBuf2; delete[] pBuf2;
} }
} }
DirEntry aF2( rFile2 ); OUString fileURL2;
osl::FileBase::getFileURLFromSystemPath( rFile2, fileURL2 );
if( nC1 != nC2 ) if( nC1 != nC2 )
{// something has changed {// something has changed
DirEntry aF1( rFile1 ); OUString fileURL1;
aF1.Kill(); osl::FileBase::getFileURLFromSystemPath( rFile1, fileURL1 );
// move file // move file
if( aF2.MoveTo( aF1 ) ) if( osl::FileBase::E_None != osl::File::move( fileURL2, fileURL1 ) )
{ {
// delete both files // delete both files
aF1.Kill(); osl::File::remove( fileURL1 );
aF2.Kill(); osl::File::remove( fileURL2 );
return sal_False; return sal_False;
} }
return sal_True; return sal_True;
} }
return 0 == aF2.Kill(); return osl::FileBase::E_None == osl::File::remove( fileURL2 );
}
//This function gets a system path to a file [fname], creates a temp file in
//the same folder as [fname] and returns the system path of the temp file.
inline OUString tempFileHelper(OUString const & fname)
{
OUString aTmpFile;
sal_Int32 delimIndex = fname.lastIndexOf( '/' );
if( delimIndex > 0 )
{
OUString aTmpDir( fname.copy( 0, delimIndex ) );
osl::FileBase::getFileURLFromSystemPath( aTmpDir, aTmpDir );
osl::FileBase::createTempFile( &aTmpDir, 0, &aTmpFile );
osl::FileBase::getSystemPathFromFileURL( aTmpFile, aTmpFile );
}
else
{
rtl::OStringBuffer aStr("invalid filename: ");
aStr.append(rtl::OUStringToOString(fname, RTL_TEXTENCODING_UTF8));
fprintf(stderr, "%s\n", aStr.getStr());
}
return aTmpFile;
} }
#if defined( UNX ) || defined (__MINGW32__) #if defined( UNX ) || defined (__MINGW32__)
...@@ -87,17 +111,14 @@ int cdecl main ( int argc, char ** argv) ...@@ -87,17 +111,14 @@ int cdecl main ( int argc, char ** argv)
{ {
#endif #endif
String aTmpListFile; OUString aTmpListFile;
String aTmpSlotMapFile; OUString aTmpSlotMapFile;
String aTmpSfxItemFile; OUString aTmpSfxItemFile;
String aTmpDataBaseFile; OUString aTmpDataBaseFile;
String aTmpCallingFile; OUString aTmpHelpIdFile;
String aTmpCxxFile; OUString aTmpCSVFile;
String aTmpHxxFile; OUString aTmpDocuFile;
String aTmpHelpIdFile; OUString aTmpDepFile;
String aTmpCSVFile;
String aTmpDocuFile;
String aTmpDepFile;
SvCommand aCommand( argc, argv ); SvCommand aCommand( argc, argv );
...@@ -108,125 +129,105 @@ int cdecl main ( int argc, char ** argv) ...@@ -108,125 +129,105 @@ int cdecl main ( int argc, char ** argv)
SvIdlWorkingBase * pDataBase = new SvIdlWorkingBase(aCommand); SvIdlWorkingBase * pDataBase = new SvIdlWorkingBase(aCommand);
int nExit = 0; int nExit = 0;
if( aCommand.aExportFile.Len() ) if( !aCommand.aExportFile.isEmpty() )
{ {
DirEntry aDE( aCommand.aExportFile ); osl::DirectoryItem aDI;
pDataBase->SetExportFile( aDE.GetName() ); osl::FileStatus fileStatus( osl_FileStatus_Mask_FileName );
osl::DirectoryItem::get( aCommand.aExportFile, aDI );
aDI.getFileStatus(fileStatus);
pDataBase->SetExportFile( fileStatus.getFileName() );
} }
if( ReadIdl( pDataBase, aCommand ) ) if( ReadIdl( pDataBase, aCommand ) )
{ {
if( nExit == 0 && aCommand.aDocuFile.Len() ) if( nExit == 0 && !aCommand.aDocuFile.isEmpty() )
{ {
DirEntry aDE( aCommand.aDocuFile ); aTmpDocuFile = tempFileHelper(aCommand.aDocuFile);
aDE.ToAbs();
aTmpDocuFile = aDE.GetPath().TempName().GetFull();
SvFileStream aOutStm( aTmpDocuFile, STREAM_READWRITE | STREAM_TRUNC ); SvFileStream aOutStm( aTmpDocuFile, STREAM_READWRITE | STREAM_TRUNC );
if( !pDataBase->WriteDocumentation( aOutStm ) ) if( !pDataBase->WriteDocumentation( aOutStm ) )
{ {
nExit = -1; nExit = -1;
rtl::OStringBuffer aStr("cannot write documentation file: "); rtl::OStringBuffer aStr("cannot write documentation file: ");
aStr.append(rtl::OUStringToOString(aCommand.aDocuFile, aStr.append(rtl::OUStringToOString(aCommand.aDocuFile, RTL_TEXTENCODING_UTF8));
RTL_TEXTENCODING_UTF8));
fprintf(stderr, "%s\n", aStr.getStr()); fprintf(stderr, "%s\n", aStr.getStr());
} }
} }
if( nExit == 0 && aCommand.aListFile.Len() ) if( nExit == 0 && !aCommand.aListFile.isEmpty() )
{ {
DirEntry aDE( aCommand.aListFile ); aTmpListFile = tempFileHelper(aCommand.aListFile);
aDE.ToAbs();
aTmpListFile = aDE.GetPath().TempName().GetFull();
SvFileStream aOutStm( aTmpListFile, STREAM_READWRITE | STREAM_TRUNC ); SvFileStream aOutStm( aTmpListFile, STREAM_READWRITE | STREAM_TRUNC );
if( !pDataBase->WriteSvIdl( aOutStm ) ) if( !pDataBase->WriteSvIdl( aOutStm ) )
{ {
nExit = -1; nExit = -1;
rtl::OStringBuffer aStr("cannot write list file: "); rtl::OStringBuffer aStr("cannot write list file: ");
aStr.append(rtl::OUStringToOString(aCommand.aListFile, aStr.append(rtl::OUStringToOString(aCommand.aListFile, RTL_TEXTENCODING_UTF8));
RTL_TEXTENCODING_UTF8));
fprintf(stderr, "%s\n", aStr.getStr()); fprintf(stderr, "%s\n", aStr.getStr());
} }
} }
if( nExit == 0 && aCommand.aSlotMapFile.Len() ) if( nExit == 0 && !aCommand.aSlotMapFile.isEmpty() )
{ {
DirEntry aDE( aCommand.aSlotMapFile ); aTmpSlotMapFile = tempFileHelper(aCommand.aSlotMapFile);
aDE.ToAbs();
aTmpSlotMapFile = aDE.GetPath().TempName().GetFull();
SvFileStream aOutStm( aTmpSlotMapFile, STREAM_READWRITE | STREAM_TRUNC ); SvFileStream aOutStm( aTmpSlotMapFile, STREAM_READWRITE | STREAM_TRUNC );
if( !pDataBase->WriteSfx( aOutStm ) ) if( !pDataBase->WriteSfx( aOutStm ) )
{ {
nExit = -1; nExit = -1;
rtl::OStringBuffer aStr("cannot write slotmap file: "); rtl::OStringBuffer aStr("cannot write slotmap file: ");
aStr.append(rtl::OUStringToOString(aCommand.aSlotMapFile, aStr.append(rtl::OUStringToOString(aCommand.aSlotMapFile, RTL_TEXTENCODING_UTF8));
RTL_TEXTENCODING_UTF8));
fprintf(stderr, "%s\n", aStr.getStr()); fprintf(stderr, "%s\n", aStr.getStr());
} }
} }
if( nExit == 0 && aCommand.aHelpIdFile.Len() ) if( nExit == 0 && !aCommand.aHelpIdFile.isEmpty() )
{ {
DirEntry aDE( aCommand.aHelpIdFile ); aTmpHelpIdFile = tempFileHelper(aCommand.aHelpIdFile);
aDE.ToAbs();
aTmpHelpIdFile = aDE.GetPath().TempName().GetFull();
SvFileStream aStm( aTmpHelpIdFile, STREAM_READWRITE | STREAM_TRUNC ); SvFileStream aStm( aTmpHelpIdFile, STREAM_READWRITE | STREAM_TRUNC );
if (!pDataBase->WriteHelpIds( aStm ) ) if (!pDataBase->WriteHelpIds( aStm ) )
{ {
nExit = -1; nExit = -1;
rtl::OStringBuffer aStr("cannot write help ID file: "); rtl::OStringBuffer aStr("cannot write help ID file: ");
aStr.append(rtl::OUStringToOString(aCommand.aHelpIdFile, aStr.append(rtl::OUStringToOString(aCommand.aHelpIdFile, RTL_TEXTENCODING_UTF8));
RTL_TEXTENCODING_UTF8));
fprintf(stderr, "%s\n", aStr.getStr()); fprintf(stderr, "%s\n", aStr.getStr());
} }
} }
if( nExit == 0 && aCommand.aCSVFile.Len() ) if( nExit == 0 && !aCommand.aCSVFile.isEmpty() )
{ {
DirEntry aDE( aCommand.aCSVFile ); aTmpCSVFile = tempFileHelper(aCommand.aCSVFile);
aDE.ToAbs();
aTmpCSVFile = aDE.GetPath().TempName().GetFull();
SvFileStream aStm( aTmpCSVFile, STREAM_READWRITE | STREAM_TRUNC ); SvFileStream aStm( aTmpCSVFile, STREAM_READWRITE | STREAM_TRUNC );
if (!pDataBase->WriteCSV( aStm ) ) if (!pDataBase->WriteCSV( aStm ) )
{ {
nExit = -1; nExit = -1;
rtl::OStringBuffer aStr("cannot write CSV file: "); rtl::OStringBuffer aStr("cannot write CSV file: ");
aStr.append(rtl::OUStringToOString(aCommand.aCSVFile, aStr.append(rtl::OUStringToOString(aCommand.aCSVFile, RTL_TEXTENCODING_UTF8));
RTL_TEXTENCODING_UTF8));
fprintf(stderr, "%s\n", aStr.getStr()); fprintf(stderr, "%s\n", aStr.getStr());
} }
} }
if( nExit == 0 && aCommand.aSfxItemFile.Len() ) if( nExit == 0 && !aCommand.aSfxItemFile.isEmpty() )
{ {
DirEntry aDE( aCommand.aSfxItemFile ); aTmpSfxItemFile = tempFileHelper(aCommand.aSfxItemFile);
aDE.ToAbs();
aTmpSfxItemFile = aDE.GetPath().TempName().GetFull();
SvFileStream aOutStm( aTmpSfxItemFile, STREAM_READWRITE | STREAM_TRUNC ); SvFileStream aOutStm( aTmpSfxItemFile, STREAM_READWRITE | STREAM_TRUNC );
if( !pDataBase->WriteSfxItem( aOutStm ) ) if( !pDataBase->WriteSfxItem( aOutStm ) )
{ {
nExit = -1; nExit = -1;
rtl::OStringBuffer aStr("cannot write item file: "); rtl::OStringBuffer aStr("cannot write item file: ");
aStr.append(rtl::OUStringToOString(aCommand.aSfxItemFile, aStr.append(rtl::OUStringToOString(aCommand.aSfxItemFile, RTL_TEXTENCODING_UTF8));
RTL_TEXTENCODING_UTF8));
fprintf(stderr, "%s\n", aStr.getStr()); fprintf(stderr, "%s\n", aStr.getStr());
} }
} }
if( nExit == 0 && aCommand.aDataBaseFile.Len() ) if( nExit == 0 && !aCommand.aDataBaseFile.isEmpty() )
{ {
DirEntry aDE( aCommand.aDataBaseFile ); aTmpDataBaseFile = tempFileHelper(aCommand.aDataBaseFile);
aDE.ToAbs();
aTmpDataBaseFile = aDE.GetPath().TempName().GetFull();
SvFileStream aOutStm( aTmpDataBaseFile, STREAM_READWRITE | STREAM_TRUNC ); SvFileStream aOutStm( aTmpDataBaseFile, STREAM_READWRITE | STREAM_TRUNC );
pDataBase->Save( aOutStm, aCommand.nFlags ); pDataBase->Save( aOutStm, aCommand.nFlags );
if( aOutStm.GetError() != SVSTREAM_OK ) if( aOutStm.GetError() != SVSTREAM_OK )
{ {
nExit = -1; nExit = -1;
rtl::OStringBuffer aStr("cannot write database file: "); rtl::OStringBuffer aStr("cannot write database file: ");
aStr.append(rtl::OUStringToOString(aCommand.aDataBaseFile, aStr.append(rtl::OUStringToOString(aCommand.aDataBaseFile, RTL_TEXTENCODING_UTF8));
RTL_TEXTENCODING_UTF8));
fprintf(stderr, "%s\n", aStr.getStr()); fprintf(stderr, "%s\n", aStr.getStr());
} }
} }
if (nExit == 0 && !aCommand.m_DepFile.isEmpty()) if (nExit == 0 && !aCommand.m_DepFile.isEmpty())
{ {
DirEntry aDE(aCommand.m_DepFile); aTmpDepFile = tempFileHelper(aCommand.m_DepFile);
aDE.ToAbs();
aTmpDepFile = aDE.GetPath().TempName().GetFull();
SvFileStream aOutStm( aTmpDepFile, STREAM_READWRITE | STREAM_TRUNC ); SvFileStream aOutStm( aTmpDepFile, STREAM_READWRITE | STREAM_TRUNC );
pDataBase->WriteDepFile(aOutStm, aCommand.aTargetFile); pDataBase->WriteDepFile(aOutStm, aCommand.aTargetFile);
if( aOutStm.GetError() != SVSTREAM_OK ) if( aOutStm.GetError() != SVSTREAM_OK )
...@@ -246,7 +247,7 @@ int cdecl main ( int argc, char ** argv) ...@@ -246,7 +247,7 @@ int cdecl main ( int argc, char ** argv)
sal_Bool bErr = sal_False; sal_Bool bErr = sal_False;
sal_Bool bDoMove = aCommand.aTargetFile.Len() == 0; sal_Bool bDoMove = aCommand.aTargetFile.Len() == 0;
String aErrFile, aErrFile2; String aErrFile, aErrFile2;
if( !bErr && aCommand.aListFile.Len() ) if( !bErr && !aCommand.aListFile.isEmpty() )
{ {
bErr |= !FileMove_Impl( aCommand.aListFile, aTmpListFile, bDoMove ); bErr |= !FileMove_Impl( aCommand.aListFile, aTmpListFile, bDoMove );
if( bErr ) { if( bErr ) {
...@@ -254,7 +255,7 @@ int cdecl main ( int argc, char ** argv) ...@@ -254,7 +255,7 @@ int cdecl main ( int argc, char ** argv)
aErrFile2 = aTmpListFile; aErrFile2 = aTmpListFile;
} }
} }
if( !bErr && aCommand.aSlotMapFile.Len() ) if( !bErr && !aCommand.aSlotMapFile.isEmpty() )
{ {
bErr |= !FileMove_Impl( aCommand.aSlotMapFile, aTmpSlotMapFile, bDoMove ); bErr |= !FileMove_Impl( aCommand.aSlotMapFile, aTmpSlotMapFile, bDoMove );
if( bErr ) { if( bErr ) {
...@@ -262,7 +263,7 @@ int cdecl main ( int argc, char ** argv) ...@@ -262,7 +263,7 @@ int cdecl main ( int argc, char ** argv)
aErrFile2 = aTmpSlotMapFile; aErrFile2 = aTmpSlotMapFile;
} }
} }
if( !bErr && aCommand.aSfxItemFile.Len() ) if( !bErr && !aCommand.aSfxItemFile.isEmpty() )
{ {
bErr |= !FileMove_Impl( aCommand.aSfxItemFile, aTmpSfxItemFile, bDoMove ); bErr |= !FileMove_Impl( aCommand.aSfxItemFile, aTmpSfxItemFile, bDoMove );
if( bErr ) { if( bErr ) {
...@@ -270,7 +271,7 @@ int cdecl main ( int argc, char ** argv) ...@@ -270,7 +271,7 @@ int cdecl main ( int argc, char ** argv)
aErrFile2 = aTmpSfxItemFile; aErrFile2 = aTmpSfxItemFile;
} }
} }
if( !bErr && aCommand.aDataBaseFile.Len() ) if( !bErr && !aCommand.aDataBaseFile.isEmpty() )
{ {
bErr |= !FileMove_Impl( aCommand.aDataBaseFile, aTmpDataBaseFile, bDoMove ); bErr |= !FileMove_Impl( aCommand.aDataBaseFile, aTmpDataBaseFile, bDoMove );
if( bErr ) { if( bErr ) {
...@@ -278,31 +279,7 @@ int cdecl main ( int argc, char ** argv) ...@@ -278,31 +279,7 @@ int cdecl main ( int argc, char ** argv)
aErrFile2 = aTmpDataBaseFile; aErrFile2 = aTmpDataBaseFile;
} }
} }
if( !bErr && aCommand.aCallingFile.Len() ) if( !bErr && !aCommand.aHelpIdFile.isEmpty() )
{
bErr |= !FileMove_Impl( aCommand.aCallingFile, aTmpCallingFile, bDoMove );
if( bErr ) {
aErrFile = aCommand.aCallingFile;
aErrFile2 = aTmpCallingFile;
}
}
if( !bErr && aCommand.aCxxFile.Len() )
{
bErr |= !FileMove_Impl( aCommand.aCxxFile, aTmpCxxFile, bDoMove );
if( bErr ) {
aErrFile = aCommand.aCxxFile;
aErrFile2 = aTmpCxxFile;
}
}
if( !bErr && aCommand.aHxxFile.Len() )
{
bErr |= !FileMove_Impl( aCommand.aHxxFile, aTmpHxxFile, bDoMove );
if( bErr ) {
aErrFile = aCommand.aHxxFile;
aErrFile2 = aTmpHxxFile;
}
}
if( !bErr && aCommand.aHelpIdFile.Len() )
{ {
bErr |= !FileMove_Impl( aCommand.aHelpIdFile, aTmpHelpIdFile, bDoMove ); bErr |= !FileMove_Impl( aCommand.aHelpIdFile, aTmpHelpIdFile, bDoMove );
if( bErr ) { if( bErr ) {
...@@ -310,7 +287,7 @@ int cdecl main ( int argc, char ** argv) ...@@ -310,7 +287,7 @@ int cdecl main ( int argc, char ** argv)
aErrFile2 = aTmpHelpIdFile; aErrFile2 = aTmpHelpIdFile;
} }
} }
if( !bErr && aCommand.aCSVFile.Len() ) if( !bErr && !aCommand.aCSVFile.isEmpty() )
{ {
bErr |= !FileMove_Impl( aCommand.aCSVFile, aTmpCSVFile, bDoMove ); bErr |= !FileMove_Impl( aCommand.aCSVFile, aTmpCSVFile, bDoMove );
if( bErr ) { if( bErr ) {
...@@ -318,7 +295,7 @@ int cdecl main ( int argc, char ** argv) ...@@ -318,7 +295,7 @@ int cdecl main ( int argc, char ** argv)
aErrFile2 = aTmpCSVFile; aErrFile2 = aTmpCSVFile;
} }
} }
if( !bErr && aCommand.aDocuFile.Len() ) if( !bErr && !aCommand.aDocuFile.isEmpty() )
{ {
bErr |= !FileMove_Impl( aCommand.aDocuFile, aTmpDocuFile, bDoMove ); bErr |= !FileMove_Impl( aCommand.aDocuFile, aTmpDocuFile, bDoMove );
if( bErr ) { if( bErr ) {
...@@ -363,20 +340,26 @@ int cdecl main ( int argc, char ** argv) ...@@ -363,20 +340,26 @@ int cdecl main ( int argc, char ** argv)
if( nExit != 0 ) if( nExit != 0 )
{ {
if( aCommand.aListFile.Len() ) if( !aCommand.aListFile.isEmpty() )
DirEntry( aTmpListFile ).Kill(); {
if( aCommand.aSlotMapFile.Len() ) osl::FileBase::getSystemPathFromFileURL( aTmpListFile, aTmpListFile );
DirEntry( aTmpSlotMapFile ).Kill(); osl::File::remove( aTmpListFile );
if( aCommand.aSfxItemFile.Len() ) }
DirEntry( aTmpSfxItemFile ).Kill(); if( !aCommand.aSlotMapFile.isEmpty() )
if( aCommand.aDataBaseFile.Len() ) {
DirEntry( aTmpDataBaseFile ).Kill(); osl::FileBase::getSystemPathFromFileURL( aTmpSlotMapFile, aTmpSlotMapFile );
if( aCommand.aCallingFile.Len() ) osl::File::remove( aTmpSlotMapFile );
DirEntry( aTmpCallingFile ).Kill(); }
if( aCommand.aCxxFile.Len() ) if( !aCommand.aSfxItemFile.isEmpty() )
DirEntry( aTmpCxxFile ).Kill(); {
if( aCommand.aHxxFile.Len() ) osl::FileBase::getSystemPathFromFileURL( aTmpSfxItemFile, aTmpSfxItemFile );
DirEntry( aTmpHxxFile ).Kill(); osl::File::remove( aTmpSfxItemFile );
}
if( !aCommand.aDataBaseFile.isEmpty() )
{
osl::FileBase::getSystemPathFromFileURL( aTmpDataBaseFile, aTmpDataBaseFile );
osl::File::remove( aTmpDataBaseFile );
}
} }
delete pDataBase; delete pDataBase;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment