1 // Copyright 2017 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.
5 #include "base/base_paths.h"
9 #include "base/base_paths_fuchsia.h"
10 #include "base/command_line.h"
11 #include "base/files/file_util.h"
12 #include "base/path_service.h"
13 #include "base/process/process.h"
18 constexpr char kPackageRoot[] = "/pkg";
22 base::FilePath GetPackageRoot() {
23 base::FilePath path_obj(kPackageRoot);
25 // Fuchsia's appmgr will set argv[0] to a fully qualified executable path
26 // under /pkg for packaged binaries.
27 if (path_obj.IsParent(base::CommandLine::ForCurrentProcess()->GetProgram())) {
30 return base::FilePath();
34 bool PathProviderFuchsia(int key, FilePath* result) {
40 *result = base::MakeAbsoluteFilePath(base::FilePath(
41 base::CommandLine::ForCurrentProcess()->GetProgram().AsUTF8Unsafe()));
45 *result = GetPackageRoot();
46 if (result->empty()) {
47 *result = FilePath("/system");
51 *result = FilePath("/data");
54 *result = GetPackageRoot();
55 if (result->empty()) {
56 return PathService::Get(DIR_EXE, result);