Fix passing fd across modules

This commit is contained in:
Cheng Zhao 2016-05-19 16:38:37 +09:00
parent 4702d8b640
commit e609a5bee2
4 changed files with 58 additions and 6 deletions

View file

@ -4,10 +4,6 @@
#include "atom/common/asar/archive.h"
#if defined(OS_WIN)
#include <io.h>
#endif
#include <string>
#include <vector>
@ -20,6 +16,10 @@
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#if defined(OS_WIN)
#include "atom/node/osfhandle.h"
#endif
namespace asar {
namespace {
@ -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_(_open_osfhandle(
fd_(node::open_osfhandle(
reinterpret_cast<intptr_t>(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) {
_close(fd_);
node::close(fd_);
// Don't close the handle since we already closed the fd.
file_.TakePlatformFile();
}