Now that copy_file() is in libWUtil, use it instead of fetchFile(),
which can be removed from wcolorpanel.c.

Signed-off-by: Carlos R. Mafra <[email protected]>
---
 WINGs/wcolorpanel.c |   56 +--------------------------------------------------
 1 files changed, 1 insertions(+), 55 deletions(-)

diff --git a/WINGs/wcolorpanel.c b/WINGs/wcolorpanel.c
index eb01947..03e8223 100644
--- a/WINGs/wcolorpanel.c
+++ b/WINGs/wcolorpanel.c
@@ -275,7 +275,6 @@ enum {
 #define M_PI 3.14159265358979323846
 #endif
 
-static int fetchFile(char *toPath, char *imageSrcFile, char 
*imageDestFileName);
 char *generateNewFilename(char *curName);
 void convertCPColor(CPColor * color);
 RColor ulongToRColor(WMScreen * scr, unsigned long value);
@@ -2925,7 +2924,7 @@ static void customPaletteMenuNewFromFile(W_ColorPanel * 
panel)
 
                /* Copy image to $(gnustepdir)/Library/Colors/ &
                 * Add filename to history menu */
-               if (fetchFile(panel->configurationPath, filepath, filename) == 
0) {
+               if (copy_file(panel->configurationPath, filepath, filename) == 
0) {
 
                        /* filepath is a "local" path now the file has been 
copied */
                        wfree(filepath);
@@ -3337,59 +3336,6 @@ static void hsbInit(W_ColorPanel * panel)
 
 /************************** Common utility functions ************************/
 
-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);
-               return -1;
-       }
-
-       dstpath = wstrconcat(toPath, destFile);
-       RETRY( dst = fopen(dstpath, "wb") )
-       if (dst == NULL) {
-               werror(_("Could not create %s"), dstpath);
-               wfree(dstpath);
-               RETRY( fclose(src) )
-               return -1;
-       }
-
-       do {
-               RETRY( nread = fread(buf, 1, sizeof(buf), src) )
-               if (ferror(src))
-                       break;
-
-               RETRY( nwritten = fwrite(buf, 1, nread, dst) )
-               if (ferror(dst) || feof(src) || nread != nwritten)
-                       break;
-
-       } while (1);
-
-       if (ferror(src) || ferror(dst))
-               unlink(dstpath);
-
-       RETRY( fclose(src) )
-       fchmod(fileno(dst), st.st_mode);
-       fsync(fileno(dst));
-       RETRY( fclose(dst) )
-       wfree(dstpath);
-
-       return 0;
-}
-
 char *generateNewFilename(char *curName)
 {
        int n;
-- 
1.7.3.4


-- 
To unsubscribe, send mail to [email protected].

Reply via email to