Make "Crypto" file opening unicode-safe on Windows.
This commit is contained in:
parent
6b2818199c
commit
989f0663eb
|
@ -37,6 +37,8 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "FileUtil.h"
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (little endian)
|
||||
*/
|
||||
|
@ -301,7 +303,10 @@ int md5_file( char *path, unsigned char output[16] )
|
|||
md5_context ctx;
|
||||
unsigned char buf[1024];
|
||||
|
||||
if( ( f = fopen( path, "rb" ) ) == NULL )
|
||||
File::IOFile file(path, "rb");
|
||||
f = file.GetHandle();
|
||||
|
||||
if (f == NULL)
|
||||
return( 1 );
|
||||
|
||||
md5_starts( &ctx );
|
||||
|
@ -315,11 +320,9 @@ int md5_file( char *path, unsigned char output[16] )
|
|||
|
||||
if( ferror( f ) != 0 )
|
||||
{
|
||||
fclose( f );
|
||||
return( 2 );
|
||||
}
|
||||
|
||||
fclose( f );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "FileUtil.h"
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (big endian)
|
||||
*/
|
||||
|
@ -335,7 +337,10 @@ int sha1_file( char *path, unsigned char output[20] )
|
|||
sha1_context ctx;
|
||||
unsigned char buf[1024];
|
||||
|
||||
if( ( f = fopen( path, "rb" ) ) == NULL )
|
||||
File::IOFile file(path, "rb");
|
||||
f = file.GetHandle();
|
||||
|
||||
if (f == NULL)
|
||||
return( 1 );
|
||||
|
||||
sha1_starts( &ctx );
|
||||
|
@ -349,11 +354,9 @@ int sha1_file( char *path, unsigned char output[20] )
|
|||
|
||||
if( ferror( f ) != 0 )
|
||||
{
|
||||
fclose( f );
|
||||
return( 2 );
|
||||
}
|
||||
|
||||
fclose( f );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue