This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
[PATCH setup 3/5] Remove NetIO_File
---
Makefile.am | 2 --
netio.cc | 12 +++++++++---
nio-file.cc | 64 -------------------------------------------------------------
nio-file.h | 31 ------------------------------
4 files changed, 9 insertions(+), 100 deletions(-)
delete mode 100644 nio-file.cc
delete mode 100644 nio-file.h
diff --git a/Makefile.am b/Makefile.am
index aca3ccc..f8f5993 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -192,8 +192,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 \
diff --git a/netio.cc b/netio.cc
index 6c357fc..d77108b 100644
--- 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,7 @@ NetIO *
NetIO::open (char const *url, bool cachable)
{
NetIO *rv = 0;
+ std::string url2;
enum
{ http, https, ftp, ftps, file }
proto;
@@ -135,11 +135,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;
+ url2 = (std::string("file://") + url);
+ url = url2.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
index fce1b2c..0000000
--- a/nio-file.cc
+++ /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
index fe5e8e0..0000000
--- a/nio-file.h
+++ /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 */
--
2.14.3