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(
oslFileHandle *pHandle,
sal_uInt32 uFlags );
/* Wrappers for stat() and lstat() with Android-specific hook
for files inside the .apk.
*/
/* Compare directory items for being the same underlying file
* this unwinds unix hard-links and symlinks etc.
*/
SAL_DLLPUBLIC oslFileError SAL_CALL osl_statFilePath(
const char *cpFilePath,
struct stat *statb );
SAL_DLLPUBLIC sal_Bool SAL_CALL osl_identicalDirectoryItem(oslDirectory a, oslDirectory b);
SAL_DLLPUBLIC oslFileError SAL_CALL osl_lstatFilePath(
const char *cpFilePath,
struct stat *statb );
SAL_DLLPUBLIC oslFileError SAL_CALL osl_lstatFilePath( const char *cpFilePath, struct stat *statb );
/* Get the OS specific "handle" of an open file. */
......
......@@ -1389,9 +1389,9 @@ public:
class DirectoryItem: public FileBase
{
oslDirectoryItem _pData;
public:
oslDirectoryItem _pData;
/** Constructor.
*/
......
......@@ -448,15 +448,31 @@ oslFileError SAL_CALL osl_setFileTime (
return osl_psz_setFileTime( path, pCreationTime, pLastAccessTime, pLastWriteTime );
}
oslFileError
SAL_CALL osl_statFilePath( const char *cpFilePath, struct stat *statb )
sal_Bool
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 );
Stat.st_ino == ...
if (rc == -1)
return oslTranslateFileError(OSL_FET_ERROR, errno);
else
return osl_File_E_None;
*/
return sal_False;
}
oslFileError
......
......@@ -648,7 +648,7 @@ PRIVATE_textenc.1 { # LibreOffice 3.6
PRIVATE_file.1 { # LibreOffice 3.6
global:
osl_openFilePath;
osl_statFilePath;
osl_identicalDirectoryItem;
osl_lstatFilePath;
osl_getFileOSHandle;
};
......
......@@ -64,10 +64,10 @@ namespace { struct LockMutex : public rtl::Static< osl::Mutex, LockMutex > {}; }
class InternalStreamLock
{
sal_Size m_nStartPos;
sal_Size m_nEndPos;
SvFileStream* m_pStream;
struct stat m_aStat;
sal_Size m_nStartPos;
sal_Size m_nEndPos;
SvFileStream* m_pStream;
osl::DirectoryItem m_aItem;
InternalStreamLock( sal_Size, sal_Size, SvFileStream* );
~InternalStreamLock();
......@@ -87,11 +87,11 @@ InternalStreamLock::InternalStreamLock(
m_nEndPos( nEnd ),
m_pStream( pStream )
{
rtl::OString aFileName(rtl::OUStringToOString(m_pStream->GetFileName(),
osl_getThreadTextEncoding()));
osl_statFilePath( aFileName.getStr(), &m_aStat );
osl::DirectoryItem::get( m_pStream->GetFileName(), m_aItem );
LockList::get().push_back( this );
#if OSL_DEBUG_LEVEL > 1
rtl::OString aFileName(rtl::OUStringToOString(m_pStream->GetFileName(),
osl_getThreadTextEncoding()));
fprintf( stderr, "locked %s", aFileName.getStr() );
if( m_nStartPos || m_nEndPos )
fprintf(stderr, " [ %ld ... %ld ]", m_nStartPos, m_nEndPos );
......@@ -112,7 +112,7 @@ InternalStreamLock::~InternalStreamLock()
}
#if OSL_DEBUG_LEVEL > 1
rtl::OString aFileName(rtl::OUStringToOString(m_pStream->GetFileName(),
osl_getThreadTextEncoding()));
osl_getThreadTextEncoding()));
fprintf( stderr, "unlocked %s", aFileName.getStr() );
if( 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
#ifndef BOOTSTRAP
osl::MutexGuard aGuard( LockMutex::get() );
#endif
rtl::OString aFileName(rtl::OUStringToOString(pStream->GetFileName(),
osl_getThreadTextEncoding()));
struct stat aStat;
if( osl_statFilePath( aFileName.getStr(), &aStat ) != osl_File_E_None )
return sal_False;
osl::DirectoryItem aItem;
if (osl::DirectoryItem::get( pStream->GetFileName(), aItem) != osl::FileBase::RC::E_None )
{
SAL_INFO("tools", "Failed to lookup stream for locking");
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;
InternalStreamLock* pLock = NULL;
......@@ -139,7 +146,7 @@ sal_Bool InternalStreamLock::LockFile( sal_Size nStart, sal_Size nEnd, SvFileStr
for( size_t i = 0; i < rLockList.size(); ++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;
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