Kaydet (Commit) 0c17acbb authored tarafından Michael Meeks's avatar Michael Meeks

fix SvStream to not disagree with sal on sizeof struct stat

A temporary tweak to restore build-ability; the oslDirectory
change needs a little more thought & public exposure, but rsc
no longer crashes during compile ...
üst 877663b9
...@@ -58,17 +58,13 @@ SAL_DLLPUBLIC oslFileError SAL_CALL osl_openFilePath( ...@@ -58,17 +58,13 @@ SAL_DLLPUBLIC oslFileError SAL_CALL osl_openFilePath(
oslFileHandle *pHandle, oslFileHandle *pHandle,
sal_uInt32 uFlags ); sal_uInt32 uFlags );
/* Wrappers for stat() and lstat() with Android-specific hook /* Compare directory items for being the same underlying file
for files inside the .apk. * this unwinds unix hard-links and symlinks etc.
*/ */
SAL_DLLPUBLIC oslFileError SAL_CALL osl_statFilePath( SAL_DLLPUBLIC sal_Bool SAL_CALL osl_identicalDirectoryItem(oslDirectory a, oslDirectory b);
const char *cpFilePath,
struct stat *statb );
SAL_DLLPUBLIC oslFileError SAL_CALL osl_lstatFilePath( SAL_DLLPUBLIC oslFileError SAL_CALL osl_lstatFilePath( const char *cpFilePath, struct stat *statb );
const char *cpFilePath,
struct stat *statb );
/* Get the OS specific "handle" of an open file. */ /* Get the OS specific "handle" of an open file. */
......
...@@ -1389,9 +1389,9 @@ public: ...@@ -1389,9 +1389,9 @@ public:
class DirectoryItem: public FileBase class DirectoryItem: public FileBase
{ {
oslDirectoryItem _pData;
public: public:
oslDirectoryItem _pData;
/** Constructor. /** Constructor.
*/ */
......
...@@ -448,15 +448,31 @@ oslFileError SAL_CALL osl_setFileTime ( ...@@ -448,15 +448,31 @@ oslFileError SAL_CALL osl_setFileTime (
return osl_psz_setFileTime( path, pCreationTime, pLastAccessTime, pLastWriteTime ); return osl_psz_setFileTime( path, pCreationTime, pLastAccessTime, pLastWriteTime );
} }
oslFileError sal_Bool
SAL_CALL osl_statFilePath( const char *cpFilePath, struct stat *statb ) SAL_CALL osl_identicalDirectoryItem( oslDirectoryItem a, oslDirectoryItem b)
{ {
DirectoryItem_Impl *pA = (DirectoryItem_Impl *) a;
DirectoryItem_Impl *pB = (DirectoryItem_Impl *) b;
if (a == b)
return sal_True;
/* same name => same item, unless renaming / moving madness has occurred */
if (rtl_ustr_compare_WithLength(
pA->m_ustrFilePath->buffer, pA->m_ustrFilePath->length,
pB->m_ustrFilePath->buffer, pB->m_ustrFilePath->length ) == 0)
return sal_True;
fprintf (stderr, "We have to do an inode compare !\n");
/*
int rc = stat_c( cpFilePath, statb ); int rc = stat_c( cpFilePath, statb );
Stat.st_ino == ...
if (rc == -1) if (rc == -1)
return oslTranslateFileError(OSL_FET_ERROR, errno); return oslTranslateFileError(OSL_FET_ERROR, errno);
else else
return osl_File_E_None; return osl_File_E_None;
*/
return sal_False;
} }
oslFileError oslFileError
......
...@@ -648,7 +648,7 @@ PRIVATE_textenc.1 { # LibreOffice 3.6 ...@@ -648,7 +648,7 @@ PRIVATE_textenc.1 { # LibreOffice 3.6
PRIVATE_file.1 { # LibreOffice 3.6 PRIVATE_file.1 { # LibreOffice 3.6
global: global:
osl_openFilePath; osl_openFilePath;
osl_statFilePath; osl_identicalDirectoryItem;
osl_lstatFilePath; osl_lstatFilePath;
osl_getFileOSHandle; osl_getFileOSHandle;
}; };
......
...@@ -64,10 +64,10 @@ namespace { struct LockMutex : public rtl::Static< osl::Mutex, LockMutex > {}; } ...@@ -64,10 +64,10 @@ namespace { struct LockMutex : public rtl::Static< osl::Mutex, LockMutex > {}; }
class InternalStreamLock class InternalStreamLock
{ {
sal_Size m_nStartPos; sal_Size m_nStartPos;
sal_Size m_nEndPos; sal_Size m_nEndPos;
SvFileStream* m_pStream; SvFileStream* m_pStream;
struct stat m_aStat; osl::DirectoryItem m_aItem;
InternalStreamLock( sal_Size, sal_Size, SvFileStream* ); InternalStreamLock( sal_Size, sal_Size, SvFileStream* );
~InternalStreamLock(); ~InternalStreamLock();
...@@ -87,11 +87,11 @@ InternalStreamLock::InternalStreamLock( ...@@ -87,11 +87,11 @@ InternalStreamLock::InternalStreamLock(
m_nEndPos( nEnd ), m_nEndPos( nEnd ),
m_pStream( pStream ) m_pStream( pStream )
{ {
rtl::OString aFileName(rtl::OUStringToOString(m_pStream->GetFileName(), osl::DirectoryItem::get( m_pStream->GetFileName(), m_aItem );
osl_getThreadTextEncoding()));
osl_statFilePath( aFileName.getStr(), &m_aStat );
LockList::get().push_back( this ); LockList::get().push_back( this );
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
rtl::OString aFileName(rtl::OUStringToOString(m_pStream->GetFileName(),
osl_getThreadTextEncoding()));
fprintf( stderr, "locked %s", aFileName.getStr() ); fprintf( stderr, "locked %s", aFileName.getStr() );
if( m_nStartPos || m_nEndPos ) if( m_nStartPos || m_nEndPos )
fprintf(stderr, " [ %ld ... %ld ]", m_nStartPos, m_nEndPos ); fprintf(stderr, " [ %ld ... %ld ]", m_nStartPos, m_nEndPos );
...@@ -112,7 +112,7 @@ InternalStreamLock::~InternalStreamLock() ...@@ -112,7 +112,7 @@ InternalStreamLock::~InternalStreamLock()
} }
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
rtl::OString aFileName(rtl::OUStringToOString(m_pStream->GetFileName(), rtl::OString aFileName(rtl::OUStringToOString(m_pStream->GetFileName(),
osl_getThreadTextEncoding())); osl_getThreadTextEncoding()));
fprintf( stderr, "unlocked %s", aFileName.getStr() ); fprintf( stderr, "unlocked %s", aFileName.getStr() );
if( m_nStartPos || m_nEndPos ) if( m_nStartPos || m_nEndPos )
fprintf(stderr, " [ %ld ... %ld ]", m_nStartPos, m_nEndPos ); fprintf(stderr, " [ %ld ... %ld ]", m_nStartPos, m_nEndPos );
...@@ -125,13 +125,20 @@ sal_Bool InternalStreamLock::LockFile( sal_Size nStart, sal_Size nEnd, SvFileStr ...@@ -125,13 +125,20 @@ sal_Bool InternalStreamLock::LockFile( sal_Size nStart, sal_Size nEnd, SvFileStr
#ifndef BOOTSTRAP #ifndef BOOTSTRAP
osl::MutexGuard aGuard( LockMutex::get() ); osl::MutexGuard aGuard( LockMutex::get() );
#endif #endif
rtl::OString aFileName(rtl::OUStringToOString(pStream->GetFileName(), osl::DirectoryItem aItem;
osl_getThreadTextEncoding())); if (osl::DirectoryItem::get( pStream->GetFileName(), aItem) != osl::FileBase::RC::E_None )
struct stat aStat; {
if( osl_statFilePath( aFileName.getStr(), &aStat ) != osl_File_E_None ) SAL_INFO("tools", "Failed to lookup stream for locking");
return sal_False; return sal_True;
}
if( S_ISDIR( aStat.st_mode ) ) osl::FileStatus aStatus( osl_FileStatus_Mask_Type );
if ( aItem.getFileStatus( aStatus ) != osl::FileBase::RC::E_None )
{
SAL_INFO("tools", "Failed to stat stream for locking");
return sal_True;
}
if( aStatus.getFileType() == osl::FileStatus::Type::Directory )
return sal_True; return sal_True;
InternalStreamLock* pLock = NULL; InternalStreamLock* pLock = NULL;
...@@ -139,7 +146,7 @@ sal_Bool InternalStreamLock::LockFile( sal_Size nStart, sal_Size nEnd, SvFileStr ...@@ -139,7 +146,7 @@ sal_Bool InternalStreamLock::LockFile( sal_Size nStart, sal_Size nEnd, SvFileStr
for( size_t i = 0; i < rLockList.size(); ++i ) for( size_t i = 0; i < rLockList.size(); ++i )
{ {
pLock = rLockList[ i ]; pLock = rLockList[ i ];
if( aStat.st_ino == pLock->m_aStat.st_ino ) if( osl_identicalDirectoryItem( aItem._pData, pLock->m_aItem._pData) )
{ {
sal_Bool bDenyByOptions = sal_False; sal_Bool bDenyByOptions = sal_False;
StreamMode nLockMode = pLock->m_pStream->GetStreamMode(); StreamMode nLockMode = pLock->m_pStream->GetStreamMode();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment