The idea is to use the fetchFile() in getstyle.c and in wcolorpanel.c instead of using two very similar functions.
In order to do that, let's move the most generic one (fetchFile()) to libWUtils, and this is the first step. Signed-off-by: Carlos R. Mafra <[email protected]> --- WINGs/wcolorpanel.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/WINGs/wcolorpanel.c b/WINGs/wcolorpanel.c index c86dfdd..eb01947 100644 --- a/WINGs/wcolorpanel.c +++ b/WINGs/wcolorpanel.c @@ -3342,8 +3342,16 @@ static int fetchFile(char *toPath, char *srcFile, char *destFile) FILE *src, *dst; size_t nread, nwritten; char *dstpath; + struct stat st; char buf[BUFSIZE]; + /* only to a directory */ + if (stat(toPath, &st) != 0 || !S_ISDIR(st.st_mode)) + return -1; + /* only copy files */ + if (stat(srcFile, &st) != 0 || !S_ISREG(st.st_mode)) + return -1; + RETRY( src = fopen(srcFile, "rb") ) if (src == NULL) { werror(_("Could not open %s"), srcFile); @@ -3374,10 +3382,11 @@ static int fetchFile(char *toPath, char *srcFile, char *destFile) unlink(dstpath); RETRY( fclose(src) ) + fchmod(fileno(dst), st.st_mode); fsync(fileno(dst)); RETRY( fclose(dst) ) - wfree(dstpath); + return 0; } -- 1.7.3.4 -- To unsubscribe, send mail to [email protected].
