michajlo | 3d8925d | 2019-05-20 16:10:41 -0700 | [diff] [blame] | 1 | // Copyright 2014 The Bazel Authors. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #ifndef BAZEL_SRC_MAIN_CPP_ARCHIVE_UTILS_H_ |
| 16 | #define BAZEL_SRC_MAIN_CPP_ARCHIVE_UTILS_H_ |
| 17 | |
| 18 | #include <string> |
| 19 | #include <vector> |
| 20 | |
michajlo | 3d8925d | 2019-05-20 16:10:41 -0700 | [diff] [blame] | 21 | namespace blaze { |
| 22 | |
michajlo | 6f38f34 | 2019-05-22 11:53:22 -0700 | [diff] [blame] | 23 | // Determines the contents of the archive, storing the names of the contained |
| 24 | // files into `files` and the install md5 key into `install_md5`. |
| 25 | void DetermineArchiveContents(const std::string &archive_path, |
michajlo | 6f38f34 | 2019-05-22 11:53:22 -0700 | [diff] [blame] | 26 | std::vector<std::string> *files, |
| 27 | std::string *install_md5); |
michajlo | 3d8925d | 2019-05-20 16:10:41 -0700 | [diff] [blame] | 28 | |
michajlo | 6f38f34 | 2019-05-22 11:53:22 -0700 | [diff] [blame] | 29 | // Extracts the embedded data files in `archive_path` into `output_dir`. |
michajlo | aeae59a | 2020-03-27 12:21:25 -0700 | [diff] [blame] | 30 | // It's expected that `output_dir` already exists and that it's a directory. |
michajlo | 6f38f34 | 2019-05-22 11:53:22 -0700 | [diff] [blame] | 31 | // Fails if `expected_install_md5` doesn't match that contained in the archive, |
| 32 | // as this could indicate that the contents has unexpectedly changed. |
| 33 | void ExtractArchiveOrDie(const std::string &archive_path, |
| 34 | const std::string &product_name, |
| 35 | const std::string &expected_install_md5, |
| 36 | const std::string &output_dir); |
michajlo | 3d8925d | 2019-05-20 16:10:41 -0700 | [diff] [blame] | 37 | |
michajlo | 371a2e3 | 2019-05-23 13:14:39 -0700 | [diff] [blame] | 38 | // Retrieves the build label (version string) from `archive_path` into |
| 39 | // `build_label`. |
| 40 | void ExtractBuildLabel(const std::string &archive_path, |
michajlo | 371a2e3 | 2019-05-23 13:14:39 -0700 | [diff] [blame] | 41 | std::string *build_label); |
michajlo | 97559ba | 2019-06-03 14:14:22 -0700 | [diff] [blame] | 42 | |
| 43 | // Returns the server jar path from the archive contents. |
| 44 | std::string GetServerJarPath(const std::vector<std::string> &archive_contents); |
| 45 | |
michajlo | 3d8925d | 2019-05-20 16:10:41 -0700 | [diff] [blame] | 46 | } // namespace blaze |
| 47 | |
| 48 | #endif // BAZEL_SRC_MAIN_CPP_ARCHIVE_UTILS_H_ |