Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
gzipfile.h
Go to the documentation of this file.
1// Copyright 2010-2025 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14#ifndef ORTOOLS_BASE_GZIPFILE_H_
15#define ORTOOLS_BASE_GZIPFILE_H_
16
17#include <zlib.h> // for Z_DEFAULT_COMPRESSION
18
19#include "absl/strings/string_view.h"
20
21class File;
22
23// Argument type used in interfaces that can optionally take ownership
24// of a passed in argument. If TAKE_OWNERSHIP is passed, the called
25// object takes ownership of the argument. Otherwise it does not.
27
28// Argument type used in interfaces that can optionally accept appended
29// compressed streams. If kConcatenateStreams is passed, the output will
30// include all streams. Otherwise only the first stream is output.
35
36// Return a read-only file that contains a uncompressed version of
37// another File.
38//
39// If "ownership == TAKE_OWNERSHIP", the file takes ownership of
40// "compressed_file". "compressed_file" will be deleted when the file is
41// closed.
42//
43// If "ownership == "DO_NOT_TAKE_OWNERSHIP", the file does not take
44// ownership of "compressed_file". The client must guarantee that
45// "compressed_file" remains live while the file is being accessed and
46// that operations on "compressed_file" do not interfere (e.g., move
47// the read pointer) with the file.
48//
49// If "appended_streams" == "kConcatenateStreams" decompression will process
50// and output each compressed stream present in the input.
51//
52// If "appended_streams" == "kIgnoreAppendedData" decompression will stop
53// after the first stream.
54//
55// The compressed file may be either a gzip format file, a zlib compressed
56// file, or a unix compress format file. The only difference between gzip
57// and zlib is whether the file has a gzip header and trailer. If the file
58// consists of multiple gzip files concatenated together, then we will
59// decompress them into a single concatenated output. This may seem weird
60// but that's what the gzip commandline tool does. If we didn't do this
61// we would silently truncate some input files upon decompression.
62// Otherwise we signal an error for any invalid data after the compressed
63// stream.
64File* GZipFileReader(absl::string_view name, File* compressed_file,
65 Ownership ownership, AppendedStreams appended_streams);
66// appended_streams defaults to kConcatenateStreams if not specified.
67inline File* GZipFileReader(absl::string_view name, File* compressed_file,
68 Ownership ownership) {
69 return GZipFileReader(name, compressed_file, ownership,
71}
72
73#endif // ORTOOLS_BASE_GZIPFILE_H_
Definition file.h:30
AppendedStreams
Definition gzipfile.h:31
Ownership
Definition gzipfile.h:26
@ TAKE_OWNERSHIP
Definition gzipfile.h:26
@ DO_NOT_TAKE_OWNERSHIP
Definition gzipfile.h:26
File * GZipFileReader(absl::string_view name, File *compressed_file, Ownership ownership, AppendedStreams appended_streams)
Definition gzipfile.cc:25