* Bugfix of "rename" across volumes, now simply copies the file instead.

This commit is contained in:
carl 2019-03-17 23:19:16 +08:00
parent de57335296
commit b3814af1ba
2 changed files with 24 additions and 12 deletions

View file

@ -43,17 +43,7 @@ void UNLINK(string x)
#endif
}
void RENAME(string x,string y)
{
/* Must move the file "x" to the file "y" */
#ifdef USE_SYS
if(!sys_rename(x,y)) fatal(1,"Cannot rename to %s",y);
#else
if (rename(x, y) == -1)
fatal(1, "Cannot rename to %s", y);
#endif
}
string libpath(string s)
{

View file

@ -353,6 +353,28 @@ void copyfile(string file)
fclose(f);
}
void copyto(string target, string source)
{
FILE *fsource;
FILE *ftarget;
int c;
ftarget = fopen(target,"wb+");
if (ftarget == NULL)
{
fatal(0, "Cannot open file %s, call an expert", target);
}
fsource = fopen(source,"rb");
if (fsource == NULL)
{
fatal(0, "Cannot open file %s, call an expert", source);
}
while ((c = getc(fsource)) != EOF)
putc(c, ftarget);
fclose(fsource);
fclose(ftarget);
}
void install(string target, string source)
{
/*
@ -377,7 +399,7 @@ void install(string target, string source)
if ((f2 = fopen(target, "r")) == NULL)
{
fclose(f1);
RENAME(f_pars, target);
copyto(target, f_pars);
return;
}
/*
@ -406,6 +428,6 @@ void install(string target, string source)
{
fatal(0, "%s : not a file generated by LLgen", target);
}
RENAME(f_pars, target);
copyto(target, f_pars);
}
}