Getting rid of File descriptor based loading APIs

Reviewed By: javache

Differential Revision: D4333725

fbshipit-source-id: ba8591c7380e8eb90660a912f6fc86fc3d2d4774
This commit is contained in:
Ashok Menon
2017-01-10 07:04:49 -08:00
committed by Facebook Github Bot
parent b5f382c0e8
commit 8819bef56b
5 changed files with 71 additions and 72 deletions

View File

@@ -23,12 +23,15 @@ void JSExecutor::loadApplicationScript(std::string bundlePath, std::string sourc
std::move(sourceURL));
}
void JSExecutor::loadApplicationScript(int fd, std::string sourceURL) {
std::unique_ptr<const JSBigFileString> JSBigFileString::fromPath(const std::string& sourceURL) {
int fd = ::open(sourceURL.c_str(), O_RDONLY);
folly::checkUnixError(fd, "Could not open file", sourceURL);
SCOPE_EXIT { CHECK(::close(fd) == 0); };
struct stat fileInfo;
folly::checkUnixError(::fstat(fd, &fileInfo), "fstat on bundle failed.");
auto bundle = folly::make_unique<JSBigFileString>(fd, fileInfo.st_size);
return loadApplicationScript(std::move(bundle), std::move(sourceURL));
return folly::make_unique<const JSBigFileString>(fd, fileInfo.st_size);
}
static JSBigOptimizedBundleString::Encoding encodingFromByte(uint8_t byte) {