Modifiche alla formattazione
git-svn-id: svn://10.65.10.50/trunk@312 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
a0cf576daf
commit
85f5697a82
@ -105,7 +105,7 @@
|
||||
#if defined( AL_BUILDING_DLL )
|
||||
void AL_DLL_FAR * AL_PROTO ALFile::operator new( size_t size )
|
||||
{
|
||||
return ::new char[ size ];
|
||||
return ::new char[ size ];
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -149,11 +149,11 @@ void AL_DLL_FAR * AL_PROTO ALFile::operator new( size_t size )
|
||||
//
|
||||
|
||||
AL_PROTO ALFile::ALFile( const char AL_DLL_FAR *file_name /* = "" */,
|
||||
int buffer_size /* = 4096 */,
|
||||
ALCase name_case /* = AL_LOWER */)
|
||||
// Note: if non-msdos, change case parameter to AL_MIXED
|
||||
: ALStorage( file_name, buffer_size, AL_FILE_OBJECT, name_case ) {
|
||||
miHandle = -1;
|
||||
int buffer_size /* = 4096 */,
|
||||
ALCase name_case /* = AL_LOWER */)
|
||||
// Note: if non-msdos, change case parameter to AL_MIXED
|
||||
: ALStorage( file_name, buffer_size, AL_FILE_OBJECT, name_case ) {
|
||||
miHandle = -1;
|
||||
}
|
||||
|
||||
//
|
||||
@ -186,9 +186,9 @@ AL_PROTO ALFile::ALFile( const char AL_DLL_FAR *file_name /* = "" */,
|
||||
|
||||
AL_PROTO ALFile::~ALFile()
|
||||
{
|
||||
AL_ASSERT( GoodTag(), "~ALFile: attempting to delete invalid object" );
|
||||
if ( miHandle != -1 )
|
||||
Close();
|
||||
AL_ASSERT( GoodTag(), "~ALFile: attempting to delete invalid object" );
|
||||
if ( miHandle != -1 )
|
||||
Close();
|
||||
}
|
||||
|
||||
//
|
||||
@ -233,31 +233,31 @@ AL_PROTO ALFile::~ALFile()
|
||||
|
||||
int AL_PROTO ALFile::LoadBuffer( long address )
|
||||
{
|
||||
if ( mStatus < AL_SUCCESS )
|
||||
return mStatus;
|
||||
if ( mlFilePointer != address ) {
|
||||
long result = lseek( miHandle, address, SEEK_SET );
|
||||
if ( result == -1L )
|
||||
return mStatus.SetError( AL_SEEK_ERROR,
|
||||
"Seek failure on %s. errno = %d",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
}
|
||||
int result = read( miHandle, mpcBuffer, muBufferSize );
|
||||
if ( result == 0 )
|
||||
return AL_END_OF_FILE;
|
||||
if ( result < 0 )
|
||||
return mStatus.SetError( AL_READ_ERROR,
|
||||
"Read failure on %s. errno = %d",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
if ( miUpdateCrcFlag )
|
||||
UpdateCrc( result );
|
||||
muReadIndex = 0; //Reading can resume at this location in the I/O buffer
|
||||
mlFilePointer += result;
|
||||
muBufferValidData = result;
|
||||
YieldTime();
|
||||
return result;
|
||||
if ( mStatus < AL_SUCCESS )
|
||||
return mStatus;
|
||||
if ( mlFilePointer != address ) {
|
||||
long result = lseek( miHandle, address, SEEK_SET );
|
||||
if ( result == -1L )
|
||||
return mStatus.SetError( AL_SEEK_ERROR,
|
||||
"Seek failure on %s. errno = %d",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
}
|
||||
int result = read( miHandle, mpcBuffer, muBufferSize );
|
||||
if ( result == 0 )
|
||||
return AL_END_OF_FILE;
|
||||
if ( result < 0 )
|
||||
return mStatus.SetError( AL_READ_ERROR,
|
||||
"Read failure on %s. errno = %d",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
if ( miUpdateCrcFlag )
|
||||
UpdateCrc( result );
|
||||
muReadIndex = 0; //Reading can resume at this location in the I/O buffer
|
||||
mlFilePointer += result;
|
||||
muBufferValidData = result;
|
||||
YieldTime();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
@ -296,24 +296,24 @@ int AL_PROTO ALFile::LoadBuffer( long address )
|
||||
|
||||
int AL_PROTO ALFile::FlushBuffer()
|
||||
{
|
||||
if ( mStatus < 0 )
|
||||
return mStatus;
|
||||
if ( muWriteIndex != 0 ) {
|
||||
if ( miUpdateCrcFlag )
|
||||
UpdateCrc( muWriteIndex );
|
||||
int result = write( miHandle, mpcBuffer, muWriteIndex );
|
||||
muWriteIndex = 0;
|
||||
if ( result == -1L )
|
||||
return mStatus.SetError( AL_WRITE_ERROR,
|
||||
"Write failure on %s. errno = %d",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
mlFilePointer += result;
|
||||
}
|
||||
muReadIndex = 0;
|
||||
muBufferValidData = 0;
|
||||
YieldTime();
|
||||
return AL_SUCCESS;
|
||||
if ( mStatus < 0 )
|
||||
return mStatus;
|
||||
if ( muWriteIndex != 0 ) {
|
||||
if ( miUpdateCrcFlag )
|
||||
UpdateCrc( muWriteIndex );
|
||||
int result = write( miHandle, mpcBuffer, muWriteIndex );
|
||||
muWriteIndex = 0;
|
||||
if ( result == -1L )
|
||||
return mStatus.SetError( AL_WRITE_ERROR,
|
||||
"Write failure on %s. errno = %d",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
mlFilePointer += result;
|
||||
}
|
||||
muReadIndex = 0;
|
||||
muBufferValidData = 0;
|
||||
YieldTime();
|
||||
return AL_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
@ -347,19 +347,19 @@ int AL_PROTO ALFile::FlushBuffer()
|
||||
|
||||
int AL_PROTO ALFile::Seek( long address )
|
||||
{
|
||||
FlushBuffer();
|
||||
if ( mStatus < 0 )
|
||||
return mStatus;
|
||||
if ( mlFilePointer != address ) {
|
||||
long result = lseek( miHandle, address, SEEK_SET );
|
||||
if ( result == -1L )
|
||||
return mStatus.SetError( AL_SEEK_ERROR,
|
||||
"Seek failure on %s. errno = %d",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
}
|
||||
mlFilePointer = address;
|
||||
return AL_SUCCESS;
|
||||
FlushBuffer();
|
||||
if ( mStatus < 0 )
|
||||
return mStatus;
|
||||
if ( mlFilePointer != address ) {
|
||||
long result = lseek( miHandle, address, SEEK_SET );
|
||||
if ( result == -1L )
|
||||
return mStatus.SetError( AL_SEEK_ERROR,
|
||||
"Seek failure on %s. errno = %d",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
}
|
||||
mlFilePointer = address;
|
||||
return AL_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
@ -398,56 +398,56 @@ int AL_PROTO ALFile::Seek( long address )
|
||||
|
||||
int AL_PROTO ALFile::Open()
|
||||
{
|
||||
if ( mStatus < AL_SUCCESS )
|
||||
return mStatus;
|
||||
miHandle = open( mName, O_BINARY | O_RDWR );
|
||||
if ( miHandle == -1 && errno == EACCES )
|
||||
miHandle = open( mName, O_BINARY | O_RDONLY );
|
||||
if ( miHandle == -1 )
|
||||
return mStatus.SetError( AL_CANT_OPEN_FILE,
|
||||
"File open failure. Open of %s returned "
|
||||
"errno = %d",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
if ( mStatus < AL_SUCCESS )
|
||||
return mStatus;
|
||||
miHandle = open( mName, O_BINARY | O_RDWR );
|
||||
if ( miHandle == -1 && errno == EACCES )
|
||||
miHandle = open( mName, O_BINARY | O_RDONLY );
|
||||
if ( miHandle == -1 )
|
||||
return mStatus.SetError( AL_CANT_OPEN_FILE,
|
||||
"File open failure. Open of %s returned "
|
||||
"errno = %d",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
|
||||
ALStorage::Open();
|
||||
struct stat buf;
|
||||
struct tm *tblock;
|
||||
if ( stat( mName, &buf ) == -1 )
|
||||
return mStatus.SetError( AL_CANT_OPEN_FILE,
|
||||
"Couldn't get time, date, and size "
|
||||
"information for %s. errno = %d.",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
mlSize = buf.st_size;
|
||||
tblock = localtime( &buf.st_mtime );
|
||||
mTimeDate.SetTimeDate( tblock );
|
||||
ALStorage::Open();
|
||||
struct stat buf;
|
||||
struct tm *tblock;
|
||||
if ( stat( mName, &buf ) == -1 )
|
||||
return mStatus.SetError( AL_CANT_OPEN_FILE,
|
||||
"Couldn't get time, date, and size "
|
||||
"information for %s. errno = %d.",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
mlSize = buf.st_size;
|
||||
tblock = localtime( &buf.st_mtime );
|
||||
mTimeDate.SetTimeDate( tblock );
|
||||
#if XVT_OS == XVT_OS_SCOUNIX
|
||||
// TBI code for UNIX attributes
|
||||
// stat s;
|
||||
// mAttributes = SetFromUnixMode(stat.st_mode)
|
||||
// TBI code for UNIX attributes
|
||||
// stat s;
|
||||
// mAttributes = SetFromUnixMode(stat.st_mode)
|
||||
#else
|
||||
#if defined( AL_WIN32S )
|
||||
DWORD attributes = GetFileAttributes( mName );
|
||||
if ( attributes == 0xFFFFFFFF )
|
||||
return mStatus.SetError( AL_CANT_OPEN_FILE,
|
||||
"Couldn't get Win32 file attribute "
|
||||
"information for %s. GetLastError = %d.",
|
||||
mName.GetName(),
|
||||
GetLastError() );
|
||||
mAttributes.SetFromWin32Attributes( attributes );
|
||||
DWORD attributes = GetFileAttributes( mName );
|
||||
if ( attributes == 0xFFFFFFFF )
|
||||
return mStatus.SetError( AL_CANT_OPEN_FILE,
|
||||
"Couldn't get Win32 file attribute "
|
||||
"information for %s. GetLastError = %d.",
|
||||
mName.GetName(),
|
||||
GetLastError() );
|
||||
mAttributes.SetFromWin32Attributes( attributes );
|
||||
#else
|
||||
unsigned attributes;
|
||||
if ( _dos_getfileattr( mName, &attributes ) != 0 )
|
||||
return mStatus.SetError( AL_CANT_OPEN_FILE,
|
||||
"Couldn't get DOS attribute "
|
||||
"information for %s. errno = %d.",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
mAttributes.SetFromDosAttributes( attributes );
|
||||
unsigned attributes;
|
||||
if ( _dos_getfileattr( mName, &attributes ) != 0 )
|
||||
return mStatus.SetError( AL_CANT_OPEN_FILE,
|
||||
"Couldn't get DOS attribute "
|
||||
"information for %s. errno = %d.",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
mAttributes.SetFromDosAttributes( attributes );
|
||||
#endif
|
||||
#endif
|
||||
return AL_SUCCESS;
|
||||
return AL_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
@ -482,10 +482,10 @@ int AL_PROTO ALFile::Open()
|
||||
|
||||
void AL_PROTO ALFile::MakeTempName( int i )
|
||||
{
|
||||
char name[ 21 ];
|
||||
char name[ 21 ];
|
||||
|
||||
sprintf( name, "~al~%03d.tmp", i );
|
||||
mName = name;
|
||||
sprintf( name, "~al~%03d.tmp", i );
|
||||
mName = name;
|
||||
}
|
||||
|
||||
//
|
||||
@ -526,48 +526,48 @@ void AL_PROTO ALFile::MakeTempName( int i )
|
||||
|
||||
int AL_PROTO ALFile::Create()
|
||||
{
|
||||
ALStorage::Create();
|
||||
if ( mStatus < AL_SUCCESS )
|
||||
return mStatus;
|
||||
if ( (char *) mName == 0 || strlen( mName ) == 0 ) {
|
||||
for ( int i = 0 ; i < 999 ; i++ ) {
|
||||
MakeTempName( i );
|
||||
miHandle = open( mName,
|
||||
O_CREAT | O_RDWR | O_BINARY | O_EXCL,
|
||||
S_IREAD | S_IWRITE );
|
||||
if ( miHandle != -1 )
|
||||
break;
|
||||
else if ( errno != EEXIST && errno != EACCES ) {
|
||||
mStatus.SetError( AL_CANT_OPEN_FILE,
|
||||
"Temporary file creation failure. "
|
||||
"Open of %s returned errno = %d",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
mName = "";
|
||||
return AL_CANT_OPEN_FILE;
|
||||
}
|
||||
}
|
||||
if ( i == 1000 ) {
|
||||
mStatus.SetError( AL_CANT_OPEN_FILE,
|
||||
"Temporary file creation failure. "
|
||||
"Tried 1000 times to open %s "
|
||||
"(or a name something like that).",
|
||||
mName.GetName() );
|
||||
mName = "";
|
||||
return AL_CANT_OPEN_FILE;
|
||||
}
|
||||
} else {
|
||||
miHandle = open( mName,
|
||||
O_CREAT | O_RDWR | O_BINARY | O_TRUNC,
|
||||
S_IREAD | S_IWRITE );
|
||||
ALStorage::Create();
|
||||
if ( mStatus < AL_SUCCESS )
|
||||
return mStatus;
|
||||
if ( (char *) mName == 0 || strlen( mName ) == 0 ) {
|
||||
for ( int i = 0 ; i < 999 ; i++ ) {
|
||||
MakeTempName( i );
|
||||
miHandle = open( mName,
|
||||
O_CREAT | O_RDWR | O_BINARY | O_EXCL,
|
||||
S_IREAD | S_IWRITE );
|
||||
if ( miHandle != -1 )
|
||||
break;
|
||||
else if ( errno != EEXIST && errno != EACCES ) {
|
||||
mStatus.SetError( AL_CANT_OPEN_FILE,
|
||||
"Temporary file creation failure. "
|
||||
"Open of %s returned errno = %d",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
mName = "";
|
||||
return AL_CANT_OPEN_FILE;
|
||||
}
|
||||
}
|
||||
if ( miHandle == -1 )
|
||||
return mStatus.SetError( AL_CANT_OPEN_FILE,
|
||||
"File creation failure. "
|
||||
"Open of %s returned errno = %d",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
return AL_SUCCESS;
|
||||
if ( i == 1000 ) {
|
||||
mStatus.SetError( AL_CANT_OPEN_FILE,
|
||||
"Temporary file creation failure. "
|
||||
"Tried 1000 times to open %s "
|
||||
"(or a name something like that).",
|
||||
mName.GetName() );
|
||||
mName = "";
|
||||
return AL_CANT_OPEN_FILE;
|
||||
}
|
||||
} else {
|
||||
miHandle = open( mName,
|
||||
O_CREAT | O_RDWR | O_BINARY | O_TRUNC,
|
||||
S_IREAD | S_IWRITE );
|
||||
}
|
||||
if ( miHandle == -1 )
|
||||
return mStatus.SetError( AL_CANT_OPEN_FILE,
|
||||
"File creation failure. "
|
||||
"Open of %s returned errno = %d",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
return AL_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
@ -597,32 +597,32 @@ int AL_PROTO ALFile::Create()
|
||||
|
||||
int AL_PROTO ALFile::Close()
|
||||
{
|
||||
if ( miHandle == -1 )
|
||||
return mStatus;
|
||||
FlushBuffer();
|
||||
mlSize = filelength( miHandle );
|
||||
if ( miCreated && mTimeDate.Valid() ) {
|
||||
if ( miHandle == -1 )
|
||||
return mStatus;
|
||||
FlushBuffer();
|
||||
mlSize = filelength( miHandle );
|
||||
if ( miCreated && mTimeDate.Valid() ) {
|
||||
#if defined( AL_WIN32S )
|
||||
// Can you do this under NT? I don't know how.
|
||||
// Can you do this under NT? I don't know how.
|
||||
#else
|
||||
_dos_setftime( miHandle, mTimeDate.GetDosDate(), mTimeDate.GetDosTime() );
|
||||
_dos_setftime( miHandle, mTimeDate.GetDosDate(), mTimeDate.GetDosTime() );
|
||||
#endif
|
||||
}
|
||||
close( miHandle );
|
||||
miHandle = -1;
|
||||
ALStorage::Close();
|
||||
if ( miCreated && mTimeDate.Valid() ) {
|
||||
}
|
||||
close( miHandle );
|
||||
miHandle = -1;
|
||||
ALStorage::Close();
|
||||
if ( miCreated && mTimeDate.Valid() ) {
|
||||
#if XVT_OS == XVT_OS_SCOUNIX
|
||||
// TBI code for setting UNIX attributes
|
||||
#else
|
||||
#if defined( AL_WIN32S )
|
||||
SetFileAttributes( mName, mAttributes.GetWin32Attributes() );
|
||||
SetFileAttributes( mName, mAttributes.GetWin32Attributes() );
|
||||
#else
|
||||
_dos_setfileattr( mName, mAttributes.GetDosAttributes() );
|
||||
_dos_setfileattr( mName, mAttributes.GetDosAttributes() );
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
return mStatus;
|
||||
}
|
||||
return mStatus;
|
||||
}
|
||||
|
||||
//
|
||||
@ -656,8 +656,8 @@ int AL_PROTO ALFile::Close()
|
||||
|
||||
int AL_PROTO ALFile::RenameToBackup( int delete_on_clash /* = 1 */ )
|
||||
{
|
||||
mName.ChangeExtension();
|
||||
return Rename( 0, delete_on_clash );
|
||||
mName.ChangeExtension();
|
||||
return Rename( 0, delete_on_clash );
|
||||
}
|
||||
|
||||
//
|
||||
@ -700,61 +700,61 @@ int AL_PROTO ALFile::RenameToBackup( int delete_on_clash /* = 1 */ )
|
||||
//
|
||||
|
||||
int AL_PROTO ALFile::Rename( const char AL_DLL_FAR *new_name /* = 0 */,
|
||||
int delete_on_clash /* = 1 */ )
|
||||
int delete_on_clash /* = 1 */ )
|
||||
{
|
||||
AL_ASSERT( miHandle == -1, "Rename: attempting to rename open file" );
|
||||
AL_ASSERT( mName.GetName() != 0, "Rename: attempting to rename file with null name" );
|
||||
AL_ASSERT( strlen( mName ) > 0, "Rename: attempting to rename file with 0 length name" );
|
||||
AL_ASSERT( miHandle == -1, "Rename: attempting to rename open file" );
|
||||
AL_ASSERT( mName.GetName() != 0, "Rename: attempting to rename file with null name" );
|
||||
AL_ASSERT( strlen( mName ) > 0, "Rename: attempting to rename file with 0 length name" );
|
||||
|
||||
int status;
|
||||
const char *real_old_name;
|
||||
const char *real_new_name;
|
||||
if ( new_name ) {
|
||||
real_old_name = mName.GetSafeName();
|
||||
real_new_name = new_name;
|
||||
} else {
|
||||
real_old_name = mName.GetSafeOldName();
|
||||
real_new_name = mName.GetSafeName();
|
||||
}
|
||||
int status;
|
||||
const char *real_old_name;
|
||||
const char *real_new_name;
|
||||
if ( new_name ) {
|
||||
real_old_name = mName.GetSafeName();
|
||||
real_new_name = new_name;
|
||||
} else {
|
||||
real_old_name = mName.GetSafeOldName();
|
||||
real_new_name = mName.GetSafeName();
|
||||
}
|
||||
#if !defined( AL_WIN32S )
|
||||
const char *p = strchr( real_new_name, '.' );
|
||||
if ( p && strlen( p ) > 4 )
|
||||
return mStatus.SetError( AL_RENAME_ERROR,
|
||||
const char *p = strchr( real_new_name, '.' );
|
||||
if ( p && strlen( p ) > 4 )
|
||||
return mStatus.SetError( AL_RENAME_ERROR,
|
||||
"Error trying to rename %s. It has a long "
|
||||
"extension, which could lead to inadvertent "
|
||||
"deletion of a file when trying to rename.",
|
||||
real_old_name );
|
||||
#endif
|
||||
if ( delete_on_clash ) {
|
||||
if ( mName.mCase == AL_MIXED )
|
||||
status = strcmp( real_new_name, real_old_name );
|
||||
else
|
||||
status = stricmp( real_new_name, real_old_name );
|
||||
if ( status == 0 )
|
||||
return mStatus.SetError( AL_RENAME_ERROR,
|
||||
"Error attempting to rename %s to %s. "
|
||||
"Can't rename to the same name!",
|
||||
real_new_name,
|
||||
real_old_name );
|
||||
status = unlink( real_new_name );
|
||||
if ( status != 0 && errno != ENOENT )
|
||||
return mStatus.SetError( AL_RENAME_ERROR,
|
||||
"Error deleting %s before renaming %s. "
|
||||
"errno = %d",
|
||||
real_new_name,
|
||||
real_old_name,
|
||||
errno );
|
||||
}
|
||||
status = rename( real_old_name, real_new_name );
|
||||
if ( status != 0 )
|
||||
return mStatus.SetError( AL_RENAME_ERROR,
|
||||
"Error renaming %s to %s. errno = %d",
|
||||
real_old_name,
|
||||
real_new_name,
|
||||
errno );
|
||||
if ( new_name != 0 )
|
||||
mName = new_name;
|
||||
return AL_SUCCESS;
|
||||
if ( delete_on_clash ) {
|
||||
if ( mName.mCase == AL_MIXED )
|
||||
status = strcmp( real_new_name, real_old_name );
|
||||
else
|
||||
status = stricmp( real_new_name, real_old_name );
|
||||
if ( status == 0 )
|
||||
return mStatus.SetError( AL_RENAME_ERROR,
|
||||
"Error attempting to rename %s to %s. "
|
||||
"Can't rename to the same name!",
|
||||
real_new_name,
|
||||
real_old_name );
|
||||
status = unlink( real_new_name );
|
||||
if ( status != 0 && errno != ENOENT )
|
||||
return mStatus.SetError( AL_RENAME_ERROR,
|
||||
"Error deleting %s before renaming %s. "
|
||||
"errno = %d",
|
||||
real_new_name,
|
||||
real_old_name,
|
||||
errno );
|
||||
}
|
||||
status = rename( real_old_name, real_new_name );
|
||||
if ( status != 0 )
|
||||
return mStatus.SetError( AL_RENAME_ERROR,
|
||||
"Error renaming %s to %s. errno = %d",
|
||||
real_old_name,
|
||||
real_new_name,
|
||||
errno );
|
||||
if ( new_name != 0 )
|
||||
mName = new_name;
|
||||
return AL_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
@ -790,33 +790,33 @@ int AL_PROTO ALFile::Rename( const char AL_DLL_FAR *new_name /* = 0 */,
|
||||
|
||||
int AL_PROTO ALFile::UnRename( int delete_on_clash /* = 1 */ )
|
||||
{
|
||||
AL_ASSERT( miHandle == -1, "UnRename: attempting to rename open file" );
|
||||
AL_ASSERT( mName.GetName() != 0, "UnRename: attempting to rename file with null name" );
|
||||
AL_ASSERT( mName.GetOldName() != 0, "UnRename: attempting to rename file with null old name" );
|
||||
AL_ASSERT( strlen( mName ) > 0, "UnRename: attempting to rename file with 0 length name" );
|
||||
AL_ASSERT( strlen( mName.GetOldName() ) > 0, "UnRename: attempting to rename file with 0 length old name" );
|
||||
AL_ASSERT( miHandle == -1, "UnRename: attempting to rename open file" );
|
||||
AL_ASSERT( mName.GetName() != 0, "UnRename: attempting to rename file with null name" );
|
||||
AL_ASSERT( mName.GetOldName() != 0, "UnRename: attempting to rename file with null old name" );
|
||||
AL_ASSERT( strlen( mName ) > 0, "UnRename: attempting to rename file with 0 length name" );
|
||||
AL_ASSERT( strlen( mName.GetOldName() ) > 0, "UnRename: attempting to rename file with 0 length old name" );
|
||||
|
||||
int status;
|
||||
int status;
|
||||
|
||||
if ( delete_on_clash ) {
|
||||
status = unlink( mName.GetOldName() );
|
||||
if ( status != 0 && errno != ENOENT )
|
||||
return mStatus.SetError( AL_RENAME_ERROR,
|
||||
"Error deleting %s before renaming %s. "
|
||||
"errno = %d",
|
||||
mName.GetOldName(),
|
||||
mName.GetName(),
|
||||
errno );
|
||||
}
|
||||
status = rename( mName, mName.GetOldName() );
|
||||
if ( delete_on_clash ) {
|
||||
status = unlink( mName.GetOldName() );
|
||||
if ( status != 0 && errno != ENOENT )
|
||||
return mStatus.SetError( AL_RENAME_ERROR,
|
||||
"Error renaming %s to %s. errno = %d",
|
||||
mName.GetName(),
|
||||
mName.GetOldName(),
|
||||
errno );
|
||||
ALStorage::mName = mName.GetOldName();
|
||||
return AL_SUCCESS;
|
||||
return mStatus.SetError( AL_RENAME_ERROR,
|
||||
"Error deleting %s before renaming %s. "
|
||||
"errno = %d",
|
||||
mName.GetOldName(),
|
||||
mName.GetName(),
|
||||
errno );
|
||||
}
|
||||
status = rename( mName, mName.GetOldName() );
|
||||
if ( status != 0 && errno != ENOENT )
|
||||
return mStatus.SetError( AL_RENAME_ERROR,
|
||||
"Error renaming %s to %s. errno = %d",
|
||||
mName.GetName(),
|
||||
mName.GetOldName(),
|
||||
errno );
|
||||
ALStorage::mName = mName.GetOldName();
|
||||
return AL_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
@ -843,17 +843,17 @@ int AL_PROTO ALFile::UnRename( int delete_on_clash /* = 1 */ )
|
||||
|
||||
int AL_PROTO ALFile::Delete()
|
||||
{
|
||||
AL_ASSERT( miHandle == -1, "Delete: attempting to delete open file" );
|
||||
AL_ASSERT( mName.GetName() != 0, "Delete: attempting to delete file with null name" );
|
||||
AL_ASSERT( strlen( mName ) > 0, "Delete: attempting to delete file with 0 length name" );
|
||||
AL_ASSERT( miHandle == -1, "Delete: attempting to delete open file" );
|
||||
AL_ASSERT( mName.GetName() != 0, "Delete: attempting to delete file with null name" );
|
||||
AL_ASSERT( strlen( mName ) > 0, "Delete: attempting to delete file with 0 length name" );
|
||||
|
||||
int status = unlink( mName );
|
||||
if ( status != 0 )
|
||||
return mStatus.SetError( AL_DELETE_ERROR,
|
||||
"Error deleting file %s, errno = %d ",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
return AL_SUCCESS;
|
||||
int status = unlink( mName );
|
||||
if ( status != 0 )
|
||||
return mStatus.SetError( AL_DELETE_ERROR,
|
||||
"Error deleting file %s, errno = %d ",
|
||||
mName.GetName(),
|
||||
errno );
|
||||
return AL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user