diff lib/local.c @ 7:5551ab2301fe

* Fixed a DND crash * When running a SSH bookmark, make sure need_userpass is enabled for that connection * moved anonymous ftp stuff from gtk port to rfc959.c * call bind_textdomain_codeset in gtk+ port * translation fixes for menus (from Owen Taylor <otaylor@redhat.com>)
author masneyb
date Fri, 23 Aug 2002 12:40:44 +0000
parents 8b1883341c6f
children 83090328581e
line wrap: on
line diff
--- a/lib/local.c	Fri Aug 23 05:31:50 2002 +0000
+++ b/lib/local.c	Fri Aug 23 12:40:44 2002 +0000
@@ -202,6 +202,7 @@
                 off_t startsize)
 {
   size_t size;
+  int sock, flags;
 
   g_return_val_if_fail (request != NULL, -2);
   g_return_val_if_fail (request->protonum == GFTP_LOCAL_NUM, -2);
@@ -209,13 +210,27 @@
 
   if (fd == NULL)
     {
-      if ((request->datafd = fopen (filename, "rb")) == NULL)
+      flags = O_RDONLY;
+#if defined (_LARGEFILE_SOURCE)
+      flags |= O_LARGEFILE;
+#endif
+
+      if ((sock = open (filename, flags)) < 0)
         {
           request->logging_function (gftp_logging_error, request->user_data,
                                    _("Error: Cannot open local file %s: %s\n"),
                                    filename, g_strerror (errno));
           return (-2);
         }
+
+      if ((request->datafd = fdopen (sock, "rb")) == NULL)
+        {
+          request->logging_function (gftp_logging_error, request->user_data,
+                                     _("Cannot fdopen() socket for %s: %s\n"),
+                                     filename, g_strerror (errno));
+          close (sock);
+          return (-2);
+        }
     }
   else
     request->datafd = fd;
@@ -255,7 +270,7 @@
 local_put_file (gftp_request * request, const char *filename, FILE * fd,
                 off_t startsize, off_t totalsize)
 {
-  int sock;
+  int sock, flags;
 
   g_return_val_if_fail (request != NULL, -2);
   g_return_val_if_fail (request->protonum == GFTP_LOCAL_NUM, -2);
@@ -263,9 +278,14 @@
 
   if (fd == NULL)
     {
-      if ((sock = open (filename, 
-          startsize > 0 ? O_WRONLY | O_APPEND | O_CREAT: O_WRONLY | O_CREAT, 
-          S_IRUSR | S_IWUSR)) < 0)
+      flags = O_WRONLY | O_CREAT;
+      if (startsize > 0)
+         flags |= O_APPEND;
+#if defined (_LARGEFILE_SOURCE)
+      flags |= O_LARGEFILE;
+#endif
+
+      if ((sock = open (filename, flags, S_IRUSR | S_IWUSR)) < 0)
         {
           request->logging_function (gftp_logging_error, request->user_data,
                                    _("Error: Cannot open local file %s: %s\n"),