diff options
author | Oliver Bolte <obo@openoffice.org> | 2009-02-16 08:01:53 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2009-02-16 08:01:53 +0000 |
commit | 5dffab1f2d224604c2f79a4d9de19fe0d4c428aa (patch) | |
tree | dc58ae21e6c4e659e33527e0ee6b10d1eef97e9e | |
parent | 274bbfb319a62311a087b7427735fc1d8b35183e (diff) |
CWS-TOOLING: integrate CWS macwebdav
2009-01-28 14:25:50 +0100 jsk r267058 : i98529
2009-01-26 13:24:52 +0100 hro r266918 : #i81536# Check for MacOsX file system locking capabilities
-rw-r--r-- | sal/osl/unx/file.cxx | 25 | ||||
-rw-r--r-- | sal/osl/unx/profile.c | 7 |
2 files changed, 29 insertions, 3 deletions
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index b4d92ccdbc3f..0ff212fe6cd8 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -291,6 +291,11 @@ static int adjustLockFlags(const char * path, int flags) flags &= ~O_EXLOCK; flags |= O_SHLOCK; } + else
+ {
+ /* Needed flags to allow opening a webdav file */
+ flags &= ~( O_EXLOCK | O_SHLOCK );
+ }
} return flags; @@ -697,7 +702,18 @@ oslFileError osl_openFile( rtl_uString* ustrFileURL, oslFileHandle* pHandle, sal aflock.l_type = 0; /* lock the file if flock.l_type is set */ - bLocked = ( F_WRLCK != aflock.l_type || -1 != fcntl( fd, F_SETLK, &aflock ) ); +#ifdef MACOSX
+ bLocked = ( F_WRLCK != aflock.l_type );
+ if (!bLocked)
+ {
+ /* Mac OSX returns ENOTSUP for webdav drives. We should try read lock */
+ if ( 0 == flock( fd, LOCK_EX | LOCK_NB ) || errno == ENOTSUP )
+ bLocked = ( errno != ENOTSUP ) || ( 0 == flock( fd, LOCK_SH | LOCK_NB ) || errno == ENOTSUP );
+ }
+#else /* MACOSX */
+ bLocked = ( F_WRLCK != aflock.l_type || -1 != fcntl( fd, F_SETLK, &aflock ) );
+#endif /* MACOSX */
+ } if ( !bNeedsLock || bLocked ) @@ -764,7 +780,12 @@ oslFileError osl_closeFile( oslFileHandle Handle ) /* FIXME: check if file is really locked ? */ /* release the file share lock on this file */ - if( -1 == fcntl( pHandleImpl->fd, F_SETLK, &aflock ) ) +#ifdef MACOSX
+ /* Mac OSX will return ENOTSUP for webdav drives. We should ignore the error */
+ if ( 0 != flock( pHandleImpl->fd, LOCK_UN | LOCK_NB ) && errno != ENOTSUP )
+#else /* MACOSX */
+ if( -1 == fcntl( pHandleImpl->fd, F_SETLK, &aflock ) )
+#endif /* MACOSX */
{ PERROR( "osl_closeFile", "unlock failed" ); } diff --git a/sal/osl/unx/profile.c b/sal/osl/unx/profile.c index 3845f07a64dd..ccee8fd613bd 100644 --- a/sal/osl/unx/profile.c +++ b/sal/osl/unx/profile.c @@ -1207,7 +1207,12 @@ static sal_Bool OslProfile_lockFile(const osl_TFile* pFile, osl_TLockMode eMode) break; } - if ( fcntl(pFile->m_Handle, F_SETLKW, &lock) == -1 ) +#ifndef MACOSX // not MAC OSX
+ if ( fcntl(pFile->m_Handle, F_SETLKW, &lock) == -1 )
+#else
+ /* Mac OSX will return ENOTSUP for webdav drives so we should ignore it */
+ if ( fcntl(pFile->m_Handle, F_SETLKW, &lock) == -1 && errno != ENOTSUP )
+#endif /* MACOSX */
{ OSL_TRACE("fcntl returned -1 (%s)\n",strerror(errno)); #ifdef TRACE_OSL_PROFILE |