Mercurial > gftp.yaz
comparison src/gtk/menu-items.c @ 131:c77f85763e28
2003-4-13 Brian Masney <masneyb@gftp.org>
* lib/config_file.c - fixed float config type
* lib/gftp.h lib/misc.c - added gftp_gen_ls_string()
* src/gtk/menu-items.c (dosave_directory_listing)
src/text/gftp-text.c (gftp_text_ls) - use
gftp_gen_ls_string()
author | masneyb |
---|---|
date | Mon, 14 Apr 2003 01:07:36 +0000 |
parents | fe0b21c006f6 |
children | c505d9ba9d53 |
comparison
equal
deleted
inserted
replaced
130:e2712348440d | 131:c77f85763e28 |
---|---|
214 | 214 |
215 | 215 |
216 static void | 216 static void |
217 dosave_directory_listing (GtkWidget * widget, gftp_save_dir_struct * str) | 217 dosave_directory_listing (GtkWidget * widget, gftp_save_dir_struct * str) |
218 { | 218 { |
219 const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", | |
220 "Aug", "Sep", "Oct", "Nov", "Dec" }; | |
221 const char *filename; | 219 const char *filename; |
222 struct tm *lt; | |
223 gftp_file * tempfle; | 220 gftp_file * tempfle; |
224 GList * templist; | 221 GList * templist; |
222 char *tempstr; | |
225 FILE * fd; | 223 FILE * fd; |
226 time_t t; | 224 |
227 | 225 |
228 filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (str->filew)); | 226 filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (str->filew)); |
229 if ((fd = fopen (filename, "w")) == NULL) | 227 if ((fd = fopen (filename, "w")) == NULL) |
230 { | 228 { |
231 ftp_log (gftp_logging_misc, NULL, | 229 ftp_log (gftp_logging_misc, NULL, |
232 _("Error: Cannot open %s for writing: %s\n"), filename, | 230 _("Error: Cannot open %s for writing: %s\n"), filename, |
233 g_strerror (errno)); | 231 g_strerror (errno)); |
234 return; | 232 return; |
235 } | 233 } |
236 | 234 |
237 time (&t); | |
238 | |
239 for (templist = str->wdata->files; | 235 for (templist = str->wdata->files; |
240 templist->next != NULL; | 236 templist->next != NULL; |
241 templist = templist->next) | 237 templist = templist->next) |
242 { | 238 { |
243 tempfle = templist->data; | 239 tempfle = templist->data; |
244 fprintf (fd, "%10s %8s %8s ", tempfle->attribs, tempfle->user, | 240 |
245 tempfle->group); | 241 tempstr = gftp_gen_ls_string (tempfle, NULL, NULL); |
246 if (tempfle->attribs && (*tempfle->attribs == 'b' || | 242 fprintf (fd, "%s\n", tempstr); |
247 *tempfle->attribs == 'c')) | 243 g_free (tempstr); |
248 fprintf (fd, "%5d, %4d", (((unsigned int) tempfle->size) >> 16) & 0xFF, | |
249 ((unsigned int) tempfle->size) & 0xFF); | |
250 else | |
251 { | |
252 #if defined (_LARGEFILE_SOURCE) | |
253 fprintf (fd, "%11lld", tempfle->size); | |
254 #else | |
255 fprintf (fd, "%11ld", tempfle->size); | |
256 #endif | |
257 } | |
258 | |
259 lt = localtime (&tempfle->datetime); | |
260 | |
261 if (tempfle->datetime > t || | |
262 t - 3600*24*90 > tempfle->datetime) | |
263 fprintf (fd, " %s %2d %4d", months[lt->tm_mon], lt->tm_mday, | |
264 lt->tm_year + 1900); | |
265 else | |
266 fprintf (fd, " %s %2d %02d:%02d", months[lt->tm_mon], lt->tm_mday, | |
267 lt->tm_hour, lt->tm_min); | |
268 | |
269 fprintf (fd, " %s\n", tempfle->file); | |
270 } | 244 } |
271 | 245 |
272 fclose (fd); | 246 fclose (fd); |
273 } | 247 } |
274 | 248 |