]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
Remove NetIO_File
authorSZAVAI Gyula <szgyg@ludens.elte.hu>
Sun, 28 Jan 2018 19:20:53 +0000 (19:20 +0000)
committerJon Turney <jon.turney@dronecode.org.uk>
Sat, 24 Feb 2018 14:59:29 +0000 (14:59 +0000)
Convert raw paths into file:// form URLs so WinInet can handle them

This maybe changes the set of malformed file:// URLs we handle (which is ok,
although it would be nice to know the details),

Makefile.am
netio.cc
nio-file.cc [deleted file]
nio-file.h [deleted file]

index af058ec4952cd06d5c991754e9734b1717cefcef..da510e401b0af930cf62337ebf58065ef326fcf1 100644 (file)
@@ -194,8 +194,6 @@ inilint_SOURCES = \
        netio.h \
        nio-ie5.cc \
        nio-ie5.h \
-       nio-file.cc \
-       nio-file.h \
        nio-http.cc \
        nio-http.h \
        package_db.cc \
index 6c357fc62ab71f939114b55273e14850cb4c8dc5..dc444dfbb905334aa8c21eb9f2a3c590ce9d9d3e 100644 (file)
--- a/netio.cc
+++ b/netio.cc
@@ -28,7 +28,6 @@
 #include "resource.h"
 #include "state.h"
 #include "msg.h"
-#include "nio-file.h"
 #include "nio-ie5.h"
 #include "nio-http.h"
 #include "dialog.h"
@@ -124,6 +123,8 @@ NetIO *
 NetIO::open (char const *url, bool cachable)
 {
   NetIO *rv = 0;
+  std::string file_url;
+
   enum
   { http, https, ftp, ftps, file }
   proto;
@@ -135,11 +136,17 @@ NetIO::open (char const *url, bool cachable)
     proto = ftp;
   else if (strncmp (url, "ftps://", 7) == 0)
     proto = ftps;
-  else
+  else if (strncmp (url, "file://", 7) == 0)
     proto = file;
+  else
+    {
+      proto = file;
+      file_url = (std::string("file://") + url);
+      url = file_url.c_str();
+    }
 
   if (proto == file)
-    rv = new NetIO_File (url);
+    rv = new NetIO_IE5 (url, true, false);
   else if (net_method == IDC_NET_PRECONFIG)
     rv = new NetIO_IE5 (url, false, cachable);
   else if (net_method == IDC_NET_PROXY)
diff --git a/nio-file.cc b/nio-file.cc
deleted file mode 100644 (file)
index fce1b2c..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2000, Red Hat, Inc.
- *
- *     This program is free software; you can redistribute it and/or modify
- *     it under the terms of the GNU General Public License as published by
- *     the Free Software Foundation; either version 2 of the License, or
- *     (at your option) any later version.
- *
- *     A copy of the GNU General Public License can be found at
- *     http://www.gnu.org/
- *
- * Written by DJ Delorie <dj@cygnus.com>
- *
- */
-
-/* The purpose of this file is to manage access to files stored on the
-   local disk (i.e. "downloading" setup.ini).  Called from netio.cc */
-
-#include "win32.h"
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include "netio.h"
-#include "nio-file.h"
-#include "resource.h"
-#include "msg.h"
-#include "filemanip.h"
-#include "LogSingleton.h"
-
-NetIO_File::NetIO_File (char const *Purl):
-NetIO (Purl)
-{
-  fd = nt_fopen (path, "rb");
-  if (fd)
-    {
-      file_size = get_file_size (std::string("file://") + path);
-    }
-  else
-    {
-      const char *err = strerror (errno);
-      if (!err)
-        err = "(unknown error)";
-      Log (LOG_BABBLE) << "Can't open " << path << " for reading: " << err << endLog;
-    }
-}
-
-NetIO_File::~NetIO_File ()
-{
-  if (fd)
-    fclose ((FILE *) fd);
-}
-
-int
-NetIO_File::ok ()
-{
-  return fd ? 1 : 0;
-}
-
-int
-NetIO_File::read (char *buf, int nbytes)
-{
-  return fread (buf, 1, nbytes, (FILE *) fd);
-}
diff --git a/nio-file.h b/nio-file.h
deleted file mode 100644 (file)
index fe5e8e0..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2000, Red Hat, Inc.
- *
- *     This program is free software; you can redistribute it and/or modify
- *     it under the terms of the GNU General Public License as published by
- *     the Free Software Foundation; either version 2 of the License, or
- *     (at your option) any later version.
- *
- *     A copy of the GNU General Public License can be found at
- *     http://www.gnu.org/
- *
- * Written by DJ Delorie <dj@cygnus.com>
- *
- */
-
-#ifndef SETUP_NIO_FILE_H
-#define SETUP_NIO_FILE_H
-
-/* see nio-file.cc */
-
-class NetIO_File:public NetIO
-{
-public:
-  NetIO_File (char const *url);
-  void *fd;
-   ~NetIO_File ();
-  virtual int ok ();
-  virtual int read (char *buf, int nbytes);
-};
-
-#endif /* SETUP_NIO_FILE_H */
This page took 0.03729 seconds and 5 git commands to generate.