1 Index: ucb/source/ucp/gvfs/content.cxx
2 ===================================================================
3 RCS file: /cvs/ucb/ucb/source/ucp/gvfs/content.cxx,v
4 retrieving revision 1.12
5 retrieving revision 1.10.64.3
6 diff -u -p -u -p -B -r1.12 -r1.10.64.3
7 --- ucb/source/ucp/gvfs/content.cxx 22 Apr 2008 15:34:22 -0000 1.12
8 +++ ucb/source/ucp/gvfs/content.cxx 17 Jun 2008 12:58:27 -0000 1.10.64.3
11 #include "osl/doublecheckedlocking.h"
13 -#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUES_HPP_
14 #include <com/sun/star/beans/PropertyValue.hpp>
16 #include <com/sun/star/beans/PropertyAttribute.hpp>
17 #include <com/sun/star/beans/PropertySetInfoChange.hpp>
18 #include <com/sun/star/beans/PropertySetInfoChangeEvent.hpp>
19 #include <com/sun/star/io/XActiveDataSink.hpp>
20 #include <com/sun/star/io/XOutputStream.hpp>
21 +#include <com/sun/star/io/XActiveDataStreamer.hpp>
22 #include <com/sun/star/lang/IllegalAccessException.hpp>
23 #include <com/sun/star/ucb/ContentInfoAttribute.hpp>
24 #include <com/sun/star/ucb/InsertCommandArgument.hpp>
25 -#ifndef _COM_SUN_STAR_UCB_INTERACTIVEBADTRANSFRERURLEXCEPTION_HPP_
26 #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
28 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
29 #include <com/sun/star/ucb/InteractiveNetworkConnectException.hpp>
30 -#ifndef _COM_SUN_STAR_UCB_INTERACTIVENETWORKGENBERALEXCEPTION_HPP_
31 #include <com/sun/star/ucb/InteractiveNetworkGeneralException.hpp>
33 #include <com/sun/star/ucb/InteractiveNetworkReadException.hpp>
34 #include <com/sun/star/ucb/InteractiveNetworkResolveNameException.hpp>
35 #include <com/sun/star/ucb/InteractiveNetworkWriteException.hpp>
36 +#include <com/sun/star/ucb/IOErrorCode.hpp>
37 #include <com/sun/star/ucb/NameClash.hpp>
38 #include <com/sun/star/ucb/NameClashException.hpp>
39 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
41 #include <com/sun/star/ucb/NameClashException.hpp>
42 #include <ucbhelper/contentidentifier.hxx>
43 #include <ucbhelper/propertyvalueset.hxx>
44 -#ifndef _UCBHELPER_INTERACTIONREQUEST_HXX
45 #include <ucbhelper/interactionrequest.hxx>
47 #include <ucbhelper/cancelcommandexecution.hxx>
48 #include <ucbhelper/simpleauthenticationrequest.hxx>
50 @@ -133,7 +127,8 @@ Content::Content(
51 throw ( ucb::ContentCreationException )
52 : ContentImplHelper( rxSMgr, pProvider, Identifier ),
53 m_pProvider( pProvider ),
54 - m_bTransient( sal_False )
55 + m_bTransient( sal_False ),
56 + m_bForceReadOnly( sal_False )
60 @@ -149,7 +144,8 @@ Content::Content(
61 throw ( ucb::ContentCreationException )
62 : ContentImplHelper( rxSMgr, pProvider, Identifier ),
63 m_pProvider( pProvider ),
64 - m_bTransient( sal_True )
65 + m_bTransient( sal_True ),
66 + m_bForceReadOnly( sal_False )
70 @@ -579,8 +575,7 @@ uno::Reference< sdbc::XRow > Content::ge
71 GnomeVFSResult result;
72 uno::Sequence< beans::Property > allProperties;
74 - if( ( result = getInfo( xEnv ) ) != GNOME_VFS_OK )
75 - cancelCommandExecution( result, xEnv, sal_False );
76 + result = getInfo( xEnv );
78 const beans::Property* pProps;
80 @@ -596,15 +591,36 @@ uno::Reference< sdbc::XRow > Content::ge
81 rtl::Reference< ::ucbhelper::PropertyValueSet > xRow
82 = new ::ucbhelper::PropertyValueSet( m_xSMgr );
84 - osl::Guard< osl::Mutex > aGuard( m_aMutex );
85 + osl::Guard< osl::Mutex > aGuard( m_aMutex );
86 for( sal_Int32 n = 0; n < nProps; ++n ) {
87 const beans::Property& rProp = pProps[ n ];
89 - if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) {
90 + if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "SupportsActiveStreaming" ) ) ) {
91 + xRow->appendBoolean( rProp, sal_True );
93 + else if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_PROTOCOL_ERROR) {
94 + // 'SupportsActiveStreaming' is the only property that can be
95 + // obtained even if getInfo() failed
96 + // We ignore protocol errors - happens eg. for broken links over sftp:// :-(
97 + cancelCommandExecution( result, xEnv, sal_False );
99 + else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) {
100 if (m_info.name && m_info.name[0] == '/')
101 g_warning ("Odd NFS title on item '%s' == '%s'",
102 getURI(), m_info.name);
103 - xRow->appendString( rProp, GnomeToOUString( m_info.name ) );
105 + if (result != GNOME_VFS_ERROR_PROTOCOL_ERROR)
106 + xRow->appendString( rProp, GnomeToOUString( m_info.name ) );
108 + // m_info is not valid, we have to guess something close enough
109 + rtl::OUString aURI( getOUURI() );
111 + sal_Int32 nLastSlash = aURI.lastIndexOf( '/' );
112 + if (nLastSlash >= 0)
113 + aURI = aURI.copy( nLastSlash + 1 );
115 + xRow->appendString( rProp, aURI );
119 else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) )
120 @@ -633,7 +649,9 @@ uno::Reference< sdbc::XRow > Content::ge
123 else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsReadOnly" ) ) ) {
124 - if (m_info.valid_fields & GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS) {
125 + if ( m_bForceReadOnly )
126 + xRow->appendBoolean( rProp, sal_True );
127 + else if (m_info.valid_fields & GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS) {
128 bool read_only = true;
130 if (m_info.uid == getuid () &&
131 @@ -921,6 +939,8 @@ void Content::insert(
133 osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
135 + GnomeVFSOpenMode nOpenMode;
138 g_warning( "Insert '%s' (%d) (0x%x:%d)", getURI(), bReplaceExisting,
139 m_info.valid_fields, m_info.type );
140 @@ -973,22 +993,27 @@ void Content::insert(
141 result = GNOME_VFS_OK;
142 if ( bReplaceExisting ) {
143 Authentication aAuth( xEnv );
144 - result = gnome_vfs_open( &handle, (const sal_Char *)aURI,
145 - GNOME_VFS_OPEN_WRITE );
146 + nOpenMode = (GnomeVFSOpenMode)(GNOME_VFS_OPEN_WRITE | GNOME_VFS_OPEN_LOCKED);
147 + result = gnome_vfs_open( &handle, (const sal_Char *)aURI, nOpenMode );
150 - if ( result != GNOME_VFS_OK ) {
151 + if ( result == GNOME_VFS_ERROR_LOCKED )
152 + throwLocked( xEnv );
153 + else if ( result != GNOME_VFS_OK ) {
155 Authentication aAuth( xEnv );
157 perm = ( ( GNOME_VFS_PERM_USER_WRITE | GNOME_VFS_PERM_USER_READ ) |
158 ( GNOME_VFS_PERM_GROUP_WRITE | GNOME_VFS_PERM_GROUP_READ ) );
160 + nOpenMode = (GnomeVFSOpenMode)(GNOME_VFS_OPEN_WRITE | GNOME_VFS_OPEN_LOCKED);
161 result = gnome_vfs_create
162 - ( &handle, (const sal_Char *)aURI, GNOME_VFS_OPEN_WRITE, TRUE, perm );
163 + ( &handle, (const sal_Char *)aURI, nOpenMode, TRUE, perm );
166 - if( result != GNOME_VFS_OK )
167 + if ( result == GNOME_VFS_ERROR_LOCKED )
168 + throwLocked( xEnv );
169 + else if ( result != GNOME_VFS_OK )
170 cancelCommandExecution( result, xEnv, sal_True );
172 if ( !xInputStream.is() ) {
173 @@ -998,7 +1023,7 @@ void Content::insert(
175 } else { // copy it over
176 uno::Reference < io::XOutputStream > xOutput =
177 - new gvfs::Stream( handle, &m_info );
178 + new gvfs::Stream( handle, &m_info, (const sal_Char *)aURI, nOpenMode );
180 copyData( xInputStream, xOutput );
182 @@ -1294,6 +1319,22 @@ void Content::cancelCommandExecution(
186 +void Content::throwLocked( const uno::Reference< ucb::XCommandEnvironment > & xEnv)
187 + throw( uno::Exception )
190 + g_warning( "File locked, throwing IOErrorCode_LOCKING_VIOLATION" );
193 + m_bForceReadOnly = sal_True;
195 + ucbhelper::cancelCommandExecution( ucb::IOErrorCode_LOCKING_VIOLATION,
196 + uno::Sequence< uno::Any >( 0 ), // FIXME more info about the file?
198 + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "an error occured during file opening" ) ),
202 uno::Sequence< beans::Property > Content::getProperties(
203 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
205 @@ -1335,6 +1376,10 @@ uno::Sequence< beans::Property > Content
206 beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
207 beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsHidden" ) ),
208 -1, getCppuBooleanType(),
209 + beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
211 + beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SupportsActiveStreaming" ) ),
212 + -1, getCppuBooleanType(),
213 beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY )
216 @@ -1428,6 +1473,7 @@ Content::createTempStream(
217 GnomeVFSResult result;
218 GnomeVFSHandle *handle = NULL;
219 ::rtl::OString aURI = getOURI();
220 + GnomeVFSOpenMode nOpenMode = GNOME_VFS_OPEN_READ;
222 osl::Guard< osl::Mutex > aGuard( m_aMutex );
223 // Something badly wrong happened - can't seek => stream to a temporary file
224 @@ -1439,60 +1485,78 @@ Content::createTempStream(
225 if ( !xTempOut.is() )
226 cancelCommandExecution( GNOME_VFS_ERROR_IO, xEnv );
228 - result = gnome_vfs_open
229 - ( &handle, (const sal_Char *)aURI, GNOME_VFS_OPEN_READ );
230 + result = gnome_vfs_open( &handle, (const sal_Char *)aURI, nOpenMode );
231 if (result != GNOME_VFS_OK)
232 cancelCommandExecution( result, xEnv );
234 - uno::Reference < io::XInputStream > pStream = new ::gvfs::Stream( handle, &m_info );
235 + uno::Reference < io::XInputStream > pStream = new ::gvfs::Stream( handle, &m_info, (const sal_Char *)aURI, nOpenMode );
236 copyData( pStream, xTempOut );
238 return uno::Reference < io::XInputStream > ( xTempOut, uno::UNO_QUERY );
241 -uno::Reference< io::XInputStream >
242 -Content::createInputStream(
243 - const uno::Reference< ucb::XCommandEnvironment >& xEnv )
244 +uno::Reference< io::XStream >
245 +Content::createStream( const uno::Reference< ucb::XCommandEnvironment >& xEnv,
247 throw( uno::Exception )
249 GnomeVFSHandle *handle = NULL;
250 GnomeVFSResult result;
251 - uno::Reference<io::XInputStream > xIn;
252 + uno::Reference< io::XStream > xStream;
254 Authentication aAuth( xEnv );
255 - osl::Guard< osl::Mutex > aGuard( m_aMutex );
256 + osl::Guard< osl::Mutex > aGuard( m_aMutex );
259 ::rtl::OString aURI = getOURI();
261 - if ( !(m_info.valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) )
262 - return createTempStream( xEnv );
263 + if ( !bReadWrite && !(m_info.valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) )
266 - result = gnome_vfs_open
267 - ( &handle, (const sal_Char *)aURI,
268 - (GnomeVFSOpenMode) (GNOME_VFS_OPEN_READ | GNOME_VFS_OPEN_RANDOM ) );
269 + GnomeVFSOpenMode nOpenMode = (GnomeVFSOpenMode)(GNOME_VFS_OPEN_READ | GNOME_VFS_OPEN_RANDOM);
271 + nOpenMode = (GnomeVFSOpenMode)(nOpenMode | GNOME_VFS_OPEN_WRITE | GNOME_VFS_OPEN_LOCKED);
273 + result = gnome_vfs_open( &handle, (const sal_Char *)aURI, nOpenMode );
275 + if (bReadWrite && (result == GNOME_VFS_ERROR_NOT_FOUND))
278 + Authentication aAuth2( xEnv );
280 + perm = ( ( GNOME_VFS_PERM_USER_WRITE | GNOME_VFS_PERM_USER_READ ) |
281 + ( GNOME_VFS_PERM_GROUP_WRITE | GNOME_VFS_PERM_GROUP_READ ) );
283 + result = gnome_vfs_create
284 + ( &handle, (const sal_Char *)aURI, nOpenMode, TRUE, perm );
287 if (result == GNOME_VFS_ERROR_INVALID_OPEN_MODE ||
288 - result == GNOME_VFS_ERROR_NOT_SUPPORTED)
289 - return createTempStream( xEnv );
291 - if (result != GNOME_VFS_OK)
292 + result == GNOME_VFS_ERROR_NOT_SUPPORTED ||
293 + result == GNOME_VFS_ERROR_ACCESS_DENIED)
295 + m_bForceReadOnly = sal_True;
298 + else if (result == GNOME_VFS_ERROR_LOCKED )
299 + throwLocked( xEnv );
300 + else if (result != GNOME_VFS_OK)
301 cancelCommandExecution( result, xEnv );
303 // Try a seek just to make sure it's Random access: some lie.
304 result = gnome_vfs_seek( handle, GNOME_VFS_SEEK_START, 0);
305 if (result == GNOME_VFS_ERROR_NOT_SUPPORTED) {
306 gnome_vfs_close( handle );
307 - return createTempStream( xEnv );
311 if (result != GNOME_VFS_OK)
312 cancelCommandExecution( result, xEnv );
315 - xIn = new ::gvfs::Stream( handle, &m_info );
316 + xStream = new ::gvfs::Stream( handle, &m_info, (const sal_Char *)aURI, nOpenMode );
323 @@ -1502,25 +1566,53 @@ Content::feedSink( uno::Reference< uno::
327 - uno::Reference< io::XOutputStream > xOut
328 - = uno::Reference< io::XOutputStream >(aSink, uno::UNO_QUERY );
329 - uno::Reference< io::XActiveDataSink > xDataSink
330 - = uno::Reference< io::XActiveDataSink >(aSink, uno::UNO_QUERY );
332 - if ( !xOut.is() && !xDataSink.is() )
335 - uno::Reference< io::XInputStream > xIn = createInputStream( xEnv );
339 + uno::Reference< io::XOutputStream > xOut( aSink, uno::UNO_QUERY );
343 + g_warning( "feedSink(), using XOutputStream" );
345 + uno::Reference< io::XInputStream > xIn( createStream( xEnv, false ), uno::UNO_QUERY );
347 + xIn = createTempStream( xEnv );
351 copyData( xIn, xOut );
355 + uno::Reference< io::XActiveDataSink > xDataSink( aSink, uno::UNO_QUERY );
356 if ( xDataSink.is() )
359 + g_warning( "feedSink(), using XActiveDataSink" );
361 + uno::Reference< io::XInputStream > xIn( createStream( xEnv, false ), uno::UNO_QUERY );
363 + xIn = createTempStream( xEnv );
367 xDataSink->setInputStream( xIn );
372 + uno::Reference< io::XActiveDataStreamer > xDataStreamer( aSink, uno::UNO_QUERY );
373 + if ( xDataStreamer.is() )
376 + g_warning( "feedSink(), using XActiveDataStreamer" );
378 + uno::Reference< io::XStream > xStream = createStream( xEnv, true );
379 + if ( !xStream.is() )
382 + xDataStreamer->setStream( xStream );
390 Index: ucb/source/ucp/gvfs/content.hxx
391 ===================================================================
392 RCS file: /cvs/ucb/ucb/source/ucp/gvfs/content.hxx,v
393 retrieving revision 1.6
394 retrieving revision 1.5.70.2
395 diff -u -p -u -p -B -r1.6 -r1.5.70.2
396 --- ucb/source/ucp/gvfs/content.hxx 10 Apr 2008 15:05:55 -0000 1.6
397 +++ ucb/source/ucp/gvfs/content.hxx 2 Jun 2008 13:28:35 -0000 1.5.70.2
398 @@ -49,6 +49,7 @@ namespace com { namespace sun { namespac
399 namespace com { namespace sun { namespace star { namespace io {
405 namespace com { namespace sun { namespace star { namespace sdbc {
406 @@ -92,6 +93,7 @@ private:
407 ContentProvider *m_pProvider; // No need for a ref, base class holds object
408 sal_Bool m_bTransient; // A non-existant (as yet) item
409 GnomeVFSFileInfo m_info; // cached status information
410 + sal_Bool m_bForceReadOnly; // behave as read-only
413 void queryChildren ( ContentRefList& rChildren );
414 @@ -166,9 +168,10 @@ private:
415 com::sun::star::ucb::XCommandEnvironment >& xEnv )
416 throw( ::com::sun::star::uno::Exception );
417 ::com::sun::star::uno::Reference<
418 - ::com::sun::star::io::XInputStream >
419 - createInputStream( const ::com::sun::star::uno::Reference<
420 - com::sun::star::ucb::XCommandEnvironment >& xEnv )
421 + ::com::sun::star::io::XStream >
422 + createStream( const ::com::sun::star::uno::Reference<
423 + com::sun::star::ucb::XCommandEnvironment >& xEnv,
425 throw( ::com::sun::star::uno::Exception );
426 sal_Bool feedSink( ::com::sun::star::uno::Reference<
427 ::com::sun::star::uno::XInterface> aSink,
428 @@ -184,6 +187,9 @@ private:
429 sal_Bool bWrite = sal_False )
430 throw( ::com::sun::star::uno::Exception );
432 + void throwLocked(const ::com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv)
433 + throw( ::com::sun::star::uno::Exception );
437 // Non-interface bits
438 Index: ucb/source/ucp/gvfs/directory.cxx
439 ===================================================================
440 RCS file: /cvs/ucb/ucb/source/ucp/gvfs/directory.cxx,v
441 retrieving revision 1.7
442 retrieving revision 1.6.70.2
443 diff -u -p -u -p -B -r1.7 -r1.6.70.2
444 --- ucb/source/ucp/gvfs/directory.cxx 10 Apr 2008 15:06:14 -0000 1.7
445 +++ ucb/source/ucp/gvfs/directory.cxx 2 Jun 2008 13:28:38 -0000 1.6.70.2
446 @@ -361,24 +361,25 @@ sal_Bool DataSupplier::getData()
450 - GnomeVFSFileInfo fileInfo;
452 - while ((result = gnome_vfs_directory_read_next (dirHandle, &fileInfo)) == GNOME_VFS_OK) {
453 - if( fileInfo.name && fileInfo.name[0] == '.' &&
454 - ( fileInfo.name[1] == '\0' ||
455 - ( fileInfo.name[1] == '.' && fileInfo.name[2] == '\0' ) ) )
456 + GnomeVFSFileInfo *pFileInfo = gnome_vfs_file_info_new();
457 + while ((result = gnome_vfs_directory_read_next (dirHandle, pFileInfo)) == GNOME_VFS_OK) {
458 + if( !pFileInfo->name ||
459 + pFileInfo->name[0] == '\0' ||
460 + ( pFileInfo->name[0] == '.' &&
461 + ( pFileInfo->name[1] == '\0' ||
462 + ( pFileInfo->name[1] == '.' && pFileInfo->name[2] == '\0' ) ) ) )
465 switch ( m_pImpl->m_nOpenMode ) {
466 case ucb::OpenMode::FOLDERS:
467 - if ( !(fileInfo.valid_fields & GNOME_VFS_FILE_INFO_FIELDS_TYPE) ||
468 - fileInfo.type != GNOME_VFS_FILE_TYPE_DIRECTORY )
469 + if ( !(pFileInfo->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_TYPE) ||
470 + pFileInfo->type != GNOME_VFS_FILE_TYPE_DIRECTORY )
474 case ucb::OpenMode::DOCUMENTS:
475 - if ( !(fileInfo.valid_fields & GNOME_VFS_FILE_INFO_FIELDS_TYPE) ||
476 - fileInfo.type != GNOME_VFS_FILE_TYPE_REGULAR )
477 + if ( !(pFileInfo->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_TYPE) ||
478 + pFileInfo->type != GNOME_VFS_FILE_TYPE_REGULAR )
482 @@ -387,8 +388,9 @@ sal_Bool DataSupplier::getData()
486 - m_pImpl->m_aResults.push_back( new ResultListEntry( &fileInfo ) );
487 + m_pImpl->m_aResults.push_back( new ResultListEntry( pFileInfo ) );
489 + g_free( pFileInfo );
491 g_warning ("Got %d directory entries", result);
493 Index: ucb/source/ucp/gvfs/makefile.mk
494 ===================================================================
495 RCS file: /cvs/ucb/ucb/source/ucp/gvfs/makefile.mk,v
496 retrieving revision 1.8
497 retrieving revision 1.7.64.3
498 diff -u -p -u -p -B -r1.8 -r1.7.64.3
499 --- ucb/source/ucp/gvfs/makefile.mk 10 Apr 2008 15:06:47 -0000 1.8
500 +++ ucb/source/ucp/gvfs/makefile.mk 2 Jun 2008 13:28:41 -0000 1.7.64.3
501 @@ -57,6 +57,14 @@ CFLAGS+=-gdwarf-2
502 PKGCONFIG_LIBS!:=-Wl,--export-dynamic $(PKGCONFIG_LIBS:s/ -llinc//:s/ -lbonobo-activation//:s/ -lgconf-2//:s/ -lORBit-2//:s/ -lIDL-2//:s/ -lgmodule-2.0//:s/ -lgobject-2.0//:s/ -lgthread-2.0//)
503 .ENDIF # "$(OS)" == "LINUX"
505 +.IF "$(debug)" != "" || "$(DEBUG)" != ""
509 +.IF "$(GNOMEVFS_HAS_LOCKING)" != "YES"
510 +CFLAGS+=-DGNOME_VFS_OPEN_LOCKED=16
516 Index: ucb/source/ucp/gvfs/stream.cxx
517 ===================================================================
518 RCS file: /cvs/ucb/ucb/source/ucp/gvfs/stream.cxx,v
519 retrieving revision 1.7
520 retrieving revision 1.6.70.3
521 diff -u -p -u -p -B -r1.7 -r1.6.70.3
522 --- ucb/source/ucp/gvfs/stream.cxx 10 Apr 2008 15:07:37 -0000 1.7
523 +++ ucb/source/ucp/gvfs/stream.cxx 17 Jun 2008 12:58:27 -0000 1.6.70.3
524 @@ -44,10 +44,14 @@ using namespace com::sun::star::ucb;
525 using namespace gvfs;
527 Stream::Stream( GnomeVFSHandle *handle,
528 - const GnomeVFSFileInfo *aInfo ) :
529 + const GnomeVFSFileInfo *aInfo,
531 + GnomeVFSOpenMode open_mode ) :
533 m_bInputStreamCalled( sal_False ),
534 - m_bOutputStreamCalled( sal_False )
535 + m_bOutputStreamCalled( sal_False ),
536 + m_pURI( g_strdup( uri ) ),
537 + m_nOpenMode( open_mode )
540 gnome_vfs_file_info_copy (&m_info, aInfo);
541 @@ -59,6 +63,7 @@ Stream::~Stream( void )
542 gnome_vfs_close (m_handle);
548 Any Stream::queryInterface( const Type &type )
549 @@ -113,7 +118,6 @@ sal_Int32 SAL_CALL Stream::readBytes(
552 GnomeVFSResult result;
553 - GnomeVFSFileSize nBytesRead = 0;
557 @@ -129,10 +133,15 @@ sal_Int32 SAL_CALL Stream::readBytes(
558 throw BufferSizeExceededException();
561 + sal_Int32 nTotalBytesRead = 0;
563 - result = gnome_vfs_read( m_handle, aData.getArray(),
564 - nBytesToRead, &nBytesRead );
565 - } while( result == GNOME_VFS_ERROR_INTERRUPTED );
566 + GnomeVFSFileSize nBytesRead = 0;
568 + result = gnome_vfs_read( m_handle, aData.getArray() + nTotalBytesRead,
569 + nBytesToRead - nTotalBytesRead, &nBytesRead );
570 + } while( result == GNOME_VFS_ERROR_INTERRUPTED );
571 + nTotalBytesRead += nBytesRead;
572 + } while( result == GNOME_VFS_OK && nTotalBytesRead < nBytesToRead );
574 if (result != GNOME_VFS_OK &&
575 result != GNOME_VFS_ERROR_EOF)
576 @@ -141,9 +150,9 @@ sal_Int32 SAL_CALL Stream::readBytes(
577 if (result == GNOME_VFS_ERROR_EOF)
580 - aData.realloc( sal::static_int_cast<sal_uInt32>(nBytesRead) );
581 + aData.realloc( sal::static_int_cast<sal_uInt32>(nTotalBytesRead) );
583 - return sal::static_int_cast<sal_Int32>(nBytesRead);
584 + return sal::static_int_cast<sal_Int32>(nTotalBytesRead);
587 sal_Int32 SAL_CALL Stream::readSomeBytes(
588 @@ -261,7 +270,17 @@ void SAL_CALL Stream::truncate( void )
592 - throwOnError( gnome_vfs_truncate_handle( m_handle, 0 ) );
593 + GnomeVFSResult result = gnome_vfs_truncate_handle( m_handle, 0 );
595 + if ( result == GNOME_VFS_ERROR_NOT_SUPPORTED )
597 + result = gnome_vfs_close( m_handle );
599 + if ( result == GNOME_VFS_OK )
600 + result = gnome_vfs_open( &m_handle, m_pURI, (GnomeVFSOpenMode)( m_nOpenMode | GNOME_VFS_OPEN_LOCKED ) );
603 + throwOnError( result );
606 // -------------------------------------------------------------------
607 Index: ucb/source/ucp/gvfs/stream.hxx
608 ===================================================================
609 RCS file: /cvs/ucb/ucb/source/ucp/gvfs/stream.hxx,v
610 retrieving revision 1.5
611 retrieving revision 1.4.136.2
612 diff -u -p -u -p -B -r1.5 -r1.4.136.2
613 --- ucb/source/ucp/gvfs/stream.hxx 10 Apr 2008 15:07:53 -0000 1.5
614 +++ ucb/source/ucp/gvfs/stream.hxx 2 Jun 2008 13:28:50 -0000 1.4.136.2
615 @@ -58,6 +58,8 @@ private:
617 sal_Bool m_bInputStreamCalled;
618 sal_Bool m_bOutputStreamCalled;
619 + gchar *m_pURI; // necessary to be able to simulate gnome_vfs_truncate if not supported
620 + GnomeVFSOpenMode m_nOpenMode;// necessary to be able to simulate gnome_vfs_truncate if not supported
622 void throwOnError( GnomeVFSResult result )
623 throw( ::com::sun::star::io::NotConnectedException,
624 @@ -72,7 +74,9 @@ private:
627 Stream ( GnomeVFSHandle *handle,
628 - const GnomeVFSFileInfo *aInfo );
629 + const GnomeVFSFileInfo *aInfo,
631 + GnomeVFSOpenMode open_mode );