Kaydet (Commit) 2d8c990f authored tarafından Ivo Hinkelmann's avatar Ivo Hinkelmann

INTEGRATION: CWS reportdesign01 (1.26.10); FILE MERGED

2007/10/15 06:33:11 oj 1.26.10.1: #i79214# new method to allow to start not with zero
üst e0d33795
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: tempfile.cxx,v $ * $RCSfile: tempfile.cxx,v $
* *
* $Revision: 1.26 $ * $Revision: 1.27 $
* *
* last change: $Author: ihi $ $Date: 2007-06-05 18:32:32 $ * last change: $Author: ihi $ $Date: 2007-11-20 19:18:22 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -273,49 +273,22 @@ umask(old_mode); ...@@ -273,49 +273,22 @@ umask(old_mode);
} }
} }
String TempFile::CreateTempName( const String* pParent ) void lcl_createName(TempFile_Impl& _rImpl,const String& rLeadingChars,sal_Bool _bStartWithZero, const String* pExtension, const String* pParent, sal_Bool bDirectory)
{ {
// get correct directory _rImpl.bIsDirectory = bDirectory;
String aName = ConstructTempDir_Impl( pParent );
// get TempFile name with default naming scheme
CreateTempName_Impl( aName, sal_False );
// convert to file URL
rtl::OUString aTmp;
if ( aName.Len() )
FileBase::getSystemPathFromFileURL( aName, aTmp );
return aTmp;
}
TempFile::TempFile( const String* pParent, sal_Bool bDirectory )
: pImp( new TempFile_Impl )
, bKillingFileEnabled( sal_False )
{
pImp->bIsDirectory = bDirectory;
// get correct directory
pImp->aName = ConstructTempDir_Impl( pParent );
// get TempFile with default naming scheme
CreateTempName_Impl( pImp->aName, sal_True, bDirectory );
}
TempFile::TempFile( const String& rLeadingChars, const String* pExtension, const String* pParent, sal_Bool bDirectory )
: pImp( new TempFile_Impl )
, bKillingFileEnabled( sal_False )
{
pImp->bIsDirectory = bDirectory;
// get correct directory // get correct directory
String aName = ConstructTempDir_Impl( pParent ); String aName = ConstructTempDir_Impl( pParent );
sal_Bool bUseNumber = _bStartWithZero;
// now use special naming scheme ( name takes leading chars and an index counting up from zero // now use special naming scheme ( name takes leading chars and an index counting up from zero
aName += rLeadingChars; aName += rLeadingChars;
for ( sal_Int32 i=0;; i++ ) for ( sal_Int32 i=0;; i++ )
{ {
String aTmp( aName ); String aTmp( aName );
aTmp += String::CreateFromInt32( i ); if ( bUseNumber )
aTmp += String::CreateFromInt32( i );
bUseNumber = sal_True;
if ( pExtension ) if ( pExtension )
aTmp += *pExtension; aTmp += *pExtension;
else else
...@@ -325,7 +298,7 @@ TempFile::TempFile( const String& rLeadingChars, const String* pExtension, const ...@@ -325,7 +298,7 @@ TempFile::TempFile( const String& rLeadingChars, const String* pExtension, const
FileBase::RC err = Directory::create( aTmp ); FileBase::RC err = Directory::create( aTmp );
if ( err == FileBase::E_None ) if ( err == FileBase::E_None )
{ {
pImp->aName = aTmp; _rImpl.aName = aTmp;
break; break;
} }
else if ( err != FileBase::E_EXIST ) else if ( err != FileBase::E_EXIST )
...@@ -345,7 +318,7 @@ umask(old_mode); ...@@ -345,7 +318,7 @@ umask(old_mode);
#endif #endif
if ( err == FileBase::E_None ) if ( err == FileBase::E_None )
{ {
pImp->aName = aTmp; _rImpl.aName = aTmp;
aFile.close(); aFile.close();
break; break;
} }
...@@ -362,9 +335,53 @@ umask(old_mode); ...@@ -362,9 +335,53 @@ umask(old_mode);
break; break;
} }
} }
if ( !_bStartWithZero )
aTmp += String::CreateFromInt32( i );
} }
} }
String TempFile::CreateTempName( const String* pParent )
{
// get correct directory
String aName = ConstructTempDir_Impl( pParent );
// get TempFile name with default naming scheme
CreateTempName_Impl( aName, sal_False );
// convert to file URL
rtl::OUString aTmp;
if ( aName.Len() )
FileBase::getSystemPathFromFileURL( aName, aTmp );
return aTmp;
}
TempFile::TempFile( const String* pParent, sal_Bool bDirectory )
: pImp( new TempFile_Impl )
, bKillingFileEnabled( sal_False )
{
pImp->bIsDirectory = bDirectory;
// get correct directory
pImp->aName = ConstructTempDir_Impl( pParent );
// get TempFile with default naming scheme
CreateTempName_Impl( pImp->aName, sal_True, bDirectory );
}
TempFile::TempFile( const String& rLeadingChars, const String* pExtension, const String* pParent, sal_Bool bDirectory)
: pImp( new TempFile_Impl )
, bKillingFileEnabled( sal_False )
{
lcl_createName(*pImp,rLeadingChars,sal_True, pExtension, pParent, bDirectory);
}
TempFile::TempFile( const String& rLeadingChars,sal_Bool _bStartWithZero, const String* pExtension, const String* pParent, sal_Bool bDirectory)
: pImp( new TempFile_Impl )
, bKillingFileEnabled( sal_False )
{
lcl_createName(*pImp,rLeadingChars,_bStartWithZero, pExtension, pParent, bDirectory);
}
TempFile::~TempFile() TempFile::~TempFile()
{ {
delete pImp->pStream; delete pImp->pStream;
......
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