comparison 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
comparison
equal deleted inserted replaced
319:2ad0b9a00fdd 320:853981bbd4d7
100 else 100 else
101 preventry->children = newentry; 101 preventry->children = newentry;
102 newentry->prev = preventry; 102 newentry->prev = preventry;
103 newentry->next = NULL; 103 newentry->next = NULL;
104 g_hash_table_insert (gftp_bookmarks_htable, newentry->path, newentry); 104 g_hash_table_insert (gftp_bookmarks_htable, newentry->path, newentry);
105 }
106
107
108 static int
109 copyfile (char *source, char *dest)
110 {
111 int srcfd, destfd;
112 char buf[8192];
113 ssize_t n;
114
115 if ((srcfd = gftp_fd_open (NULL, source, O_RDONLY, 0)) == -1)
116 {
117 printf (_("Error: Cannot open local file %s: %s\n"),
118 source, g_strerror (errno));
119 exit (1);
120 }
121
122 if ((destfd = gftp_fd_open (NULL, dest, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR)) == -1)
123 {
124 printf (_("Error: Cannot open local file %s: %s\n"),
125 dest, g_strerror (errno));
126 close (srcfd);
127 exit (1);
128 }
129
130 while ((n = read (srcfd, buf, sizeof (buf))) > 0)
131 {
132 if (write (destfd, buf, n) == -1)
133 {
134 printf (_("Error: Could not write to socket: %s\n"),
135 g_strerror (errno));
136 exit (1);
137 }
138 }
139
140 if (n == -1)
141 {
142 printf (_("Error: Could not read from socket: %s\n"), g_strerror (errno));
143 exit (1);
144 }
145
146 if (close (srcfd) == -1)
147 {
148 printf (_("Error closing file descriptor: %s\n"), g_strerror (errno));
149 exit (1);
150 }
151
152 if (close (destfd) == -1)
153 {
154 printf (_("Error closing file descriptor: %s\n"), g_strerror (errno));
155 exit (1);
156 }
157
158 return (1);
105 } 159 }
106 160
107 161
108 static void 162 static void
109 gftp_read_bookmarks (char *global_data_path) 163 gftp_read_bookmarks (char *global_data_path)