Similar to other commands, such as tar.
Dump manifest file at _PATH_ in text format to standard output. This is
only useful when debugging ccache and its behavior.
+ A path of `-` means to read from standard input.
*`--dump-result`* _PATH_::
Dump result file at _PATH_ in text format to standard output. This is only
useful when debugging ccache and its behavior.
+ A path of `-` means to read from standard input.
*`--extract-result`* _PATH_::
std::unique_ptr<ManifestData>
read_manifest(const std::string& path, FILE* dump_stream = nullptr)
{
- File file(path, "rb");
- if (!file) {
- return {};
+ FILE* file_stream;
+ File file;
+ if (path == "-") {
+ file_stream = stdin;
+ } else {
+ file = File(path, "rb");
+ if (!file) {
+ return {};
+ }
+ file_stream = file.get();
}
- CacheEntryReader reader(file.get(), Manifest::k_magic, Manifest::k_version);
+ CacheEntryReader reader(file_stream, Manifest::k_magic, Manifest::k_version);
if (dump_stream) {
reader.dump_header(dump_stream);
bool
Reader::read_result(Consumer& consumer)
{
- File file(m_result_path, "rb");
- if (!file) {
- // Cache miss.
- return false;
+ FILE* file_stream;
+ File file;
+ if (m_result_path == "-") {
+ file_stream = stdin;
+ } else {
+ file = File(m_result_path, "rb");
+ if (!file) {
+ // Cache miss.
+ return false;
+ }
+ file_stream = file.get();
}
- CacheEntryReader cache_entry_reader(file.get(), k_magic, k_version);
+ CacheEntryReader cache_entry_reader(file_stream, k_magic, k_version);
consumer.on_header(cache_entry_reader);