Add Archive::GetFD
This commit is contained in:
parent
f8e1dfbbc6
commit
d8d7e5b9bb
5 changed files with 34 additions and 5 deletions
|
@ -4,6 +4,10 @@
|
|||
|
||||
#include "atom/common/asar/archive.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -250,7 +254,7 @@ bool Archive::CopyFileOut(const base::FilePath& path, base::FilePath* out) {
|
|||
}
|
||||
|
||||
scoped_ptr<ScopedTemporaryFile> temp_file(new ScopedTemporaryFile);
|
||||
if (!temp_file->InitFromFile(file_, info.offset, info.size))
|
||||
if (!temp_file->InitFromFile(&file_, info.offset, info.size))
|
||||
return false;
|
||||
|
||||
*out = temp_file->path();
|
||||
|
@ -258,4 +262,18 @@ bool Archive::CopyFileOut(const base::FilePath& path, base::FilePath* out) {
|
|||
return true;
|
||||
}
|
||||
|
||||
int Archive::GetFD() const {
|
||||
if (!file_.IsValid())
|
||||
return -1;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
return
|
||||
_open_osfhandle(reinterpret_cast<intptr_t>(file_.GetPlatformFile()), 0);
|
||||
#elif defined(OS_POSIX)
|
||||
return file_.GetPlatformFile();
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace asar
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue