mirror of
https://github.com/cathugger/mkp224o.git
synced 2025-01-09 02:57:21 -03:00
fix syncwritefile on windows
This commit is contained in:
parent
bd1b6d927e
commit
f667a8a256
2 changed files with 10 additions and 2 deletions
|
@ -22,6 +22,7 @@ mkdir -p out
|
|||
SV=mkp224o-$V
|
||||
SO=$(realpath ./out/$SV)
|
||||
git clone ../../ "$SO"
|
||||
git -C ../../ diff | git -C "$SO" apply
|
||||
cd "$SO"
|
||||
rm -rf .git
|
||||
./autogen.sh
|
||||
|
|
11
ioutil.c
11
ioutil.c
|
@ -221,22 +221,29 @@ int createdir(const char *path,int secret)
|
|||
static int syncwritefile(const char *filename,const char *tmpname,int secret,const u8 *data,size_t datalen)
|
||||
{
|
||||
FH f = createfile(tmpname,secret);
|
||||
if (f == FH_invalid)
|
||||
if (f == FH_invalid) {
|
||||
//fprintf(stderr,"!failed to create\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (writeall(f,data,datalen) < 0) {
|
||||
//fprintf(stderr,"!failed to write\n");
|
||||
goto failclose;
|
||||
}
|
||||
|
||||
if (FlushFileBuffers(f) == 0) {
|
||||
//fprintf(stderr,"!failed to flush\n");
|
||||
goto failclose;
|
||||
}
|
||||
|
||||
if (closefile(f) < 0) {
|
||||
//fprintf(stderr,"!failed to close\n");
|
||||
goto failrm;
|
||||
}
|
||||
|
||||
if (MoveFileA(tmpname,filename) == 0) {
|
||||
if (MoveFileExA(tmpname,filename,MOVEFILE_REPLACE_EXISTING) == 0) {
|
||||
//fprintf(stderr,"!failed to move\n");
|
||||
goto failrm;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue