Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: mojo/nacl/nonsfi/irt_resource_open.cc

Issue 1382713002: Creating a pexe content handler to translate and run pexes. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Using PathService instead of URL hacking Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698