Use function-like macro for Windows renaming
This commit is contained in:
parent
b467934fb7
commit
fdda7de048
@ -62,6 +62,13 @@
|
|||||||
#define PSA_ITS_MAGIC_STRING "PSA\0ITS\0"
|
#define PSA_ITS_MAGIC_STRING "PSA\0ITS\0"
|
||||||
#define PSA_ITS_MAGIC_LENGTH 8
|
#define PSA_ITS_MAGIC_LENGTH 8
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#define rename_replace_existing( oldpath, newpath ) \
|
||||||
|
(!MoveFileExA( oldpath, newpath, MOVEFILE_REPLACE_EXISTING ))
|
||||||
|
#else
|
||||||
|
#define rename_replace_existing( oldpath, newpath ) rename( oldpath, newpath )
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8_t magic[PSA_ITS_MAGIC_LENGTH];
|
uint8_t magic[PSA_ITS_MAGIC_LENGTH];
|
||||||
@ -213,12 +220,7 @@ exit:
|
|||||||
}
|
}
|
||||||
if( status == PSA_SUCCESS )
|
if( status == PSA_SUCCESS )
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
if( rename_replace_existing( PSA_ITS_STORAGE_TEMP, filename ) != 0 )
|
||||||
if( MoveFileExA( PSA_ITS_STORAGE_TEMP, filename,
|
|
||||||
MOVEFILE_REPLACE_EXISTING ) == 0 )
|
|
||||||
#else
|
|
||||||
if( rename( PSA_ITS_STORAGE_TEMP, filename ) != 0 )
|
|
||||||
#endif
|
|
||||||
status = PSA_ERROR_STORAGE_FAILURE;
|
status = PSA_ERROR_STORAGE_FAILURE;
|
||||||
}
|
}
|
||||||
remove( PSA_ITS_STORAGE_TEMP );
|
remove( PSA_ITS_STORAGE_TEMP );
|
||||||
|
Loading…
Reference in New Issue
Block a user