1 // Copyright 2022 Google LLC 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 // https://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 CONTRIB_BROTLI_UTILS_UTILS_BROTLI_H_ 16 #define CONTRIB_BROTLI_UTILS_UTILS_BROTLI_H_ 17 18 #include <cstdint> 19 #include <fstream> 20 #include <iostream> 21 #include <string> 22 #include <vector> 23 24 #include "absl/status/status.h" 25 #include "absl/status/statusor.h" 26 27 constexpr size_t kFileMaxSize = size_t{1} << 30; // 1GiB 28 29 std::streamsize GetStreamSize(std::ifstream& stream); 30 31 absl::StatusOr<std::vector<uint8_t>> ReadFile(const std::string& in_file_s); 32 33 absl::Status WriteFile(const std::string& out_file_s, 34 const std::vector<uint8_t>& out_buf); 35 36 #endif // CONTRIB_BROTLI_UTILS_UTILS_BROTLI_H_ 37