File API -> OSL
This commit is contained in:
@@ -2,9 +2,9 @@
|
|||||||
*
|
*
|
||||||
* $RCSfile: runtime.hxx,v $
|
* $RCSfile: runtime.hxx,v $
|
||||||
*
|
*
|
||||||
* $Revision: 1.1.1.1 $
|
* $Revision: 1.2 $
|
||||||
*
|
*
|
||||||
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
|
* last change: $Author: ab $ $Date: 2000-09-26 09:02:02 $
|
||||||
*
|
*
|
||||||
* The Contents of this file are made available subject to the terms of
|
* The Contents of this file are made available subject to the terms of
|
||||||
* either of the following licenses
|
* either of the following licenses
|
||||||
@@ -68,13 +68,25 @@
|
|||||||
#define _USE_UNO
|
#define _USE_UNO
|
||||||
|
|
||||||
#ifdef _USE_UNO
|
#ifdef _USE_UNO
|
||||||
|
#ifndef _RTL_USTRING_
|
||||||
#include <rtl/ustring>
|
#include <rtl/ustring>
|
||||||
|
#endif
|
||||||
|
#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
|
||||||
#include <com/sun/star/uno/Sequence.hxx>
|
#include <com/sun/star/uno/Sequence.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _OSL_FILE_HXX_
|
||||||
|
#include <osl/file.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace rtl;
|
using namespace rtl;
|
||||||
using namespace com::sun::star::uno;
|
using namespace com::sun::star::uno;
|
||||||
|
|
||||||
|
|
||||||
|
// Define activates old file implementation
|
||||||
|
// (only in non UCB case)
|
||||||
|
#define _OLD_FILE_IMPL
|
||||||
|
|
||||||
|
|
||||||
//#include <sal/types.h>
|
//#include <sal/types.h>
|
||||||
//#include <rtl/byteseq.hxx>
|
//#include <rtl/byteseq.hxx>
|
||||||
//#include <rtl/ustring>
|
//#include <rtl/ustring>
|
||||||
@@ -131,9 +143,15 @@ class Dir;
|
|||||||
class SbiRTLData
|
class SbiRTLData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
#ifdef _OLD_FILE_IMPL
|
||||||
Dir* pDir;
|
Dir* pDir;
|
||||||
|
#else
|
||||||
|
::osl::Directory* pDir;
|
||||||
|
#endif
|
||||||
INT16 nDirFlags;
|
INT16 nDirFlags;
|
||||||
USHORT nCurDirPos;
|
USHORT nCurDirPos;
|
||||||
|
|
||||||
#ifdef _USE_UNO
|
#ifdef _USE_UNO
|
||||||
Sequence< OUString > aDirSeq;
|
Sequence< OUString > aDirSeq;
|
||||||
#endif /* _USE_UNO */
|
#endif /* _USE_UNO */
|
||||||
@@ -470,4 +488,8 @@ String implGetCurDir( void );
|
|||||||
// has not to be infected with UNO)
|
// has not to be infected with UNO)
|
||||||
void implStepRenameUCB( const String& aSource, const String& aDest );
|
void implStepRenameUCB( const String& aSource, const String& aDest );
|
||||||
|
|
||||||
|
//*** OSL file access ***
|
||||||
|
String getFullPathUNC( const String& aRelPath );
|
||||||
|
void implStepRenameOSL( const String& aSource, const String& aDest );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -2,9 +2,9 @@
|
|||||||
*
|
*
|
||||||
* $RCSfile: iosys.cxx,v $
|
* $RCSfile: iosys.cxx,v $
|
||||||
*
|
*
|
||||||
* $Revision: 1.2 $
|
* $Revision: 1.3 $
|
||||||
*
|
*
|
||||||
* last change: $Author: patrick.luby $ $Date: 2000-09-25 02:53:43 $
|
* last change: $Author: ab $ $Date: 2000-09-26 09:01:36 $
|
||||||
*
|
*
|
||||||
* The Contents of this file are made available subject to the terms of
|
* The Contents of this file are made available subject to the terms of
|
||||||
* either of the following licenses
|
* either of the following licenses
|
||||||
@@ -75,6 +75,7 @@
|
|||||||
#include <vcl/svapp.hxx>
|
#include <vcl/svapp.hxx>
|
||||||
#endif
|
#endif
|
||||||
#include <osl/security.h>
|
#include <osl/security.h>
|
||||||
|
#include <osl/file.hxx>
|
||||||
|
|
||||||
#include "runtime.hxx"
|
#include "runtime.hxx"
|
||||||
|
|
||||||
@@ -119,6 +120,7 @@
|
|||||||
#include <com/sun/star/bridge/XBridgeFactory.hpp>
|
#include <com/sun/star/bridge/XBridgeFactory.hpp>
|
||||||
|
|
||||||
using namespace utl;
|
using namespace utl;
|
||||||
|
using namespace osl;
|
||||||
using namespace rtl;
|
using namespace rtl;
|
||||||
using namespace com::sun::star::uno;
|
using namespace com::sun::star::uno;
|
||||||
using namespace com::sun::star::lang;
|
using namespace com::sun::star::lang;
|
||||||
@@ -683,6 +685,105 @@ BOOL hasUno( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _OLD_FILE_IMPL
|
||||||
|
|
||||||
|
class OslStream : public SvStream
|
||||||
|
{
|
||||||
|
File maFile;
|
||||||
|
short mnStrmMode;
|
||||||
|
|
||||||
|
public:
|
||||||
|
OslStream( const String& rName, short nStrmMode );
|
||||||
|
~OslStream();
|
||||||
|
virtual ULONG GetData( void* pData, ULONG nSize );
|
||||||
|
virtual ULONG PutData( const void* pData, ULONG nSize );
|
||||||
|
virtual ULONG SeekPos( ULONG nPos );
|
||||||
|
virtual void FlushData();
|
||||||
|
virtual void SetSize( ULONG nSize );
|
||||||
|
};
|
||||||
|
|
||||||
|
OslStream::OslStream( const String& rName, short nStrmMode )
|
||||||
|
: maFile( rName )
|
||||||
|
, mnStrmMode( nStrmMode )
|
||||||
|
{
|
||||||
|
sal_uInt32 nFlags;
|
||||||
|
|
||||||
|
if( (nStrmMode & (STREAM_READ | STREAM_WRITE)) == (STREAM_READ | STREAM_WRITE) )
|
||||||
|
{
|
||||||
|
nFlags = OpenFlag_Read | OpenFlag_Write;
|
||||||
|
}
|
||||||
|
else if( nStrmMode & STREAM_WRITE )
|
||||||
|
{
|
||||||
|
nFlags = OpenFlag_Write;
|
||||||
|
}
|
||||||
|
else //if( nStrmMode & STREAM_READ )
|
||||||
|
{
|
||||||
|
nFlags = OpenFlag_Read;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileBase::RC nRet = maFile.open( nFlags );
|
||||||
|
if( nRet == FileBase::RC::E_NOENT && nFlags != OpenFlag_Read )
|
||||||
|
{
|
||||||
|
nFlags |= OpenFlag_Create;
|
||||||
|
nRet = maFile.open( nFlags );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( nRet != FileBase::RC::E_None )
|
||||||
|
{
|
||||||
|
SetError( ERRCODE_IO_GENERAL );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OslStream::~OslStream()
|
||||||
|
{
|
||||||
|
FileBase::RC nRet = maFile.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG OslStream::GetData( void* pData, ULONG nSize )
|
||||||
|
{
|
||||||
|
|
||||||
|
sal_uInt64 nBytesRead = nSize;
|
||||||
|
FileBase::RC nRet = maFile.read( pData, nBytesRead, nBytesRead );
|
||||||
|
return (ULONG)nBytesRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG OslStream::PutData( const void* pData, ULONG nSize )
|
||||||
|
{
|
||||||
|
sal_uInt64 nBytesWritten;
|
||||||
|
FileBase::RC nRet = maFile.write( pData, (sal_uInt64)nSize, nBytesWritten );
|
||||||
|
return (ULONG)nBytesWritten;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG OslStream::SeekPos( ULONG nPos )
|
||||||
|
{
|
||||||
|
FileBase::RC nRet;
|
||||||
|
if( nPos == STREAM_SEEK_TO_END )
|
||||||
|
{
|
||||||
|
nRet = maFile.setPos( Pos_End, 0 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nRet = maFile.setPos( Pos_Absolut, (sal_uInt64)nPos );
|
||||||
|
}
|
||||||
|
sal_uInt64 nRealPos;
|
||||||
|
nRet = maFile.getPos( nRealPos );
|
||||||
|
return nRealPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OslStream::FlushData()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void OslStream::SetSize( ULONG nSize )
|
||||||
|
{
|
||||||
|
FileBase::RC nRet = maFile.setSize( (sal_uInt64)nSize );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef _USE_UNO
|
#ifdef _USE_UNO
|
||||||
|
|
||||||
class UCBStream : public SvStream
|
class UCBStream : public SvStream
|
||||||
@@ -929,7 +1030,13 @@ SbError SbiStream::Open
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
if( !pStrm )
|
if( !pStrm )
|
||||||
|
{
|
||||||
|
#ifdef _OLD_FILE_IMPL
|
||||||
pStrm = new SvFileStream( aNameStr, nStrmMode );
|
pStrm = new SvFileStream( aNameStr, nStrmMode );
|
||||||
|
#else
|
||||||
|
pStrm = new OslStream( getFullPathUNC( aNameStr ), nStrmMode );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
if( IsAppend() )
|
if( IsAppend() )
|
||||||
pStrm->Seek( STREAM_SEEK_TO_END );
|
pStrm->Seek( STREAM_SEEK_TO_END );
|
||||||
MapError();
|
MapError();
|
||||||
@@ -943,7 +1050,11 @@ SbError SbiStream::Close()
|
|||||||
if( pStrm )
|
if( pStrm )
|
||||||
{
|
{
|
||||||
if( !hasUno() )
|
if( !hasUno() )
|
||||||
|
{
|
||||||
|
#ifdef _OLD_FILE_IMPL
|
||||||
((SvFileStream *)pStrm)->Close();
|
((SvFileStream *)pStrm)->Close();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
MapError();
|
MapError();
|
||||||
delete pStrm;
|
delete pStrm;
|
||||||
pStrm = NULL;
|
pStrm = NULL;
|
||||||
|
@@ -2,9 +2,9 @@
|
|||||||
*
|
*
|
||||||
* $RCSfile: methods.cxx,v $
|
* $RCSfile: methods.cxx,v $
|
||||||
*
|
*
|
||||||
* $Revision: 1.1.1.1 $
|
* $Revision: 1.2 $
|
||||||
*
|
*
|
||||||
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
|
* last change: $Author: ab $ $Date: 2000-09-26 09:01:44 $
|
||||||
*
|
*
|
||||||
* The Contents of this file are made available subject to the terms of
|
* The Contents of this file are made available subject to the terms of
|
||||||
* either of the following licenses
|
* either of the following licenses
|
||||||
@@ -66,9 +66,6 @@
|
|||||||
#ifndef _SBXVAR_HXX
|
#ifndef _SBXVAR_HXX
|
||||||
#include <svtools/sbxvar.hxx>
|
#include <svtools/sbxvar.hxx>
|
||||||
#endif
|
#endif
|
||||||
#ifndef _FSYS_HXX //autogen
|
|
||||||
#include <tools/fsys.hxx>
|
|
||||||
#endif
|
|
||||||
#ifndef _INTN_HXX //autogen
|
#ifndef _INTN_HXX //autogen
|
||||||
#include <tools/intn.hxx>
|
#include <tools/intn.hxx>
|
||||||
#endif
|
#endif
|
||||||
@@ -97,7 +94,7 @@
|
|||||||
#include <tools/solmath.hxx>
|
#include <tools/solmath.hxx>
|
||||||
#endif
|
#endif
|
||||||
#include <tools/urlobj.hxx>
|
#include <tools/urlobj.hxx>
|
||||||
#include <osl/file.hxx>
|
#include <osl/time.h>
|
||||||
|
|
||||||
#ifdef OS2
|
#ifdef OS2
|
||||||
#define INCL_WINWINDOWMGR
|
#define INCL_WINWINDOWMGR
|
||||||
@@ -117,6 +114,11 @@
|
|||||||
|
|
||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#include "runtime.hxx"
|
#include "runtime.hxx"
|
||||||
|
#ifdef _OLD_FILE_IMPL
|
||||||
|
#ifndef _FSYS_HXX //autogen
|
||||||
|
#include <tools/fsys.hxx>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _USE_UNO
|
#ifdef _USE_UNO
|
||||||
#include <unotools/processfactory.hxx>
|
#include <unotools/processfactory.hxx>
|
||||||
@@ -140,6 +142,8 @@ using namespace com::sun::star::io;
|
|||||||
|
|
||||||
#endif /* _USE_UNO */
|
#endif /* _USE_UNO */
|
||||||
|
|
||||||
|
//#define _ENABLE_CUR_DIR
|
||||||
|
|
||||||
#include "stdobj.hxx"
|
#include "stdobj.hxx"
|
||||||
#include "stdobj1.hxx"
|
#include "stdobj1.hxx"
|
||||||
#include "rtlproto.hxx"
|
#include "rtlproto.hxx"
|
||||||
@@ -227,16 +231,37 @@ static long GetDayDiff( const Date& rDate )
|
|||||||
|
|
||||||
|
|
||||||
//*** UCB file access ***
|
//*** UCB file access ***
|
||||||
|
|
||||||
// Converts possibly relative paths to absolute paths
|
// Converts possibly relative paths to absolute paths
|
||||||
// according to the setting done by ChDir/ChDrive
|
// according to the setting done by ChDir/ChDrive
|
||||||
// (Implemented in methods.cxx)
|
|
||||||
String getFullPath( const String& aRelPath )
|
String getFullPath( const String& aRelPath )
|
||||||
|
{
|
||||||
|
//return aRelPath;
|
||||||
|
|
||||||
|
String aUNCStr = getFullPathUNC( aRelPath );
|
||||||
|
|
||||||
|
OUString aFileURL;
|
||||||
|
FileBase::RC nRet = File::getFileURLFromNormalizedPath( aUNCStr, aFileURL );
|
||||||
|
return aFileURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//*** OSL file access ***
|
||||||
|
// Converts possibly relative paths to absolute paths
|
||||||
|
// according to the setting done by ChDir/ChDrive
|
||||||
|
String getFullPathUNC( const String& aRelPath )
|
||||||
{
|
{
|
||||||
// TODO: Use CurDir to build full path
|
// TODO: Use CurDir to build full path
|
||||||
// First step: Return given path unchanged
|
// First step: Return given path unchanged
|
||||||
return aRelPath;
|
|
||||||
|
//static inline RC getAbsolutePath( const ::rtl::OUString& strDirBase, const ::rtl::OUString& strRelative, ::rtl::OUString& strAbsolute )
|
||||||
|
|
||||||
|
OUString aNormPath;
|
||||||
|
FileBase::RC nRet = File::normalizePath( aRelPath, aNormPath );
|
||||||
|
return aNormPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Sets (virtual) current path for UCB file access
|
// Sets (virtual) current path for UCB file access
|
||||||
void implChDir( const String& aDir )
|
void implChDir( const String& aDir )
|
||||||
{
|
{
|
||||||
@@ -555,6 +580,7 @@ RTLFUNC(ChDir) // JSM
|
|||||||
rPar.Get(0)->PutEmpty();
|
rPar.Get(0)->PutEmpty();
|
||||||
if (rPar.Count() == 2)
|
if (rPar.Count() == 2)
|
||||||
{
|
{
|
||||||
|
#ifdef _ENABLE_CUR_DIR
|
||||||
String aPath = rPar.Get(1)->GetString();
|
String aPath = rPar.Get(1)->GetString();
|
||||||
BOOL bError = FALSE;
|
BOOL bError = FALSE;
|
||||||
#ifdef WNT
|
#ifdef WNT
|
||||||
@@ -570,6 +596,7 @@ RTLFUNC(ChDir) // JSM
|
|||||||
#endif
|
#endif
|
||||||
if( bError )
|
if( bError )
|
||||||
StarBASIC::Error( SbERR_PATH_NOT_FOUND );
|
StarBASIC::Error( SbERR_PATH_NOT_FOUND );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
StarBASIC::Error( SbERR_BAD_ARGUMENT );
|
StarBASIC::Error( SbERR_BAD_ARGUMENT );
|
||||||
@@ -580,6 +607,7 @@ RTLFUNC(ChDrive) // JSM
|
|||||||
rPar.Get(0)->PutEmpty();
|
rPar.Get(0)->PutEmpty();
|
||||||
if (rPar.Count() == 2)
|
if (rPar.Count() == 2)
|
||||||
{
|
{
|
||||||
|
#ifdef _ENABLE_CUR_DIR
|
||||||
// Keine Laufwerke in Unix
|
// Keine Laufwerke in Unix
|
||||||
#ifndef UNX
|
#ifndef UNX
|
||||||
String aPar1 = rPar.Get(1)->GetString();
|
String aPar1 = rPar.Get(1)->GetString();
|
||||||
@@ -619,6 +647,7 @@ RTLFUNC(ChDrive) // JSM
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
// #ifndef UNX
|
// #ifndef UNX
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
StarBASIC::Error( SbERR_BAD_ARGUMENT );
|
StarBASIC::Error( SbERR_BAD_ARGUMENT );
|
||||||
@@ -642,6 +671,16 @@ void implStepRenameUCB( const String& aSource, const String& aDest )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Implementation of StepRENAME with OSL
|
||||||
|
void implStepRenameOSL( const String& aSource, const String& aDest )
|
||||||
|
{
|
||||||
|
FileBase::RC nRet = File::move( getFullPathUNC( aSource ), getFullPathUNC( aDest ) );
|
||||||
|
if( nRet != FileBase::RC::E_None )
|
||||||
|
{
|
||||||
|
StarBASIC::Error( SbERR_PATH_NOT_FOUND );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RTLFUNC(FileCopy) // JSM
|
RTLFUNC(FileCopy) // JSM
|
||||||
{
|
{
|
||||||
rPar.Get(0)->PutEmpty();
|
rPar.Get(0)->PutEmpty();
|
||||||
@@ -668,6 +707,7 @@ RTLFUNC(FileCopy) // JSM
|
|||||||
else
|
else
|
||||||
// --> UCB
|
// --> UCB
|
||||||
{
|
{
|
||||||
|
#ifdef _OLD_FILE_IMPL
|
||||||
DirEntry aSourceDirEntry(aSource);
|
DirEntry aSourceDirEntry(aSource);
|
||||||
if (aSourceDirEntry.Exists())
|
if (aSourceDirEntry.Exists())
|
||||||
{
|
{
|
||||||
@@ -676,6 +716,13 @@ RTLFUNC(FileCopy) // JSM
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
StarBASIC::Error( SbERR_PATH_NOT_FOUND );
|
StarBASIC::Error( SbERR_PATH_NOT_FOUND );
|
||||||
|
#else
|
||||||
|
FileBase::RC nRet = File::copy( getFullPathUNC( aSource ), getFullPathUNC( aDest ) );
|
||||||
|
if( nRet != FileBase::RC::E_None )
|
||||||
|
{
|
||||||
|
StarBASIC::Error( SbERR_PATH_NOT_FOUND );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -708,8 +755,12 @@ RTLFUNC(Kill) // JSM
|
|||||||
else
|
else
|
||||||
// --> UCB
|
// --> UCB
|
||||||
{
|
{
|
||||||
|
#ifdef _OLD_FILE_IMPL
|
||||||
if(DirEntry(aFileSpec).Kill() != FSYS_ERR_OK)
|
if(DirEntry(aFileSpec).Kill() != FSYS_ERR_OK)
|
||||||
StarBASIC::Error( SbERR_PATH_NOT_FOUND );
|
StarBASIC::Error( SbERR_PATH_NOT_FOUND );
|
||||||
|
#else
|
||||||
|
File::remove( getFullPathUNC( aFileSpec ) );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -742,14 +793,78 @@ RTLFUNC(MkDir) // JSM
|
|||||||
else
|
else
|
||||||
// --> UCB
|
// --> UCB
|
||||||
{
|
{
|
||||||
|
#ifdef _OLD_FILE_IMPL
|
||||||
if (!DirEntry(aPath).MakeDir())
|
if (!DirEntry(aPath).MakeDir())
|
||||||
StarBASIC::Error( SbERR_PATH_NOT_FOUND );
|
StarBASIC::Error( SbERR_PATH_NOT_FOUND );
|
||||||
|
#else
|
||||||
|
Directory::create( getFullPathUNC( aPath ) );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
StarBASIC::Error( SbERR_BAD_ARGUMENT );
|
StarBASIC::Error( SbERR_BAD_ARGUMENT );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _OLD_FILE_IMPL
|
||||||
|
|
||||||
|
// In OSL only empty directories can be deleted
|
||||||
|
// so we have to delete all files recursively
|
||||||
|
void implRemoveDirRecursive( const String& aDirPath )
|
||||||
|
{
|
||||||
|
DirectoryItem aItem;
|
||||||
|
FileBase::RC nRet = DirectoryItem::get( aDirPath, aItem );
|
||||||
|
sal_Bool bExists = (nRet == FileBase::RC::E_None);
|
||||||
|
|
||||||
|
FileStatus aFileStatus( FileStatusMask_Type );
|
||||||
|
nRet = aItem.getFileStatus( aFileStatus );
|
||||||
|
FileStatus::Type aType = aFileStatus.getFileType();
|
||||||
|
sal_Bool bFolder = (aType == FileStatus::Type::Directory);
|
||||||
|
|
||||||
|
if( !bExists || !bFolder )
|
||||||
|
{
|
||||||
|
StarBASIC::Error( SbERR_PATH_NOT_FOUND );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Directory aDir( aDirPath );
|
||||||
|
nRet = aDir.open();
|
||||||
|
if( nRet != FileBase::RC::E_None )
|
||||||
|
{
|
||||||
|
StarBASIC::Error( SbERR_PATH_NOT_FOUND );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
DirectoryItem aItem;
|
||||||
|
nRet = aDir.getNextItem( aItem );
|
||||||
|
if( nRet != FileBase::RC::E_None )
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Handle flags
|
||||||
|
FileStatus aFileStatus( FileStatusMask_Type | FileStatusMask_FilePath );
|
||||||
|
nRet = aItem.getFileStatus( aFileStatus );
|
||||||
|
OUString aPath = aFileStatus.getFilePath();
|
||||||
|
|
||||||
|
// Directory?
|
||||||
|
FileStatus::Type aType = aFileStatus.getFileType();
|
||||||
|
sal_Bool bFolder = (aType == FileStatus::Type::Directory);
|
||||||
|
if( bFolder )
|
||||||
|
{
|
||||||
|
implRemoveDirRecursive( aPath );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
File::remove( aPath );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nRet = Directory::remove( aDirPath );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
RTLFUNC(RmDir) // JSM
|
RTLFUNC(RmDir) // JSM
|
||||||
{
|
{
|
||||||
rPar.Get(0)->PutEmpty();
|
rPar.Get(0)->PutEmpty();
|
||||||
@@ -775,9 +890,13 @@ RTLFUNC(RmDir) // JSM
|
|||||||
else
|
else
|
||||||
// --> UCB
|
// --> UCB
|
||||||
{
|
{
|
||||||
|
#ifdef _OLD_FILE_IMPL
|
||||||
DirEntry aDirEntry(aPath);
|
DirEntry aDirEntry(aPath);
|
||||||
if (aDirEntry.Kill() != FSYS_ERR_OK)
|
if (aDirEntry.Kill() != FSYS_ERR_OK)
|
||||||
StarBASIC::Error( SbERR_PATH_NOT_FOUND );
|
StarBASIC::Error( SbERR_PATH_NOT_FOUND );
|
||||||
|
#else
|
||||||
|
implRemoveDirRecursive( getFullPathUNC( aPath ) );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -831,8 +950,16 @@ RTLFUNC(FileLen)
|
|||||||
else
|
else
|
||||||
// --> UCB
|
// --> UCB
|
||||||
{
|
{
|
||||||
|
#ifdef _OLD_FILE_IMPL
|
||||||
FileStat aStat = DirEntry( aStr );
|
FileStat aStat = DirEntry( aStr );
|
||||||
nLen = aStat.GetSize();
|
nLen = aStat.GetSize();
|
||||||
|
#else
|
||||||
|
DirectoryItem aItem;
|
||||||
|
FileBase::RC nRet = DirectoryItem::get( getFullPathUNC( aStr ), aItem );
|
||||||
|
FileStatus aFileStatus( FileStatusMask_FileSize );
|
||||||
|
nRet = aItem.getFileStatus( aFileStatus );
|
||||||
|
nLen = (INT32)aFileStatus.getFileSize();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
rPar.Get(0)->PutLong( (long)nLen );
|
rPar.Get(0)->PutLong( (long)nLen );
|
||||||
}
|
}
|
||||||
@@ -1815,11 +1942,7 @@ RTLFUNC(Dir)
|
|||||||
{
|
{
|
||||||
if ( nParCount >= 2 )
|
if ( nParCount >= 2 )
|
||||||
{
|
{
|
||||||
String aStr = getFullPath( rPar.Get(1)->GetString() );
|
String aFileURLStr = getFullPath( rPar.Get(1)->GetString() );
|
||||||
OUString aUNCPath;
|
|
||||||
FileBase::normalizePath( aStr, aUNCPath );
|
|
||||||
OUString aFileURLStr;
|
|
||||||
FileBase::getFileURLFromNormalizedPath( aUNCPath, aFileURLStr );
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -1827,10 +1950,6 @@ RTLFUNC(Dir)
|
|||||||
sal_Bool bFolder = sal_False;
|
sal_Bool bFolder = sal_False;
|
||||||
try { bFolder = xSFI->isFolder( aFileURLStr ); }
|
try { bFolder = xSFI->isFolder( aFileURLStr ); }
|
||||||
catch( Exception & ) {}
|
catch( Exception & ) {}
|
||||||
//catch( ::ucb::ContentCreationException & e )
|
|
||||||
//{
|
|
||||||
//::ucb::ContentCreationException::Reason aReason = e.getReason();
|
|
||||||
//}
|
|
||||||
|
|
||||||
if( bFolder )
|
if( bFolder )
|
||||||
{
|
{
|
||||||
@@ -1843,10 +1962,6 @@ RTLFUNC(Dir)
|
|||||||
// Not folder but exists? Return file!
|
// Not folder but exists? Return file!
|
||||||
sal_Bool bExists = sal_False;
|
sal_Bool bExists = sal_False;
|
||||||
try { bExists = xSFI->exists( aFileURLStr ); }
|
try { bExists = xSFI->exists( aFileURLStr ); }
|
||||||
//catch( ::ucb::ContentCreationException & e )
|
|
||||||
//{
|
|
||||||
//::ucb::ContentCreationException::Reason aReason = e.getReason();
|
|
||||||
//}
|
|
||||||
catch( Exception & ) {}
|
catch( Exception & ) {}
|
||||||
if( bExists )
|
if( bExists )
|
||||||
{
|
{
|
||||||
@@ -1914,6 +2029,7 @@ RTLFUNC(Dir)
|
|||||||
else
|
else
|
||||||
// --> UCB
|
// --> UCB
|
||||||
{
|
{
|
||||||
|
#ifdef _OLD_FILE_IMPL
|
||||||
if ( nParCount >= 2 )
|
if ( nParCount >= 2 )
|
||||||
{
|
{
|
||||||
delete pRTLData->pDir;
|
delete pRTLData->pDir;
|
||||||
@@ -1994,6 +2110,107 @@ RTLFUNC(Dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
rPar.Get(0)->PutString( aPath );
|
rPar.Get(0)->PutString( aPath );
|
||||||
|
#else
|
||||||
|
// TODO: OSL
|
||||||
|
if ( nParCount >= 2 )
|
||||||
|
{
|
||||||
|
String aUNCStr = getFullPathUNC( rPar.Get(1)->GetString() );
|
||||||
|
String aDirUNCStr;
|
||||||
|
|
||||||
|
// Does path exist at all? TODO: Wildcards
|
||||||
|
DirectoryItem aItem;
|
||||||
|
FileBase::RC nRet = DirectoryItem::get( aUNCStr, aItem );
|
||||||
|
sal_Bool bExists = (nRet == FileBase::RC::E_None);
|
||||||
|
|
||||||
|
FileStatus aFileStatus( FileStatusMask_Type );
|
||||||
|
nRet = aItem.getFileStatus( aFileStatus );
|
||||||
|
FileStatus::Type aType = aFileStatus.getFileType();
|
||||||
|
sal_Bool bFolder = (aType == FileStatus::Type::Directory);
|
||||||
|
|
||||||
|
if( bFolder )
|
||||||
|
{
|
||||||
|
aDirUNCStr = aUNCStr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Search last '/'
|
||||||
|
sal_Int32 iLastSlash = aUNCStr.SearchBackward( '/' );
|
||||||
|
|
||||||
|
if( bExists )
|
||||||
|
{
|
||||||
|
String aNameOnlyStr;
|
||||||
|
if( iLastSlash != STRING_NOTFOUND )
|
||||||
|
{
|
||||||
|
aNameOnlyStr = aUNCStr.Copy( iLastSlash + 1 );
|
||||||
|
}
|
||||||
|
rPar.Get(0)->PutString( aNameOnlyStr );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if( iLastSlash != STRING_NOTFOUND )
|
||||||
|
{
|
||||||
|
aDirUNCStr = aUNCStr.Copy( 0, iLastSlash );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rPar.Get(0)->PutString( String() );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
USHORT nFlags = 0;
|
||||||
|
if ( nParCount > 2 )
|
||||||
|
pRTLData->nDirFlags = nFlags = rPar.Get(2)->GetInteger();
|
||||||
|
else
|
||||||
|
pRTLData->nDirFlags = 0;
|
||||||
|
|
||||||
|
// Read directory
|
||||||
|
//sal_Bool bIncludeFolders = ((nFlags & Sb_ATTR_DIRECTORY) != 0);
|
||||||
|
pRTLData->pDir = new Directory( aDirUNCStr );
|
||||||
|
nRet = pRTLData->pDir->open();
|
||||||
|
if( nRet != FileBase::RC::E_None )
|
||||||
|
{
|
||||||
|
delete pRTLData->pDir;
|
||||||
|
pRTLData->pDir = NULL;
|
||||||
|
rPar.Get(0)->PutString( String() );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//pRTLData->nCurDirPos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( pRTLData->pDir )
|
||||||
|
{
|
||||||
|
sal_Bool bOnlyFolders = ((pRTLData->nDirFlags & Sb_ATTR_DIRECTORY) != 0);
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
DirectoryItem aItem;
|
||||||
|
FileBase::RC nRet = pRTLData->pDir->getNextItem( aItem );
|
||||||
|
if( nRet != FileBase::RC::E_None )
|
||||||
|
{
|
||||||
|
delete pRTLData->pDir;
|
||||||
|
pRTLData->pDir = NULL;
|
||||||
|
aPath.Erase();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle flags
|
||||||
|
FileStatus aFileStatus( FileStatusMask_Type | FileStatusMask_FileName );
|
||||||
|
nRet = aItem.getFileStatus( aFileStatus );
|
||||||
|
|
||||||
|
// Only directories?
|
||||||
|
if( bOnlyFolders )
|
||||||
|
{
|
||||||
|
FileStatus::Type aType = aFileStatus.getFileType();
|
||||||
|
sal_Bool bFolder = (aType == FileStatus::Type::Directory);
|
||||||
|
if( !bFolder )
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
aPath = aFileStatus.getFileName();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rPar.Get(0)->PutString( aPath );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2039,6 +2256,7 @@ RTLFUNC(GetAttr)
|
|||||||
else
|
else
|
||||||
// --> UCB
|
// --> UCB
|
||||||
{
|
{
|
||||||
|
#ifdef _OLD_FILE_IMPL
|
||||||
DirEntry aEntry( rPar.Get(1)->GetString() );
|
DirEntry aEntry( rPar.Get(1)->GetString() );
|
||||||
aEntry.ToAbs();
|
aEntry.ToAbs();
|
||||||
BOOL bUseFileStat = FALSE;
|
BOOL bUseFileStat = FALSE;
|
||||||
@@ -2082,6 +2300,22 @@ RTLFUNC(GetAttr)
|
|||||||
if( aEntry.GetFlag() & FSYS_FLAG_VOLUME )
|
if( aEntry.GetFlag() & FSYS_FLAG_VOLUME )
|
||||||
nFlags |= 0x0008; // ATTR_VOLUME
|
nFlags |= 0x0008; // ATTR_VOLUME
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
DirectoryItem aItem;
|
||||||
|
FileBase::RC nRet = DirectoryItem::get( getFullPathUNC( rPar.Get(1)->GetString() ), aItem );
|
||||||
|
FileStatus aFileStatus( FileStatusMask_Attributes | FileStatusMask_Type );
|
||||||
|
nRet = aItem.getFileStatus( aFileStatus );
|
||||||
|
sal_uInt64 nAttributes = aFileStatus.getAttributes();
|
||||||
|
sal_Bool bReadOnly = (nAttributes & Attribute_ReadOnly) != 0;
|
||||||
|
|
||||||
|
FileStatus::Type aType = aFileStatus.getFileType();
|
||||||
|
sal_Bool bDirectory = (aType == FileStatus::Type::Directory);
|
||||||
|
if( bReadOnly )
|
||||||
|
nFlags |= 0x0001; // ATTR_READONLY
|
||||||
|
if( bDirectory )
|
||||||
|
nFlags |= 0x0010; // ATTR_DIRECTORY
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
rPar.Get(0)->PutInteger( nFlags );
|
rPar.Get(0)->PutInteger( nFlags );
|
||||||
}
|
}
|
||||||
@@ -2096,7 +2330,6 @@ RTLFUNC(FileDateTime)
|
|||||||
StarBASIC::Error( SbERR_BAD_ARGUMENT );
|
StarBASIC::Error( SbERR_BAD_ARGUMENT );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
// <-- UCB
|
// <-- UCB
|
||||||
String aPath = rPar.Get(1)->GetString();
|
String aPath = rPar.Get(1)->GetString();
|
||||||
Time aTime;
|
Time aTime;
|
||||||
@@ -2121,10 +2354,23 @@ RTLFUNC(FileDateTime)
|
|||||||
else
|
else
|
||||||
// --> UCB
|
// --> UCB
|
||||||
{
|
{
|
||||||
|
#ifdef _OLD_FILE_IMPL
|
||||||
DirEntry aEntry( aPath );
|
DirEntry aEntry( aPath );
|
||||||
FileStat aStat( aEntry );
|
FileStat aStat( aEntry );
|
||||||
aTime = Time( aStat.TimeModified() );
|
aTime = Time( aStat.TimeModified() );
|
||||||
aDate = Date( aStat.DateModified() );
|
aDate = Date( aStat.DateModified() );
|
||||||
|
#else
|
||||||
|
DirectoryItem aItem;
|
||||||
|
FileBase::RC nRet = DirectoryItem::get( getFullPathUNC( aPath ), aItem );
|
||||||
|
FileStatus aFileStatus( FileStatusMask_ModifyTime );
|
||||||
|
nRet = aItem.getFileStatus( aFileStatus );
|
||||||
|
TimeValue aTimeVal = aFileStatus.getModifyTime();
|
||||||
|
oslDateTime aDT;
|
||||||
|
sal_Bool bRet = osl_getDateTimeFromTimeValue( &aTimeVal, &aDT );
|
||||||
|
|
||||||
|
aTime = Time( aDT.Hours, aDT.Minutes, aDT.Seconds, 10000000*aDT.NanoSeconds );
|
||||||
|
aDate = Date( aDT.Day, aDT.Month, aDT.Year );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
double fSerial = (double)GetDayDiff( aDate );
|
double fSerial = (double)GetDayDiff( aDate );
|
||||||
@@ -3120,6 +3366,7 @@ RTLFUNC(SetAttr) // JSM
|
|||||||
else
|
else
|
||||||
// --> UCB
|
// --> UCB
|
||||||
{
|
{
|
||||||
|
#ifdef _OLD_FILE_IMPL
|
||||||
// #57064 Bei virtuellen URLs den Real-Path extrahieren
|
// #57064 Bei virtuellen URLs den Real-Path extrahieren
|
||||||
DirEntry aEntry( aStr );
|
DirEntry aEntry( aStr );
|
||||||
String aFile = aEntry.GetFull();
|
String aFile = aEntry.GetFull();
|
||||||
@@ -3156,6 +3403,11 @@ RTLFUNC(SetAttr) // JSM
|
|||||||
else
|
else
|
||||||
StarBASIC::Error( SbERR_FILE_NOT_FOUND );
|
StarBASIC::Error( SbERR_FILE_NOT_FOUND );
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
sal_Bool bReadOnly = (nFlags & 0x0001) != 0; // ATTR_READONLY
|
||||||
|
sal_uInt64 nAttrs = bReadOnly ? Attribute_ReadOnly : 0;
|
||||||
|
String aPath = getFullPathUNC( rPar.Get(1)->GetString() );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -3217,8 +3469,14 @@ RTLFUNC(FileExists)
|
|||||||
else
|
else
|
||||||
// --> UCB
|
// --> UCB
|
||||||
{
|
{
|
||||||
|
#ifdef _OLD_FILE_IMPL
|
||||||
DirEntry aEntry( aStr );
|
DirEntry aEntry( aStr );
|
||||||
bExists = aEntry.Exists();
|
bExists = aEntry.Exists();
|
||||||
|
#else
|
||||||
|
DirectoryItem aItem;
|
||||||
|
FileBase::RC nRet = DirectoryItem::get( getFullPathUNC( aStr ), aItem );
|
||||||
|
bExists = (nRet == FileBase::RC::E_None);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
rPar.Get(0)->PutBool( bExists );
|
rPar.Get(0)->PutBool( bExists );
|
||||||
}
|
}
|
||||||
|
@@ -2,9 +2,9 @@
|
|||||||
*
|
*
|
||||||
* $RCSfile: step0.cxx,v $
|
* $RCSfile: step0.cxx,v $
|
||||||
*
|
*
|
||||||
* $Revision: 1.1.1.1 $
|
* $Revision: 1.2 $
|
||||||
*
|
*
|
||||||
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
|
* last change: $Author: ab $ $Date: 2000-09-26 09:01:52 $
|
||||||
*
|
*
|
||||||
* The Contents of this file are made available subject to the terms of
|
* The Contents of this file are made available subject to the terms of
|
||||||
* either of the following licenses
|
* either of the following licenses
|
||||||
@@ -747,6 +747,7 @@ void SbiRuntime::StepRENAME() // Rename Tos+1 to Tos
|
|||||||
else
|
else
|
||||||
// --> UCB
|
// --> UCB
|
||||||
{
|
{
|
||||||
|
#ifdef _OLD_FILE_IMPL
|
||||||
DirEntry aSourceDirEntry( aSource );
|
DirEntry aSourceDirEntry( aSource );
|
||||||
if( aSourceDirEntry.Exists() )
|
if( aSourceDirEntry.Exists() )
|
||||||
{
|
{
|
||||||
@@ -755,6 +756,9 @@ void SbiRuntime::StepRENAME() // Rename Tos+1 to Tos
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
StarBASIC::Error( SbERR_PATH_NOT_FOUND );
|
StarBASIC::Error( SbERR_PATH_NOT_FOUND );
|
||||||
|
#else
|
||||||
|
implStepRenameOSL( aSource, aDest );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user