forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase_paths_fuchsia.cc
47 lines (40 loc) · 1.36 KB
/
base_paths_fuchsia.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/base_paths.h"
#include <stdlib.h>
#include "base/command_line.h"
#include "base/files/file_path.h"
namespace base {
bool PathProviderFuchsia(int key, FilePath* result) {
switch (key) {
case FILE_MODULE:
// Not supported in debug or component builds. Fall back on using the EXE
// path for now.
// TODO(fuchsia): Get this value from an API. See crbug.com/726124
case FILE_EXE: {
// Use the binary name as specified on the command line.
// TODO(fuchsia): It would be nice to get the canonical executable path
// from a kernel API. See https://crbug.com/726124
char bin_dir[PATH_MAX + 1];
if (realpath(base::CommandLine::ForCurrentProcess()
->GetProgram()
.AsUTF8Unsafe()
.c_str(),
bin_dir) == NULL) {
return false;
}
*result = FilePath(bin_dir);
return true;
}
case DIR_SOURCE_ROOT:
// This is only used for tests, so we return the binary location for now.
*result = FilePath("/system");
return true;
case DIR_CACHE:
*result = FilePath("/data");
return true;
}
return false;
}
} // namespace base