mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-25 09:02:48 +00:00
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
@ -33,6 +33,10 @@
|
|||||||
#define mbedtls_snprintf snprintf
|
#define mbedtls_snprintf snprintf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "psa_crypto_its.h"
|
#include "psa_crypto_its.h"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
@ -209,7 +213,12 @@ exit:
|
|||||||
}
|
}
|
||||||
if( status == PSA_SUCCESS )
|
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 )
|
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…
x
Reference in New Issue
Block a user