Changeset 379 for trunk/orca

Show
Ignore:
Timestamp:
04/03/07 17:37:23 (20 months ago)
Author:
krobillard
Message:

Rename now has Unix overwrite behavior on Windows.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/orca/stdio.c

    r94 r379  
    6969 
    7070 
     71#ifdef _WIN32 
     72extern int orIsDir( const char* path ); 
     73#endif 
     74 
    7175OR_NATIVE_PUB( orRenameNative ) 
    7276{ 
     
    8791    cp2 = orStrChars( str2, a2 ); 
    8892 
     93#ifdef _WIN32 
     94    // We want Unix rename overwrite behavior. 
     95    if( orIsDir() == 0 ) 
     96    { 
     97        if( remove( cp2 ) == -1 ) 
     98        { 
     99            orErrorT( OR_ERROR_ACCESS, "remove() %s", strerror(errno) ); 
     100            return; 
     101        } 
     102    } 
     103#endif 
     104 
    89105    ok = rename( cp1, cp2 ); 
    90106    if( ok != 0 ) 
    91107    { 
    92         orErrorT( OR_ERROR_ACCESS, "rename() error %d", errno ); 
     108        orErrorT( OR_ERROR_ACCESS, "rename() %s", strerror(errno) ); 
    93109        return; 
    94110    }