fix error reporting
This commit is contained in:
@@ -21,6 +21,8 @@ public:
|
|||||||
virtual void FlushDirCache( const CString &sPath );
|
virtual void FlushDirCache( const CString &sPath );
|
||||||
virtual bool Remove( const CString &sPath ) { return false; }
|
virtual bool Remove( const CString &sPath ) { return false; }
|
||||||
|
|
||||||
|
/* Possible error returns from Open, in addition to standard errno.h values: */
|
||||||
|
enum { ERROR_WRITING_NOT_SUPPORTED = -1 };
|
||||||
protected:
|
protected:
|
||||||
FilenameDB *FDB;
|
FilenameDB *FDB;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -452,7 +452,7 @@ RageFileObj *RageFileDriverZip::Open( const CString &path, int mode, RageFile &p
|
|||||||
{
|
{
|
||||||
if( mode == RageFile::WRITE )
|
if( mode == RageFile::WRITE )
|
||||||
{
|
{
|
||||||
err = EINVAL;
|
err = ERROR_WRITING_NOT_SUPPORTED;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
RageFileDriverMountpoints(): RageFileDriver( new FilenameDB ) { }
|
RageFileDriverMountpoints(): RageFileDriver( new FilenameDB ) { }
|
||||||
RageFileObj *Open( const CString &path, int mode, RageFile &p, int &err )
|
RageFileObj *Open( const CString &path, int mode, RageFile &p, int &err )
|
||||||
{
|
{
|
||||||
err = (mode == RageFile::WRITE)? EINVAL:ENOENT;
|
err = (mode == RageFile::WRITE)? ERROR_WRITING_NOT_SUPPORTED:ENOENT;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* Never flush FDB, except in LoadFromDrivers. */
|
/* Never flush FDB, except in LoadFromDrivers. */
|
||||||
@@ -592,15 +592,9 @@ RageFileObj *RageFileManager::OpenForWriting( const CString &sPath, int mode, Ra
|
|||||||
Values.push_back( pair<int,int>( i, value ) );
|
Values.push_back( pair<int,int>( i, value ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !Values.size() )
|
|
||||||
{
|
|
||||||
err = EEXIST;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
stable_sort( Values.begin(), Values.end(), SortBySecond );
|
stable_sort( Values.begin(), Values.end(), SortBySecond );
|
||||||
|
|
||||||
int error = 0;
|
err = 0;
|
||||||
for( i = 0; i < Values.size(); ++i )
|
for( i = 0; i < Values.size(); ++i )
|
||||||
{
|
{
|
||||||
const int driver = Values[i].first;
|
const int driver = Values[i].first;
|
||||||
@@ -608,14 +602,23 @@ RageFileObj *RageFileManager::OpenForWriting( const CString &sPath, int mode, Ra
|
|||||||
const CString path = ld.GetPath( sPath );
|
const CString path = ld.GetPath( sPath );
|
||||||
ASSERT( path.size() );
|
ASSERT( path.size() );
|
||||||
|
|
||||||
|
int error;
|
||||||
RageFileObj *ret = ld.driver->Open( path, mode, p, error );
|
RageFileObj *ret = ld.driver->Open( path, mode, p, error );
|
||||||
if( ret )
|
if( ret )
|
||||||
{
|
{
|
||||||
AddReference( ret, ld.driver );
|
AddReference( ret, ld.driver );
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The drivers are in order of priority; if they all return error, return the
|
||||||
|
* first. Never return ERROR_WRITING_NOT_SUPPORTED. */
|
||||||
|
if( !err && error != RageFileDriver::ERROR_WRITING_NOT_SUPPORTED )
|
||||||
|
err = error;
|
||||||
}
|
}
|
||||||
err = error;
|
|
||||||
|
if( !err )
|
||||||
|
err = EEXIST; /* no driver could write */
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user