return 0 if file cp only partially succeeded

SVN revision: 29684
This commit is contained in:
Carsten Haitzler 2007-04-22 23:07:48 +00:00
parent ecfa6af1ec
commit db70aa52ac
1 changed files with 6 additions and 2 deletions

View File

@ -183,6 +183,7 @@ ecore_file_cp(const char *src, const char *dst)
char realpath1[PATH_MAX];
char realpath2[PATH_MAX];
size_t num;
int ret = 1;
if (!realpath(src, realpath1)) return 0;
if (realpath(dst, realpath2) && !strcmp(realpath1, realpath2)) return 0;
@ -195,10 +196,13 @@ ecore_file_cp(const char *src, const char *dst)
fclose(f1);
return 0;
}
while ((num = fread(buf, 1, sizeof(buf), f1)) > 0) fwrite(buf, 1, num, f2);
while ((num = fread(buf, 1, sizeof(buf), f1)) > 0)
{
if (fwrite(buf, 1, num, f2) != num) ret = 0;
}
fclose(f1);
fclose(f2);
return 1;
return ret;
}
EAPI int