Use Windows-specific renaming function
On Windows, rename() fails if the new filename already exists. Use the Windows specific function MoveFileExA with the MOVEFILE_REPLACE_EXISTING flag set instead to do renames.
This commit is contained in:
parent
c70a3c76bf
commit
b467934fb7
1 changed files with 9 additions and 0 deletions
|
@ -33,6 +33,10 @@
|
|||
#define mbedtls_snprintf snprintf
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "psa_crypto_its.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
@ -209,7 +213,12 @@ exit:
|
|||
}
|
||||
if( status == PSA_SUCCESS )
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
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;
|
||||
}
|
||||
remove( PSA_ITS_STORAGE_TEMP );
|
||||
|
|
Loading…
Reference in a new issue