| Avi Drissman | e4622aa | 2022-09-08 20:36:06 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors |
| scottmg | 1ab7aa8 | 2017-05-25 05:22:49 | [diff] [blame] | 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 "base/base_paths.h" |
| 6 | |
| Kevin Marshall | fe2f08c | 2017-08-25 21:45:29 | [diff] [blame] | 7 | #include <stdlib.h> |
| 8 | |
| 9 | #include "base/command_line.h" |
| Kevin Marshall | f35fa5f | 2018-01-29 19:24:42 | [diff] [blame] | 10 | #include "base/files/file_util.h" |
| Sergey Ulanov | 278b19f | 2019-03-12 00:19:59 | [diff] [blame] | 11 | #include "base/fuchsia/file_utils.h" |
| Peter Boström | 6e2fd08 | 2024-01-23 01:17:55 | [diff] [blame] | 12 | #include "base/notimplemented.h" |
| Kevin Marshall | f35fa5f | 2018-01-29 19:24:42 | [diff] [blame] | 13 | #include "base/path_service.h" |
| 14 | #include "base/process/process.h" |
| scottmg | 1ab7aa8 | 2017-05-25 05:22:49 | [diff] [blame] | 15 | |
| 16 | namespace base { |
| Kevin Marshall | f35fa5f | 2018-01-29 19:24:42 | [diff] [blame] | 17 | |
| scottmg | 1ab7aa8 | 2017-05-25 05:22:49 | [diff] [blame] | 18 | bool PathProviderFuchsia(int key, FilePath* result) { |
| 19 | switch (key) { |
| Sergey Ulanov | 5d0a54c | 2018-05-11 18:07:44 | [diff] [blame] | 20 | case FILE_EXE: |
| 21 | *result = CommandLine::ForCurrentProcess()->GetProgram(); |
| Scott Graham | 4bd2b07f | 2017-06-01 04:17:04 | [diff] [blame] | 22 | return true; |
| Sergey Ulanov | d5ae68e | 2018-02-07 20:14:21 | [diff] [blame] | 23 | case DIR_ASSETS: |
| David Dorwin | c694f72 | 2021-10-29 22:46:59 | [diff] [blame] | 24 | *result = base::FilePath(base::kPackageRootDirectoryPath); |
| 25 | return true; |
| Etienne Pierre-doray | f4dcbd6a | 2023-07-06 16:12:03 | [diff] [blame] | 26 | |
| Alison Gale | 81f4f2c7 | 2024-04-22 19:33:31 | [diff] [blame] | 27 | // TODO(crbug.com/40274404): Align with other platforms and remove this |
| Etienne Pierre-doray | f4dcbd6a | 2023-07-06 16:12:03 | [diff] [blame] | 28 | // specialization. |
| David Dorwin | c694f72 | 2021-10-29 22:46:59 | [diff] [blame] | 29 | case DIR_GEN_TEST_DATA_ROOT: |
| Etienne Pierre-doray | f4dcbd6a | 2023-07-06 16:12:03 | [diff] [blame] | 30 | [[fallthrough]]; |
| 31 | |
| 32 | case DIR_SRC_TEST_DATA_ROOT: |
| 33 | case DIR_OUT_TEST_DATA_ROOT: |
| David Dorwin | c694f72 | 2021-10-29 22:46:59 | [diff] [blame] | 34 | // These are only used by tests. |
| 35 | // Test binaries are added to the package root via GN deps. |
| Fabrice de Gans-Riberi | ee44a3b | 2020-10-10 00:21:13 | [diff] [blame] | 36 | *result = base::FilePath(base::kPackageRootDirectoryPath); |
| Kevin Marshall | f35fa5f | 2018-01-29 19:24:42 | [diff] [blame] | 37 | return true; |
| David Dorwin | d9d3c7c | 2021-10-21 04:50:49 | [diff] [blame] | 38 | case DIR_USER_DESKTOP: |
| Alison Gale | d965ba0 | 2024-04-26 21:50:54 | [diff] [blame] | 39 | // TODO(crbug.com/42050322): Implement this case for DIR_USER_DESKTOP. |
| Keith Lee | d41880c7 | 2022-12-13 02:58:25 | [diff] [blame] | 40 | NOTIMPLEMENTED_LOG_ONCE(); |
| David Dorwin | d9d3c7c | 2021-10-21 04:50:49 | [diff] [blame] | 41 | return false; |
| 42 | case DIR_HOME: |
| Alison Gale | d965ba0 | 2024-04-26 21:50:54 | [diff] [blame] | 43 | // TODO(crbug.com/42050322) Provide a proper base::GetHomeDir() |
| David Dorwin | d9d3c7c | 2021-10-21 04:50:49 | [diff] [blame] | 44 | // implementation for Fuchsia and remove this case statement. See also |
| 45 | // crbug.com/1261284. For now, log, return false, and let the base |
| 46 | // implementation handle it. This will end up returning a temporary |
| 47 | // directory. |
| Keith Lee | d41880c7 | 2022-12-13 02:58:25 | [diff] [blame] | 48 | // This is for DIR_HOME. Will use temporary dir. |
| 49 | NOTIMPLEMENTED_LOG_ONCE(); |
| David Dorwin | d9d3c7c | 2021-10-21 04:50:49 | [diff] [blame] | 50 | return false; |
| scottmg | 1ab7aa8 | 2017-05-25 05:22:49 | [diff] [blame] | 51 | } |
| David Dorwin | c694f72 | 2021-10-29 22:46:59 | [diff] [blame] | 52 | |
| scottmg | 1ab7aa8 | 2017-05-25 05:22:49 | [diff] [blame] | 53 | return false; |
| 54 | } |
| 55 | |
| 56 | } // namespace base |