From 64d9e5b8611c4833ae787ad01460811adc8964f1 Mon Sep 17 00:00:00 2001 From: Ales Pergl Date: Wed, 30 Aug 2017 10:28:45 +0200 Subject: [PATCH] Removed obsolete `io.h` wrappers, included `atlbase.h` in `atom_main.cc` --- atom/app/atom_main.cc | 1 + atom/common/asar/archive.cc | 6 +++--- atom/node/osfhandle.cc | 10 ---------- atom/node/osfhandle.h | 14 -------------- 4 files changed, 4 insertions(+), 27 deletions(-) diff --git a/atom/app/atom_main.cc b/atom/app/atom_main.cc index 76a62399d6ea..cbba0d5bfbca 100644 --- a/atom/app/atom_main.cc +++ b/atom/app/atom_main.cc @@ -9,6 +9,7 @@ #if defined(OS_WIN) #include // windows.h must be included first +#include // ensures that ATL statics like `_AtlWinModule` are initialized (it's an issue in static debug build) #include #include #include diff --git a/atom/common/asar/archive.cc b/atom/common/asar/archive.cc index 8f75c8fbb572..c8d85f904d93 100644 --- a/atom/common/asar/archive.cc +++ b/atom/common/asar/archive.cc @@ -17,7 +17,7 @@ #include "base/values.h" #if defined(OS_WIN) -#include "atom/node/osfhandle.h" +#include #endif namespace asar { @@ -118,7 +118,7 @@ Archive::Archive(const base::FilePath& path) : path_(path), file_(path_, base::File::FLAG_OPEN | base::File::FLAG_READ), #if defined(OS_WIN) - fd_(node::open_osfhandle( + fd_(_open_osfhandle( reinterpret_cast(file_.GetPlatformFile()), 0)), #elif defined(OS_POSIX) fd_(file_.GetPlatformFile()), @@ -131,7 +131,7 @@ Archive::Archive(const base::FilePath& path) Archive::~Archive() { #if defined(OS_WIN) if (fd_ != -1) { - node::close(fd_); + _close(fd_); // Don't close the handle since we already closed the fd. file_.TakePlatformFile(); } diff --git a/atom/node/osfhandle.cc b/atom/node/osfhandle.cc index 4d49d7227b70..1efdce39a29b 100644 --- a/atom/node/osfhandle.cc +++ b/atom/node/osfhandle.cc @@ -4,8 +4,6 @@ #include "osfhandle.h" -#include - #if !defined(DEBUG) #define U_I18N_IMPLEMENTATION #define U_COMMON_IMPLEMENTATION @@ -32,14 +30,6 @@ namespace node { -int open_osfhandle(intptr_t osfhandle, int flags) { - return _open_osfhandle(osfhandle, flags); -} - -int close(int fd) { - return _close(fd); -} - void ReferenceSymbols() { // Following symbols are used by electron.exe but got stripped by compiler, // by using the symbols we can force compiler to keep the objects in node.dll, diff --git a/atom/node/osfhandle.h b/atom/node/osfhandle.h index 1427bb895115..06b91ba51fb8 100644 --- a/atom/node/osfhandle.h +++ b/atom/node/osfhandle.h @@ -5,22 +5,8 @@ #ifndef ATOM_NODE_OSFHANDLE_H_ #define ATOM_NODE_OSFHANDLE_H_ -#include - namespace node { -// The _open_osfhandle and _close functions on Windows are provided by the -// Visual C++ library, so the fd returned by them can only be used in the -// same instance of VC++ library. -// However Electron is linking with VC++ library statically, so electron.exe -// shares a different instance of VC++ library with node.exe. This results -// in fd created in electron.exe not usable in node.dll, so we have to ensure -// we always create fd in one instance of VC++ library. -// Followings wrappers are compiled in node.dll, and all code in electron.exe -// should call these wrappers instead of calling _open_osfhandle directly. -__declspec(dllexport) int open_osfhandle(intptr_t osfhandle, int flags); -__declspec(dllexport) int close(int fd); - // A trick to force referencing symbols. __declspec(dllexport) void ReferenceSymbols();