2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 12:59:11 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 12:59:11 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 12:59:11 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 12:59:11 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 12:59:11 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 12:59:11 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 00:02:01 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <limits.h>
|
|
|
|
|
2007-06-27 21:19:35 +00:00
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#include <tools/fsys.hxx>
|
|
|
|
#include <tools/stream.hxx>
|
2011-02-16 06:26:02 -08:00
|
|
|
#include <vector>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-10-16 03:20:00 -05:00
|
|
|
#include <osl/mutex.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <osl/thread.h> // osl_getThreadTextEncoding
|
|
|
|
|
|
|
|
// class FileBase
|
|
|
|
#include <osl/file.hxx>
|
2012-01-17 21:59:22 +02:00
|
|
|
#include <osl/detail/file.h>
|
2004-06-25 16:25:44 +00:00
|
|
|
#include <rtl/instance.hxx>
|
2011-06-29 09:02:15 +01:00
|
|
|
#include <rtl/strbuf.hxx>
|
2004-06-25 16:25:44 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
using namespace osl;
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// ----------------
|
|
|
|
// - InternalLock -
|
|
|
|
// ----------------
|
|
|
|
|
2010-10-16 03:20:00 -05:00
|
|
|
namespace { struct LockMutex : public rtl::Static< osl::Mutex, LockMutex > {}; }
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
class InternalStreamLock
|
|
|
|
{
|
2012-01-19 11:05:51 +00:00
|
|
|
sal_Size m_nStartPos;
|
|
|
|
sal_Size m_nEndPos;
|
|
|
|
SvFileStream* m_pStream;
|
|
|
|
osl::DirectoryItem m_aItem;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-06-17 12:12:48 +00:00
|
|
|
InternalStreamLock( sal_Size, sal_Size, SvFileStream* );
|
2000-09-18 16:07:07 +00:00
|
|
|
~InternalStreamLock();
|
|
|
|
public:
|
2004-06-17 12:12:48 +00:00
|
|
|
static sal_Bool LockFile( sal_Size nStart, sal_Size nEnd, SvFileStream* );
|
|
|
|
static void UnlockFile( sal_Size nStart, sal_Size nEnd, SvFileStream* );
|
2000-09-18 16:07:07 +00:00
|
|
|
};
|
|
|
|
|
2011-02-16 06:26:02 -08:00
|
|
|
typedef ::std::vector< InternalStreamLock* > InternalStreamLockList;
|
|
|
|
namespace { struct LockList : public rtl::Static< InternalStreamLockList, LockList > {}; }
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
InternalStreamLock::InternalStreamLock(
|
2004-06-17 12:12:48 +00:00
|
|
|
sal_Size nStart,
|
|
|
|
sal_Size nEnd,
|
2000-09-18 16:07:07 +00:00
|
|
|
SvFileStream* pStream ) :
|
|
|
|
m_nStartPos( nStart ),
|
|
|
|
m_nEndPos( nEnd ),
|
|
|
|
m_pStream( pStream )
|
|
|
|
{
|
2012-01-19 11:05:51 +00:00
|
|
|
osl::DirectoryItem::get( m_pStream->GetFileName(), m_aItem );
|
2011-02-16 06:26:02 -08:00
|
|
|
LockList::get().push_back( this );
|
2003-04-15 16:56:06 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2012-01-19 11:05:51 +00:00
|
|
|
rtl::OString aFileName(rtl::OUStringToOString(m_pStream->GetFileName(),
|
|
|
|
osl_getThreadTextEncoding()));
|
2011-08-30 23:42:11 +01:00
|
|
|
fprintf( stderr, "locked %s", aFileName.getStr() );
|
2000-09-18 16:07:07 +00:00
|
|
|
if( m_nStartPos || m_nEndPos )
|
2010-03-18 14:24:20 +01:00
|
|
|
fprintf(stderr, " [ %ld ... %ld ]", m_nStartPos, m_nEndPos );
|
2000-09-18 16:07:07 +00:00
|
|
|
fprintf( stderr, "\n" );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
InternalStreamLock::~InternalStreamLock()
|
|
|
|
{
|
2011-02-16 06:26:02 -08:00
|
|
|
for ( InternalStreamLockList::iterator it = LockList::get().begin();
|
|
|
|
it < LockList::get().end();
|
|
|
|
++it
|
|
|
|
) {
|
|
|
|
if ( this == *it ) {
|
|
|
|
LockList::get().erase( it );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-04-15 16:56:06 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2011-08-30 23:42:11 +01:00
|
|
|
rtl::OString aFileName(rtl::OUStringToOString(m_pStream->GetFileName(),
|
2012-01-19 11:05:51 +00:00
|
|
|
osl_getThreadTextEncoding()));
|
2011-08-30 23:42:11 +01:00
|
|
|
fprintf( stderr, "unlocked %s", aFileName.getStr() );
|
2000-09-18 16:07:07 +00:00
|
|
|
if( m_nStartPos || m_nEndPos )
|
2010-03-18 14:24:20 +01:00
|
|
|
fprintf(stderr, " [ %ld ... %ld ]", m_nStartPos, m_nEndPos );
|
2000-09-18 16:07:07 +00:00
|
|
|
fprintf( stderr, "\n" );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2004-06-17 12:12:48 +00:00
|
|
|
sal_Bool InternalStreamLock::LockFile( sal_Size nStart, sal_Size nEnd, SvFileStream* pStream )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2010-10-16 03:20:00 -05:00
|
|
|
osl::MutexGuard aGuard( LockMutex::get() );
|
2012-01-19 11:05:51 +00:00
|
|
|
osl::DirectoryItem aItem;
|
2012-01-19 14:01:45 +02:00
|
|
|
if (osl::DirectoryItem::get( pStream->GetFileName(), aItem) != osl::FileBase::E_None )
|
2012-01-19 11:05:51 +00:00
|
|
|
{
|
|
|
|
SAL_INFO("tools", "Failed to lookup stream for locking");
|
|
|
|
return sal_True;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-01-19 11:05:51 +00:00
|
|
|
osl::FileStatus aStatus( osl_FileStatus_Mask_Type );
|
2012-01-19 14:01:45 +02:00
|
|
|
if ( aItem.getFileStatus( aStatus ) != osl::FileBase::E_None )
|
2012-01-19 11:05:51 +00:00
|
|
|
{
|
|
|
|
SAL_INFO("tools", "Failed to stat stream for locking");
|
|
|
|
return sal_True;
|
|
|
|
}
|
2012-01-19 14:01:45 +02:00
|
|
|
if( aStatus.getFileType() == osl::FileStatus::Directory )
|
2004-06-17 12:12:48 +00:00
|
|
|
return sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
InternalStreamLock* pLock = NULL;
|
2004-06-25 16:25:44 +00:00
|
|
|
InternalStreamLockList &rLockList = LockList::get();
|
2011-02-16 06:26:02 -08:00
|
|
|
for( size_t i = 0; i < rLockList.size(); ++i )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-02-16 06:26:02 -08:00
|
|
|
pLock = rLockList[ i ];
|
2012-01-19 14:01:33 +00:00
|
|
|
if( aItem.isIdenticalTo( pLock->m_aItem ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-06-17 12:12:48 +00:00
|
|
|
sal_Bool bDenyByOptions = sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
StreamMode nLockMode = pLock->m_pStream->GetStreamMode();
|
|
|
|
StreamMode nNewMode = pStream->GetStreamMode();
|
|
|
|
|
|
|
|
if( nLockMode & STREAM_SHARE_DENYALL )
|
2004-06-17 12:12:48 +00:00
|
|
|
bDenyByOptions = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
else if( ( nLockMode & STREAM_SHARE_DENYWRITE ) &&
|
|
|
|
( nNewMode & STREAM_WRITE ) )
|
2004-06-17 12:12:48 +00:00
|
|
|
bDenyByOptions = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
else if( ( nLockMode & STREAM_SHARE_DENYREAD ) &&
|
|
|
|
( nNewMode & STREAM_READ ) )
|
2004-06-17 12:12:48 +00:00
|
|
|
bDenyByOptions = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if( bDenyByOptions )
|
|
|
|
{
|
|
|
|
if( pLock->m_nStartPos == 0 && pLock->m_nEndPos == 0 ) // whole file is already locked
|
2004-06-17 12:12:48 +00:00
|
|
|
return sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
if( nStart == 0 && nEnd == 0) // cannot lock whole file
|
2004-06-17 12:12:48 +00:00
|
|
|
return sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if( ( nStart < pLock->m_nStartPos && nEnd > pLock->m_nStartPos ) ||
|
|
|
|
( nStart < pLock->m_nEndPos && nEnd > pLock->m_nEndPos ) )
|
2004-06-17 12:12:48 +00:00
|
|
|
return sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-02-16 06:26:02 -08:00
|
|
|
// hint: new InternalStreamLock() adds the entry to the global list
|
2000-09-18 16:07:07 +00:00
|
|
|
pLock = new InternalStreamLock( nStart, nEnd, pStream );
|
2004-06-17 12:12:48 +00:00
|
|
|
return sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2004-06-17 12:12:48 +00:00
|
|
|
void InternalStreamLock::UnlockFile( sal_Size nStart, sal_Size nEnd, SvFileStream* pStream )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2010-10-16 03:20:00 -05:00
|
|
|
osl::MutexGuard aGuard( LockMutex::get() );
|
2000-09-18 16:07:07 +00:00
|
|
|
InternalStreamLock* pLock = NULL;
|
2004-06-25 16:25:44 +00:00
|
|
|
InternalStreamLockList &rLockList = LockList::get();
|
2000-09-18 16:07:07 +00:00
|
|
|
if( nStart == 0 && nEnd == 0 )
|
|
|
|
{
|
2011-02-16 06:26:02 -08:00
|
|
|
// nStart & nEnd = 0, so delete all locks
|
|
|
|
for( size_t i = 0; i < rLockList.size(); ++i )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-02-16 06:26:02 -08:00
|
|
|
if( ( pLock = rLockList[ i ] )->m_pStream == pStream )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-02-16 06:26:02 -08:00
|
|
|
// hint: delete will remove pLock from the global list
|
2000-09-18 16:07:07 +00:00
|
|
|
delete pLock;
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2011-02-16 06:26:02 -08:00
|
|
|
for( size_t i = 0; i < rLockList.size(); ++i )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-02-16 06:26:02 -08:00
|
|
|
if ( ( pLock = rLockList[ i ] )->m_pStream == pStream
|
|
|
|
&& nStart == pLock->m_nStartPos
|
|
|
|
&& nEnd == pLock->m_nEndPos
|
|
|
|
) {
|
|
|
|
// hint: delete will remove pLock from the global list
|
2000-09-18 16:07:07 +00:00
|
|
|
delete pLock;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-16 06:26:02 -08:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// --------------
|
|
|
|
// - StreamData -
|
|
|
|
// --------------
|
|
|
|
|
|
|
|
class StreamData
|
|
|
|
{
|
|
|
|
public:
|
2012-01-17 21:59:22 +02:00
|
|
|
oslFileHandle rHandle;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-01-19 12:23:23 +00:00
|
|
|
StreamData() : rHandle( 0 ) { }
|
2000-09-18 16:07:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2004-06-17 12:12:48 +00:00
|
|
|
static sal_uInt32 GetSvError( int nErrno )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-06-17 12:12:48 +00:00
|
|
|
static struct { int nErr; sal_uInt32 sv; } errArr[] =
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
{ 0, SVSTREAM_OK },
|
|
|
|
{ EACCES, SVSTREAM_ACCESS_DENIED },
|
|
|
|
{ EBADF, SVSTREAM_INVALID_HANDLE },
|
2011-10-03 01:46:06 +09:00
|
|
|
#if defined(RS6000) || defined(NETBSD) || \
|
2011-02-15 12:12:14 +00:00
|
|
|
defined(FREEBSD) || defined(MACOSX) || defined(OPENBSD) || \
|
2011-06-15 17:59:53 +03:00
|
|
|
defined(__FreeBSD_kernel__) || defined (AIX) || defined(DRAGONFLY) || \
|
|
|
|
defined(IOS)
|
2000-09-18 16:07:07 +00:00
|
|
|
{ EDEADLK, SVSTREAM_LOCKING_VIOLATION },
|
|
|
|
#else
|
|
|
|
{ EDEADLOCK, SVSTREAM_LOCKING_VIOLATION },
|
|
|
|
#endif
|
|
|
|
{ EINVAL, SVSTREAM_INVALID_PARAMETER },
|
|
|
|
{ EMFILE, SVSTREAM_TOO_MANY_OPEN_FILES },
|
|
|
|
{ ENFILE, SVSTREAM_TOO_MANY_OPEN_FILES },
|
|
|
|
{ ENOENT, SVSTREAM_FILE_NOT_FOUND },
|
|
|
|
{ EPERM, SVSTREAM_ACCESS_DENIED },
|
|
|
|
{ EROFS, SVSTREAM_ACCESS_DENIED },
|
|
|
|
{ EAGAIN, SVSTREAM_LOCKING_VIOLATION },
|
|
|
|
{ EISDIR, SVSTREAM_PATH_NOT_FOUND },
|
|
|
|
{ ELOOP, SVSTREAM_PATH_NOT_FOUND },
|
2011-10-03 01:46:06 +09:00
|
|
|
#if !defined(RS6000) && !defined(NETBSD) && !defined (FREEBSD) && \
|
2011-02-15 12:12:14 +00:00
|
|
|
!defined(MACOSX) && !defined(OPENBSD) && !defined(__FreeBSD_kernel__) && \
|
|
|
|
!defined(DRAGONFLY)
|
2000-09-18 16:07:07 +00:00
|
|
|
{ EMULTIHOP, SVSTREAM_PATH_NOT_FOUND },
|
|
|
|
{ ENOLINK, SVSTREAM_PATH_NOT_FOUND },
|
|
|
|
#endif
|
|
|
|
{ ENOTDIR, SVSTREAM_PATH_NOT_FOUND },
|
|
|
|
{ ETXTBSY, SVSTREAM_ACCESS_DENIED },
|
|
|
|
{ EEXIST, SVSTREAM_CANNOT_MAKE },
|
|
|
|
{ ENOSPC, SVSTREAM_DISK_FULL },
|
|
|
|
{ (int)0xFFFF, SVSTREAM_GENERALERROR }
|
|
|
|
};
|
|
|
|
|
2004-06-17 12:12:48 +00:00
|
|
|
sal_uInt32 nRetVal = SVSTREAM_GENERALERROR; // Standardfehler
|
2000-09-18 16:07:07 +00:00
|
|
|
int i=0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if ( errArr[i].nErr == nErrno )
|
|
|
|
{
|
|
|
|
nRetVal = errArr[i].sv;
|
|
|
|
break;
|
|
|
|
}
|
2004-06-25 16:25:44 +00:00
|
|
|
++i;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
while( errArr[i].nErr != 0xFFFF );
|
|
|
|
return nRetVal;
|
|
|
|
}
|
|
|
|
|
2012-01-17 21:59:22 +02:00
|
|
|
static sal_uInt32 GetSvError( oslFileError nErrno )
|
|
|
|
{
|
|
|
|
static struct { oslFileError nErr; sal_uInt32 sv; } errArr[] =
|
|
|
|
{
|
|
|
|
{ osl_File_E_None, SVSTREAM_OK },
|
|
|
|
{ osl_File_E_ACCES, SVSTREAM_ACCESS_DENIED },
|
|
|
|
{ osl_File_E_BADF, SVSTREAM_INVALID_HANDLE },
|
|
|
|
{ osl_File_E_DEADLK, SVSTREAM_LOCKING_VIOLATION },
|
|
|
|
{ osl_File_E_INVAL, SVSTREAM_INVALID_PARAMETER },
|
|
|
|
{ osl_File_E_MFILE, SVSTREAM_TOO_MANY_OPEN_FILES },
|
|
|
|
{ osl_File_E_NFILE, SVSTREAM_TOO_MANY_OPEN_FILES },
|
|
|
|
{ osl_File_E_NOENT, SVSTREAM_FILE_NOT_FOUND },
|
|
|
|
{ osl_File_E_PERM, SVSTREAM_ACCESS_DENIED },
|
|
|
|
{ osl_File_E_ROFS, SVSTREAM_ACCESS_DENIED },
|
|
|
|
{ osl_File_E_AGAIN, SVSTREAM_LOCKING_VIOLATION },
|
|
|
|
{ osl_File_E_ISDIR, SVSTREAM_PATH_NOT_FOUND },
|
|
|
|
{ osl_File_E_LOOP, SVSTREAM_PATH_NOT_FOUND },
|
|
|
|
{ osl_File_E_MULTIHOP, SVSTREAM_PATH_NOT_FOUND },
|
|
|
|
{ osl_File_E_NOLINK, SVSTREAM_PATH_NOT_FOUND },
|
|
|
|
{ osl_File_E_NOTDIR, SVSTREAM_PATH_NOT_FOUND },
|
|
|
|
{ osl_File_E_EXIST, SVSTREAM_CANNOT_MAKE },
|
|
|
|
{ osl_File_E_NOSPC, SVSTREAM_DISK_FULL },
|
|
|
|
{ (oslFileError)0xFFFF, SVSTREAM_GENERALERROR }
|
|
|
|
};
|
|
|
|
|
|
|
|
sal_uInt32 nRetVal = SVSTREAM_GENERALERROR; // Standardfehler
|
|
|
|
int i=0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if ( errArr[i].nErr == nErrno )
|
|
|
|
{
|
|
|
|
nRetVal = errArr[i].sv;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
while( errArr[i].nErr != (oslFileError)0xFFFF );
|
|
|
|
return nRetVal;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SvFileStream::SvFileStream()
|
|
|
|
|*
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
SvFileStream::SvFileStream( const String& rFileName, StreamMode nOpenMode )
|
|
|
|
{
|
2004-06-17 12:12:48 +00:00
|
|
|
bIsOpen = sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
nLockCounter = 0;
|
2004-06-17 12:12:48 +00:00
|
|
|
bIsWritable = sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
pInstanceData = new StreamData;
|
|
|
|
|
|
|
|
SetBufferSize( 1024 );
|
|
|
|
// convert URL to SystemPath, if necessary
|
2001-05-10 13:20:57 +00:00
|
|
|
::rtl::OUString aSystemFileName;
|
2006-06-19 12:52:12 +00:00
|
|
|
if( FileBase::getSystemPathFromFileURL( rFileName , aSystemFileName )
|
|
|
|
!= FileBase::E_None )
|
2001-05-10 13:20:57 +00:00
|
|
|
{
|
|
|
|
aSystemFileName = rFileName;
|
|
|
|
}
|
|
|
|
Open( aSystemFileName, nOpenMode );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SvFileStream::SvFileStream()
|
|
|
|
|*
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
SvFileStream::SvFileStream()
|
|
|
|
{
|
2004-06-17 12:12:48 +00:00
|
|
|
bIsOpen = sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
nLockCounter = 0;
|
2004-06-17 12:12:48 +00:00
|
|
|
bIsWritable = sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
pInstanceData = new StreamData;
|
|
|
|
SetBufferSize( 1024 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SvFileStream::~SvFileStream()
|
|
|
|
|*
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
SvFileStream::~SvFileStream()
|
|
|
|
{
|
|
|
|
Close();
|
|
|
|
|
|
|
|
InternalStreamLock::UnlockFile( 0, 0, this );
|
|
|
|
|
|
|
|
if (pInstanceData)
|
|
|
|
delete pInstanceData;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SvFileStream::GetFileHandle()
|
|
|
|
|*
|
|
|
|
*************************************************************************/
|
|
|
|
|
2004-06-17 12:12:48 +00:00
|
|
|
sal_uInt32 SvFileStream::GetFileHandle() const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-01-17 21:59:22 +02:00
|
|
|
sal_IntPtr handle;
|
|
|
|
if (osl_getFileOSHandle(pInstanceData->rHandle, &handle) == osl_File_E_None)
|
|
|
|
return (sal_uInt32) handle;
|
|
|
|
else
|
|
|
|
return (sal_uInt32) -1;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SvFileStream::IsA()
|
|
|
|
|*
|
|
|
|
*************************************************************************/
|
|
|
|
|
2004-06-17 12:12:48 +00:00
|
|
|
sal_uInt16 SvFileStream::IsA() const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return ID_FILESTREAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SvFileStream::GetData()
|
|
|
|
|*
|
|
|
|
*************************************************************************/
|
|
|
|
|
2004-06-17 12:12:48 +00:00
|
|
|
sal_Size SvFileStream::GetData( void* pData, sal_Size nSize )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
#ifdef DBG_UTIL
|
2011-06-29 09:02:15 +01:00
|
|
|
rtl::OStringBuffer aTraceStr(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM("SvFileStream::GetData(): "));
|
|
|
|
aTraceStr.append(static_cast<sal_Int64>(nSize));
|
|
|
|
aTraceStr.append(RTL_CONSTASCII_STRINGPARAM(" Bytes from "));
|
|
|
|
aTraceStr.append(rtl::OUStringToOString(aFilename,
|
|
|
|
osl_getThreadTextEncoding()));
|
|
|
|
OSL_TRACE("%s", aTraceStr.getStr());
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
|
|
|
|
2012-01-17 21:59:22 +02:00
|
|
|
sal_uInt64 nRead = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( IsOpen() )
|
|
|
|
{
|
2012-01-17 21:59:22 +02:00
|
|
|
oslFileError rc = osl_readFile(pInstanceData->rHandle,pData,(sal_uInt64)nSize,&nRead);
|
|
|
|
if ( rc != osl_File_E_None )
|
|
|
|
{
|
|
|
|
SetError( ::GetSvError( rc ));
|
|
|
|
return -1;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2004-06-17 12:12:48 +00:00
|
|
|
return (sal_Size)nRead;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SvFileStream::PutData()
|
|
|
|
|*
|
|
|
|
*************************************************************************/
|
|
|
|
|
2004-06-17 12:12:48 +00:00
|
|
|
sal_Size SvFileStream::PutData( const void* pData, sal_Size nSize )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
#ifdef DBG_UTIL
|
2011-06-29 09:02:15 +01:00
|
|
|
rtl::OStringBuffer aTraceStr(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM("SvFileStream::PutData(): "));
|
|
|
|
aTraceStr.append(static_cast<sal_Int64>(nSize));
|
|
|
|
aTraceStr.append(RTL_CONSTASCII_STRINGPARAM(" Bytes to "));
|
|
|
|
aTraceStr.append(rtl::OUStringToOString(aFilename,
|
|
|
|
osl_getThreadTextEncoding()));
|
|
|
|
OSL_TRACE("%s", aTraceStr.getStr());
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
|
|
|
|
2012-01-17 21:59:22 +02:00
|
|
|
sal_uInt64 nWrite = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( IsOpen() )
|
|
|
|
{
|
2012-01-17 21:59:22 +02:00
|
|
|
oslFileError rc = osl_writeFile(pInstanceData->rHandle,pData,(sal_uInt64)nSize,&nWrite);
|
|
|
|
if ( rc != osl_File_E_None )
|
|
|
|
{
|
|
|
|
SetError( ::GetSvError( rc ) );
|
|
|
|
return -1;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
else if( !nWrite )
|
2012-01-17 21:59:22 +02:00
|
|
|
SetError( SVSTREAM_DISK_FULL );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2004-06-17 12:12:48 +00:00
|
|
|
return (sal_Size)nWrite;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SvFileStream::SeekPos()
|
|
|
|
|*
|
|
|
|
*************************************************************************/
|
|
|
|
|
2004-06-17 12:12:48 +00:00
|
|
|
sal_Size SvFileStream::SeekPos( sal_Size nPos )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( IsOpen() )
|
|
|
|
{
|
2012-01-17 21:59:22 +02:00
|
|
|
oslFileError rc;
|
|
|
|
sal_uInt64 nNewPos;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nPos != STREAM_SEEK_TO_END )
|
2012-01-17 21:59:22 +02:00
|
|
|
rc = osl_setFilePos( pInstanceData->rHandle, osl_Pos_Absolut, nPos );
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2012-01-17 21:59:22 +02:00
|
|
|
rc = osl_setFilePos( pInstanceData->rHandle, osl_Pos_End, 0 );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-01-17 21:59:22 +02:00
|
|
|
if ( rc != osl_File_E_None )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
SetError( SVSTREAM_SEEK_ERROR );
|
|
|
|
return 0L;
|
|
|
|
}
|
2012-01-17 21:59:22 +02:00
|
|
|
rc = osl_getFilePos( pInstanceData->rHandle, &nNewPos );
|
|
|
|
return (sal_Size) nNewPos;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
SetError( SVSTREAM_GENERALERROR );
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SvFileStream::FlushData()
|
|
|
|
|*
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
void SvFileStream::FlushData()
|
|
|
|
{
|
|
|
|
// lokal gibt es nicht
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SvFileStream::LockRange()
|
|
|
|
|*
|
|
|
|
*************************************************************************/
|
|
|
|
|
2004-06-17 12:12:48 +00:00
|
|
|
sal_Bool SvFileStream::LockRange( sal_Size nByteOffset, sal_Size nBytes )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
int nLockMode = 0;
|
|
|
|
|
|
|
|
if ( ! IsOpen() )
|
2004-06-17 12:12:48 +00:00
|
|
|
return sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( eStreamMode & STREAM_SHARE_DENYALL )
|
2008-11-10 15:06:12 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
if (bIsWritable)
|
|
|
|
nLockMode = F_WRLCK;
|
|
|
|
else
|
|
|
|
nLockMode = F_RDLCK;
|
2008-11-10 15:06:12 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( eStreamMode & STREAM_SHARE_DENYREAD )
|
2008-11-10 15:06:12 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
if (bIsWritable)
|
|
|
|
nLockMode = F_WRLCK;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetError(SVSTREAM_LOCKING_VIOLATION);
|
2004-06-17 12:12:48 +00:00
|
|
|
return sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2008-11-10 15:06:12 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( eStreamMode & STREAM_SHARE_DENYWRITE )
|
2008-11-10 15:06:12 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
if (bIsWritable)
|
|
|
|
nLockMode = F_WRLCK;
|
|
|
|
else
|
|
|
|
nLockMode = F_RDLCK;
|
2008-11-10 15:06:12 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (!nLockMode)
|
2004-06-17 12:12:48 +00:00
|
|
|
return sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if( ! InternalStreamLock::LockFile( nByteOffset, nByteOffset+nBytes, this ) )
|
|
|
|
{
|
2003-04-15 16:56:06 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-03-18 14:24:20 +01:00
|
|
|
fprintf( stderr, "InternalLock on %s [ %ld ... %ld ] failed\n",
|
2011-11-25 20:51:38 +00:00
|
|
|
rtl::OUStringToOString(aFilename, osl_getThreadTextEncoding()).getStr(), nByteOffset, nByteOffset+nBytes );
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
2004-06-17 12:12:48 +00:00
|
|
|
return sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2004-06-17 12:12:48 +00:00
|
|
|
return sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SvFileStream::LockFile()
|
|
|
|
|*
|
|
|
|
*************************************************************************/
|
|
|
|
|
2004-06-17 12:12:48 +00:00
|
|
|
sal_Bool SvFileStream::LockFile()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return LockRange( 0UL, 0UL );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SvFileStream::Open()
|
|
|
|
|*
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
void SvFileStream::Open( const String& rFilename, StreamMode nOpenMode )
|
|
|
|
{
|
2012-01-17 21:59:22 +02:00
|
|
|
sal_uInt32 uFlags;
|
|
|
|
oslFileHandle nHandleTmp;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
Close();
|
|
|
|
errno = 0;
|
|
|
|
eStreamMode = nOpenMode;
|
|
|
|
eStreamMode &= ~STREAM_TRUNC; // beim ReOpen nicht cutten
|
|
|
|
|
|
|
|
// !!! NoOp: Ansonsten ToAbs() verwendern
|
|
|
|
// !!! DirEntry aDirEntry( rFilename );
|
|
|
|
// !!! aFilename = aDirEntry.GetFull();
|
|
|
|
aFilename = rFilename;
|
2011-08-30 23:42:11 +01:00
|
|
|
rtl::OString aLocalFilename(rtl::OUStringToOString(aFilename, osl_getThreadTextEncoding()));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#ifdef DBG_UTIL
|
2011-08-30 23:42:11 +01:00
|
|
|
rtl::OStringBuffer aTraceStr(RTL_CONSTASCII_STRINGPARAM(
|
|
|
|
"SvFileStream::Open(): "));
|
|
|
|
aTraceStr.append(aLocalFilename);
|
|
|
|
OSL_TRACE( "%s", aTraceStr.getStr() );
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
|
|
|
|
2012-01-19 12:23:23 +00:00
|
|
|
rtl::OUString aFileURL;
|
|
|
|
osl::DirectoryItem aItem;
|
|
|
|
osl::FileStatus aStatus( osl_FileStatus_Mask_Type | osl_FileStatus_Mask_LinkTargetURL );
|
|
|
|
|
|
|
|
// FIXME: we really need to switch to a pure URL model ...
|
2012-01-19 15:18:20 +02:00
|
|
|
if ( osl::File::getFileURLFromSystemPath( aFilename, aFileURL ) != osl::FileBase::E_None )
|
2012-01-19 12:23:23 +00:00
|
|
|
aFileURL = aFilename;
|
2012-01-19 15:18:20 +02:00
|
|
|
bool bStatValid = ( osl::DirectoryItem::get( aFileURL, aItem) != osl::FileBase::E_None &&
|
|
|
|
aItem.getFileStatus( aStatus ) != osl::FileBase::E_None );
|
2012-01-19 12:23:23 +00:00
|
|
|
|
|
|
|
// SvFileStream can't open a directory
|
2012-01-19 15:18:20 +02:00
|
|
|
if( bStatValid && aStatus.getFileType() == osl::FileStatus::Directory )
|
2012-01-19 12:23:23 +00:00
|
|
|
{
|
|
|
|
SetError( ::GetSvError( EISDIR ) );
|
|
|
|
return;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( !( nOpenMode & STREAM_WRITE ) )
|
2012-01-17 21:59:22 +02:00
|
|
|
uFlags = osl_File_OpenFlag_Read;
|
2000-09-18 16:07:07 +00:00
|
|
|
else if ( !( nOpenMode & STREAM_READ ) )
|
2012-01-17 21:59:22 +02:00
|
|
|
uFlags = osl_File_OpenFlag_Write;
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2012-01-17 21:59:22 +02:00
|
|
|
uFlags = osl_File_OpenFlag_Read | osl_File_OpenFlag_Write;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// Fix (MDA, 18.01.95): Bei RD_ONLY nicht mit O_CREAT oeffnen
|
|
|
|
// Wichtig auf Read-Only-Dateisystemen (wie CDROM)
|
2012-01-17 21:59:22 +02:00
|
|
|
if ( (!( nOpenMode & STREAM_NOCREATE )) && ( uFlags != osl_File_OpenFlag_Read ) )
|
|
|
|
uFlags |= osl_File_OpenFlag_Create;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nOpenMode & STREAM_TRUNC )
|
2012-01-17 21:59:22 +02:00
|
|
|
uFlags |= osl_File_OpenFlag_Trunc;
|
|
|
|
|
|
|
|
uFlags |= osl_File_OpenFlag_NoExcl | osl_File_OpenFlag_NoLock;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( nOpenMode & STREAM_WRITE)
|
|
|
|
{
|
2012-01-19 12:23:23 +00:00
|
|
|
if ( nOpenMode & STREAM_COPY_ON_SYMLINK )
|
|
|
|
{
|
2012-01-19 15:18:20 +02:00
|
|
|
if ( bStatValid && aStatus.getFileType() == osl::FileStatus::Link &&
|
2012-01-19 12:23:23 +00:00
|
|
|
aStatus.getLinkTargetURL().getLength() > 0 )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-01-19 12:23:23 +00:00
|
|
|
// delete the symbolic link, and replace it with the contents of the link
|
2012-01-19 15:18:20 +02:00
|
|
|
if (osl::File::remove( aFileURL ) == osl::FileBase::E_None )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-01-19 12:23:23 +00:00
|
|
|
File::copy( aStatus.getLinkTargetURL(), aFileURL );
|
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
|
|
|
fprintf( stderr,
|
|
|
|
"Removing link and replacing with file contents (%s) -> (%s).\n",
|
|
|
|
rtl::OUStringToOString( aStatus.getLinkTargetURL(),
|
|
|
|
RTL_TEXTENCODING_UTF8).getStr(),
|
|
|
|
rtl::OUStringToOString( aFileURL,
|
|
|
|
RTL_TEXTENCODING_UTF8).getStr() );
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-19 12:23:23 +00:00
|
|
|
oslFileError rc = osl_openFile( aFileURL.pData, &nHandleTmp, uFlags );
|
2012-01-17 21:59:22 +02:00
|
|
|
if ( rc != osl_File_E_None )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-01-17 21:59:22 +02:00
|
|
|
if ( uFlags & osl_File_OpenFlag_Write )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
// auf Lesen runterschalten
|
2012-01-17 21:59:22 +02:00
|
|
|
uFlags &= ~osl_File_OpenFlag_Write;
|
2012-01-19 12:23:23 +00:00
|
|
|
rc = osl_openFile( aFileURL.pData, &nHandleTmp, uFlags );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2012-01-17 21:59:22 +02:00
|
|
|
if ( rc == osl_File_E_None )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-01-17 21:59:22 +02:00
|
|
|
pInstanceData->rHandle = nHandleTmp;
|
2004-06-17 12:12:48 +00:00
|
|
|
bIsOpen = sal_True;
|
2012-01-17 21:59:22 +02:00
|
|
|
if ( uFlags & osl_File_OpenFlag_Write )
|
2004-06-17 12:12:48 +00:00
|
|
|
bIsWritable = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( !LockFile() ) // ganze Datei
|
|
|
|
{
|
2012-01-17 21:59:22 +02:00
|
|
|
rc = osl_closeFile( nHandleTmp );
|
2004-06-17 12:12:48 +00:00
|
|
|
bIsOpen = sal_False;
|
|
|
|
bIsWritable = sal_False;
|
2012-01-17 21:59:22 +02:00
|
|
|
pInstanceData->rHandle = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2012-01-17 21:59:22 +02:00
|
|
|
SetError( ::GetSvError( rc ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SvFileStream::Close()
|
|
|
|
|*
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
void SvFileStream::Close()
|
|
|
|
{
|
|
|
|
InternalStreamLock::UnlockFile( 0, 0, this );
|
|
|
|
|
2011-08-23 00:38:42 +01:00
|
|
|
if ( IsOpen() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
#ifdef DBG_UTIL
|
2011-08-23 00:38:42 +01:00
|
|
|
rtl::OStringBuffer aTraceStr(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM("SvFileStream::Close(): "));
|
|
|
|
aTraceStr.append(rtl::OUStringToOString(aFilename,
|
|
|
|
osl_getThreadTextEncoding()));
|
|
|
|
OSL_TRACE("%s", aTraceStr.getStr());
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
Flush();
|
2012-01-17 21:59:22 +02:00
|
|
|
osl_closeFile( pInstanceData->rHandle );
|
|
|
|
pInstanceData->rHandle = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2004-06-17 12:12:48 +00:00
|
|
|
bIsOpen = sal_False;
|
|
|
|
bIsWritable = sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
SvStream::ClearBuffer();
|
|
|
|
SvStream::ClearError();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SvFileStream::ResetError()
|
|
|
|
|*
|
|
|
|
|* Beschreibung STREAM.SDW; Setzt Filepointer auf Dateianfang
|
|
|
|
|*
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
void SvFileStream::ResetError()
|
|
|
|
{
|
|
|
|
SvStream::ClearError();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SvFileStream::SetSize()
|
|
|
|
|*
|
|
|
|
|* Beschreibung STREAM.SDW;
|
|
|
|
|*
|
|
|
|
*************************************************************************/
|
|
|
|
|
2004-06-17 12:12:48 +00:00
|
|
|
void SvFileStream::SetSize (sal_Size nSize)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-07-18 12:00:10 +00:00
|
|
|
if (IsOpen())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-01-17 21:59:22 +02:00
|
|
|
oslFileError rc = osl_setFileSize( pInstanceData->rHandle, nSize );
|
|
|
|
if (rc != osl_File_E_None )
|
2001-07-18 12:00:10 +00:00
|
|
|
{
|
2012-01-17 21:59:22 +02:00
|
|
|
SetError ( ::GetSvError( rc ));
|
2001-07-18 12:00:10 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-14 08:27:31 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|