Mercurial > gftp.yaz
diff lib/config_file.c @ 320:853981bbd4d7
2003-11-30 Brian Masney <masneyb@gftp.org>
* src/gtk/transfer.c - shows status information in title bar. (patch
from Jamil Geor <jamil_geor@yahoo.co.nz>, cleaned up by me some)
* lib/options.h - added show_trans_in_title option.
2003-11-25 Brian Masney <masneyb@gftp.org>
* lib/misc.c (gftp_locale_init) - call bindtextdomain() so that the
directory is setup properly
* lib/misc.c lib/gftp.h lib/config_file.c - move copyfile() to
config_file.c and declare it to be static. On the destination file,
set the flag O_EXCL
author | masneyb |
---|---|
date | Sun, 30 Nov 2003 19:35:24 +0000 |
parents | 35ae2e80962e |
children | 0fcc6468a0af |
line wrap: on
line diff
--- a/lib/config_file.c Sun Nov 23 15:52:22 2003 +0000 +++ b/lib/config_file.c Sun Nov 30 19:35:24 2003 +0000 @@ -105,6 +105,60 @@ } +static int +copyfile (char *source, char *dest) +{ + int srcfd, destfd; + char buf[8192]; + ssize_t n; + + if ((srcfd = gftp_fd_open (NULL, source, O_RDONLY, 0)) == -1) + { + printf (_("Error: Cannot open local file %s: %s\n"), + source, g_strerror (errno)); + exit (1); + } + + if ((destfd = gftp_fd_open (NULL, dest, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR)) == -1) + { + printf (_("Error: Cannot open local file %s: %s\n"), + dest, g_strerror (errno)); + close (srcfd); + exit (1); + } + + while ((n = read (srcfd, buf, sizeof (buf))) > 0) + { + if (write (destfd, buf, n) == -1) + { + printf (_("Error: Could not write to socket: %s\n"), + g_strerror (errno)); + exit (1); + } + } + + if (n == -1) + { + printf (_("Error: Could not read from socket: %s\n"), g_strerror (errno)); + exit (1); + } + + if (close (srcfd) == -1) + { + printf (_("Error closing file descriptor: %s\n"), g_strerror (errno)); + exit (1); + } + + if (close (destfd) == -1) + { + printf (_("Error closing file descriptor: %s\n"), g_strerror (errno)); + exit (1); + } + + return (1); +} + + static void gftp_read_bookmarks (char *global_data_path) {