diff options
Diffstat (limited to 'tools/source/fsys/dirent.cxx')
-rw-r--r-- | tools/source/fsys/dirent.cxx | 165 |
1 files changed, 0 insertions, 165 deletions
diff --git a/tools/source/fsys/dirent.cxx b/tools/source/fsys/dirent.cxx index be2899512e4e..4c42f478fb17 100644 --- a/tools/source/fsys/dirent.cxx +++ b/tools/source/fsys/dirent.cxx @@ -1463,171 +1463,6 @@ sal_Bool DirEntry::MakeDir( sal_Bool bSloppy ) const return sal_True; } -FSysError DirEntry::CopyTo( const DirEntry& rDest, FSysAction nActions ) const -{ - DBG_CHKTHIS( DirEntry, ImpCheckDirEntry ); - - if ( FSYS_ACTION_COPYFILE != (nActions & FSYS_ACTION_COPYFILE) ) -#ifdef UNX - { - // create hardlink - // redirection missing - rtl::OString aThis(rtl::OUStringToOString(GetFull(), osl_getThreadTextEncoding())); - rtl::OString aDest(rtl::OUStringToOString(rDest.GetFull(), osl_getThreadTextEncoding())); - if (link(aThis.getStr(), aDest.getStr()) == -1) - return Sys2SolarError_Impl( errno ); - else - return FSYS_ERR_OK; - } -#else - return FSYS_ERR_NOTSUPPORTED; -#endif - - FileCopier fc(*this, rDest); - return fc.Execute(nActions); -} - -#if defined WNT || defined UNX -FSysError DirEntry::MoveTo( const DirEntry& rNewName ) const -{ - DBG_CHKTHIS( DirEntry, ImpCheckDirEntry ); - - DirEntry aDest(rNewName); - FileStat aDestStat(rNewName); - if ( aDestStat.IsKind(FSYS_KIND_DIR ) ) - { - aDest += DirEntry(rtl::OStringToOUString(aName, osl_getThreadTextEncoding())); - } - if ( aDest.Exists() ) - { - return FSYS_ERR_ALREADYEXISTS; - } - - String aFrom( GetFull() ); - - String aTo( aDest.GetFull() ); - - rtl::OString bFrom(rtl::OUStringToOString(aFrom, osl_getThreadTextEncoding())); - rtl::OString bTo(rtl::OUStringToOString(aTo, osl_getThreadTextEncoding())); - -#ifdef WNT - // MoveTo nun atomar - SetLastError(0); - - DirEntry aFromDevice(rtl::OStringToOUString(bFrom, osl_getThreadTextEncoding())); - DirEntry aToDevice(rtl::OStringToOUString(bTo,osl_getThreadTextEncoding())); - aFromDevice.ToAbs(); - aToDevice.ToAbs(); - aFromDevice=aFromDevice.GetDevice(); - aToDevice=aToDevice.GetDevice(); - - if (aFromDevice==aToDevice) - { - // same device, use intra-device-move with MoveFile - MoveFile( bFrom.getStr(), bTo.getStr() ); - // Note: MoveFile is buggy for cross-device operations. - // Return value is TRUE, even if the operation was only partially successful. - // MoveFile has varying behavior between differing NT-versions. - return Sys2SolarError_Impl( GetLastError() ); - } - else - { - // Not the same device, use inter-device-move with copy/delete - FSysError nCopyError = CopyTo(rNewName, FSYS_ACTION_COPYFILE); - - DirEntry aKill(rtl::OStringToOUString(bTo, osl_getThreadTextEncoding())); - FileStat aKillStat(String(rtl::OStringToOUString(bTo, osl_getThreadTextEncoding()))); - if ( aKillStat.IsKind(FSYS_KIND_DIR ) ) - { - aKill += String(rtl::OStringToOUString(aName, osl_getThreadTextEncoding())); - } - - if (nCopyError==FSYS_ERR_OK) - { - if (Kill()==FSYS_ERR_OK) - { - return FSYS_ERR_OK; - } - else - { - aKill.Kill(); - return FSYS_ERR_ACCESSDENIED; - } - } - else - { - aKill.Kill(); - return nCopyError; - } - } -#else - // #68639# - // on some nfs connections rename with from == to - // leads to destruction of file - if ( ( aFrom != aTo ) && ( 0 != rename( bFrom.getStr(), bTo.getStr() ) ) ) -#if !defined(UNX) - return Sys2SolarError_Impl( GetLastError() ); -#else - { - if( errno == EXDEV ) - // simple rename does not work cross device - { - FILE *fpIN = fopen( bFrom.getStr(), "r" ); - FILE *fpOUT = fopen( bTo.getStr(), "w" ); - if( fpIN && fpOUT ) - { - char pBuf[ 16384 ]; - int nBytes, nWritten, nErr = 0; - errno = 0; - while( ( nBytes = fread( pBuf, 1, sizeof(pBuf), fpIN ) ) && ! nErr ) - { - nWritten = fwrite( pBuf, 1, nBytes, fpOUT ); - // Error in fwrite ? - if( nWritten < nBytes ) - { - nErr = errno; - break; - } - } - fclose( fpIN ); - fclose( fpOUT ); - if ( nErr ) - { - unlink( bTo.getStr() ); - return Sys2SolarError_Impl( nErr ); - } - else - { - unlink( bFrom.getStr() ); - } - } - else - { - if ( fpIN ) - fclose( fpIN ); - if ( fpOUT ) - fclose( fpOUT ); - return Sys2SolarError_Impl( EXDEV ); - } - } - else - { - return Sys2SolarError_Impl( errno ); - } - } -#endif -#endif - -// For the WNT case we always return already above, so avoid warning -// C4702: unreachable code. Possibly also in non-WNT cases we always -// return already above, but gcc apparently doesn't mind. -#ifndef WNT - return ERRCODE_NONE; -#endif -} - -#endif - FSysError DirEntry::Kill( FSysAction nActions ) const { DBG_CHKTHIS( DirEntry, ImpCheckDirEntry ); |