mirror of
https://github.com/cathugger/mkp224o.git
synced 2025-01-09 11:07:19 -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
|
SV=mkp224o-$V
|
||||||
SO=$(realpath ./out/$SV)
|
SO=$(realpath ./out/$SV)
|
||||||
git clone ../../ "$SO"
|
git clone ../../ "$SO"
|
||||||
|
git -C ../../ diff | git -C "$SO" apply
|
||||||
cd "$SO"
|
cd "$SO"
|
||||||
rm -rf .git
|
rm -rf .git
|
||||||
./autogen.sh
|
./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)
|
static int syncwritefile(const char *filename,const char *tmpname,int secret,const u8 *data,size_t datalen)
|
||||||
{
|
{
|
||||||
FH f = createfile(tmpname,secret);
|
FH f = createfile(tmpname,secret);
|
||||||
if (f == FH_invalid)
|
if (f == FH_invalid) {
|
||||||
|
//fprintf(stderr,"!failed to create\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (writeall(f,data,datalen) < 0) {
|
if (writeall(f,data,datalen) < 0) {
|
||||||
|
//fprintf(stderr,"!failed to write\n");
|
||||||
goto failclose;
|
goto failclose;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FlushFileBuffers(f) == 0) {
|
if (FlushFileBuffers(f) == 0) {
|
||||||
|
//fprintf(stderr,"!failed to flush\n");
|
||||||
goto failclose;
|
goto failclose;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (closefile(f) < 0) {
|
if (closefile(f) < 0) {
|
||||||
|
//fprintf(stderr,"!failed to close\n");
|
||||||
goto failrm;
|
goto failrm;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MoveFileA(tmpname,filename) == 0) {
|
if (MoveFileExA(tmpname,filename,MOVEFILE_REPLACE_EXISTING) == 0) {
|
||||||
|
//fprintf(stderr,"!failed to move\n");
|
||||||
goto failrm;
|
goto failrm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue