Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <fcntl.h> | |
| 6 | |
| 7 #include "base/files/file_util.h" | |
| 8 #include "base/path_service.h" | |
| 9 #include "mojo/nacl/nonsfi/irt_mojo_nonsfi.h" | |
| 10 #include "native_client/src/untrusted/irt/irt_dev.h" | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 int IrtOpenResource(const char* filename, int* newfd) { | |
| 15 base::FilePath base_path; | |
| 16 PathService::Get(base::DIR_MODULE, &base_path); | |
|
Mark Seaborn
2015/10/28 21:53:01
How about returning ENOENT if this fails?
Sean Klein
2015/10/28 22:22:16
Done.
| |
| 17 std::string path = base_path.value(); | |
| 18 path.append("/pnacl_translation_files/"); | |
|
Mark Seaborn
2015/10/28 21:53:01
You could use FilePath()'s Append() method instead
Sean Klein
2015/10/28 22:22:16
Done, and for consistency, updated pnacl_link and
| |
| 19 if (strcmp(filename, "libpnacl_irt_shim.a")) | |
| 20 path.append(filename); | |
| 21 else | |
| 22 path.append("libpnacl_irt_shim_dummy.a"); | |
| 23 int rv = open(path.c_str(), O_RDONLY); | |
| 24 if (rv < 0) | |
| 25 return -errno; | |
|
Mark Seaborn
2015/10/28 21:53:01
This shouldn't be negated.
Sean Klein
2015/10/28 22:22:16
Done.
| |
| 26 *newfd = rv; | |
| 27 return 0; | |
| 28 } | |
| 29 | |
| 30 } // namespace anonymous | |
| 31 | |
| 32 namespace nacl { | |
| 33 | |
| 34 const struct nacl_irt_resource_open nacl_irt_resource_open = { | |
| 35 IrtOpenResource, | |
| 36 }; | |
| 37 | |
| 38 } // namespace nacl | |
| OLD | NEW |