kumarashishg | 826308d | 2023-06-23 13:21:22 +0000 | [diff] [blame] | 1 | // Copyright 2015 The PDFium Authors |
Philip P. Moltmann | ac3d58c | 2016-03-04 15:19:21 -0800 | [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 | #ifndef TESTING_UTILS_PATH_SERVICE_H_ |
| 6 | #define TESTING_UTILS_PATH_SERVICE_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #ifdef _WIN32 |
| 11 | #define PATH_SEPARATOR '\\' |
| 12 | #else |
| 13 | #define PATH_SEPARATOR '/' |
| 14 | #endif |
| 15 | |
| 16 | // Get the various file directory and path information. |
| 17 | class PathService { |
| 18 | public: |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 19 | // Return true when the path is a directory that exists. |
| 20 | static bool DirectoryExists(const std::string& path); |
| 21 | |
Philip P. Moltmann | ac3d58c | 2016-03-04 15:19:21 -0800 | [diff] [blame] | 22 | // Return true when the path ends with a path separator. |
| 23 | static bool EndsWithSeparator(const std::string& path); |
| 24 | |
| 25 | // Retrieve the directory where executables run from. |
| 26 | static bool GetExecutableDir(std::string* path); |
| 27 | |
| 28 | // Retrieve the root directory of the source tree. |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 29 | // Assume executables always run from out/<build_dir_name>/, so the source |
Philip P. Moltmann | ac3d58c | 2016-03-04 15:19:21 -0800 | [diff] [blame] | 30 | // directory is two levels above the executable directory. |
| 31 | static bool GetSourceDir(std::string* path); |
| 32 | |
| 33 | // Retrieve the test data directory where test files are stored. |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 34 | // Try <source_dir>/testing/resources/ first. If it does not exist, try |
| 35 | // checking <source_dir>/third_party/pdfium/testing/resources/. |
Philip P. Moltmann | ac3d58c | 2016-03-04 15:19:21 -0800 | [diff] [blame] | 36 | static bool GetTestDataDir(std::string* path); |
| 37 | |
| 38 | // Get the full path for a test file under the test data directory. |
| 39 | static bool GetTestFilePath(const std::string& file_name, std::string* path); |
kumarashishg | 826308d | 2023-06-23 13:21:22 +0000 | [diff] [blame] | 40 | |
| 41 | // Get the full path for a file under the third-party directory. |
| 42 | static bool GetThirdPartyFilePath(const std::string& file_name, |
| 43 | std::string* path); |
Philip P. Moltmann | ac3d58c | 2016-03-04 15:19:21 -0800 | [diff] [blame] | 44 | }; |
| 45 | #endif // TESTING_UTILS_PATH_SERVICE_H_ |