]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
* filemanip.cc (nt_fopen): Rename from fopen. Add permission parameter.
authorCorinna Vinschen <corinna@vinschen.de>
Mon, 18 Nov 2013 11:16:15 +0000 (11:16 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Mon, 18 Nov 2013 11:16:15 +0000 (11:16 +0000)
Drop C binding.  Move comment.
* filemanip.h (nt_fopen): Declare.
* geturl.cc (get_url_to_file): Call nt_fopen instead of fopen.
* nio-file.cc (NetIO_File::NetIO_File): Ditto.
* main.cc (dyn_AttachConsole): Remove.
(dyn_GetLongPathName): Remove.
(set_dynaddr): Remove.
(set_cout): Just call AttachConsole directly.
(WinMain): Drop call to set_dynaddr.

ChangeLog
filemanip.cc
filemanip.h
geturl.cc
main.cc
nio-file.cc

index 1e2ed5a40fdfcad4e63a6df38d3585f8ee08fac0..6494d9eb69986579617eb92f2d78abe55c80f10d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2013-11-18  Corinna Vinschen  <corinna@vinschen.de>
+
+       * filemanip.cc (nt_fopen): Rename from fopen.  Add permission parameter.
+       Drop C binding.  Move comment.
+       * filemanip.h (nt_fopen): Declare.
+       * geturl.cc (get_url_to_file): Call nt_fopen instead of fopen.
+       * nio-file.cc (NetIO_File::NetIO_File): Ditto.
+       * main.cc (dyn_AttachConsole): Remove.
+       (dyn_GetLongPathName): Remove.
+       (set_dynaddr): Remove.
+       (set_cout): Just call AttachConsole directly.
+       (WinMain): Drop call to set_dynaddr.
+
 2013-11-15  Corinna Vinschen  <corinna@vinschen.de>
 
        * resource.h (IDC_SOURCE_SUBTEXT): Define.
index 121917aeee602cae976554114f44e3e2b1bda802..8b733cef0f8046e8f07bd7c8e8028f9f40e4f442 100644 (file)
@@ -515,18 +515,18 @@ nt_wfopen (const wchar_t *wpath, const char *mode, mode_t perms)
   return _fdopen (fd, mode);
 }
 
-/* Override C file io functions for the sake of the download side of setup.
-   These overrides eliminate the problem that the ANSI file API limits the
-   filename length to MAX_PATH. */
-extern "C" FILE *
-fopen (const char *path, const char *mode)
+FILE *
+nt_fopen (const char *path, const char *mode, mode_t perms)
 {
   size_t len = strlen (path) + 8;
   WCHAR wpath[len];
   mklongpath (wpath, path, len);
-  return nt_wfopen (wpath, mode, 0644);
+  return nt_wfopen (wpath, mode, perms);
 }
 
+/* Override C file io functions for the sake of the download side of setup.
+   These overrides eliminate the problem that the ANSI file API limits the
+   filename length to MAX_PATH. */
 extern "C" int
 remove (const char *path)
 {
index 6a7fb030fe9a770b859e062e203b8c60663ed00d..559451935e88571264c5cfbf895a8ffafa35b66d 100644 (file)
@@ -36,5 +36,6 @@ std::string backslash (const std::string& s);
 const char * trail (const char *, const char *);
 int mklongpath (wchar_t *tgt, const char *src, size_t len);
 FILE *nt_wfopen (const wchar_t *wpath, const char *mode, mode_t perms);
+FILE *nt_fopen (const char *path, const char *mode, mode_t perms = 0644);
 
 #endif /* SETUP_FILEMANIP_H */
index 5dd4effc3fc45d29ad0898a214425b8c79e48888..1899d5e13b796b65f26643a27aa3d885f1eb7de8 100644 (file)
--- a/geturl.cc
+++ b/geturl.cc
@@ -41,6 +41,7 @@ static const char *cvsid =
 #include "state.h"
 #include "diskfull.h"
 #include "mount.h"
+#include "filemanip.h"
 
 #include "threebar.h"
 
@@ -225,7 +226,7 @@ get_url_to_file (const string &_url,
       return 1;
     }
 
-  FILE *f = fopen (_filename.c_str(), "wb");
+  FILE *f = nt_fopen (_filename.c_str(), "wb");
   if (!f)
     {
       const char *err = strerror (errno);
diff --git a/main.cc b/main.cc
index 8e7bc942bf9e08c8d4fe3009133a37d2f459a52e..0ed84a1f71011ce7ceee786fa6c8a21def1437d2 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -96,19 +96,6 @@ static BoolOption UnattendedOption (false, 'q', "quiet-mode", "Unattended setup
 static BoolOption PackageManagerOption (false, 'M', "package-manager", "Semi-attended chooser-only mode");
 static BoolOption NoAdminOption (false, 'B', "no-admin", "Do not check for and enforce running as Administrator");
 static BoolOption HelpOption (false, 'h', "help", "print help");
-static BOOL WINAPI (*dyn_AttachConsole) (DWORD);
-static BOOL WINAPI (*dyn_GetLongPathName) (LPCTSTR, LPTSTR, DWORD);
-
-static void inline
-set_dynaddr ()
-{
-  HMODULE hm = LoadLibrary ("kernel32.dll");
-  if (!hm)
-    return;
-
-  dyn_AttachConsole = (BOOL WINAPI (*)(DWORD)) GetProcAddress (hm, "AttachConsole");
-  dyn_GetLongPathName = (BOOL WINAPI (*)(LPCTSTR, LPTSTR, DWORD)) GetProcAddress (hm, "GetLongPathNameA");
-}
 
 static void inline
 set_cout ()
@@ -117,7 +104,7 @@ set_cout ()
   if (my_stdout != INVALID_HANDLE_VALUE && GetFileType (my_stdout) != FILE_TYPE_UNKNOWN)
     return;
 
-  if (dyn_AttachConsole && dyn_AttachConsole ((DWORD) -1))
+  if (AttachConsole ((DWORD) -1))
     {
       ofstream *conout = new ofstream ("conout$");
       cout.rdbuf (conout->rdbuf ());
@@ -227,7 +214,6 @@ WinMain (HINSTANCE h,
 
   hinstance = h;
 
-  set_dynaddr ();
   // Make sure the C runtime functions use the same codepage as the GUI
   char locale[12];
   snprintf(locale, sizeof locale, ".%u", GetACP());
index c9f452eec72f1a9fb89de8aef2402aa125e25b0d..efdf40db20d35e4ba681473c63f18f1a147b6987 100644 (file)
@@ -35,7 +35,7 @@ static const char *cvsid =
 NetIO_File::NetIO_File (char const *Purl):
 NetIO (Purl)
 {
-  fd = fopen (path, "rb");
+  fd = nt_fopen (path, "rb");
   if (fd)
     {
       file_size = get_file_size (std::string("file://") + path);
This page took 0.047128 seconds and 5 git commands to generate.