Home | History | Annotate | Download | only in src

Lines Matching refs:FILE

5 // you may not use this file except in compliance with the License.
45 "File containing dictionary data (required)");
47 "Target file (default is stdin for encode, stdout for decode");
49 "Encoded delta file (default is stdout for encode, "
54 "Buffer size for reading input file");
65 "Maximum target file size allowed by decoder");
71 "encode or delta: create delta file from dictionary and target file\n"
72 "decode or patch: reconstruct target file from dictionary and delta file";
82 // will use the supplied options to carry out a file-based encode
89 // Determines the size of the file. The given file must be an input file
93 static bool FileSize(FILE* file, size_t* file_size);
95 // Opens a file for incremental reading. file_name is the name of the file
97 // use in log messages. If successful, returns true and sets *file to a
98 // valid input file, *buffer to a region of memory allocated using malloc()
100 // of the buffer, which will not be larger than the size of the file, and
105 FILE** file,
108 // Opens the dictionary file and reads it into a newly allocated buffer.
113 // Opens the input file (the delta or target file) for reading.
123 // Opens the output file (the target or delta file) for writing.
127 // Opens the output file (the target file) for comparison against the decoded
136 // Reads as much input data as possible from the input file
148 // do not match, or if end of file is reached before the expected number of
153 // Dictionary contents. The entire dictionary file will be read into memory.
159 // used in log messages such as "Error opening delta file..."
168 // stdio-style file handles for the input and output files and the dictionary.
169 // When encoding, input_file_ is the target file and output_file_ is the delta
170 // file; when decoding, the reverse is true. The dictionary is always read
171 // from a file rather than from standard input.
172 FILE* input_file_;
173 FILE* output_file_;
175 // A memory buffer used to load the input file into memory. If the input
176 // comes from stdin because no input file was specified, then the size of
178 // If the input comes from a file, then the buffer will be allocated to match
179 // the file size, if possible. However, the buffer will not exceed
183 // A memory buffer used to load the output file into memory for comparison
209 bool VCDiffFileBasedCoder::FileSize(FILE* file, size_t* file_size) {
210 long initial_position = ftell(file);
211 if (fseek(file, 0, SEEK_END) != 0) {
214 *file_size = static_cast<size_t>(ftell(file));
215 if (fseek(file, initial_position, SEEK_SET) != 0) {
224 FILE* dictionary_file = fopen(FLAGS_dictionary.c_str(), "rb");
226 std::cerr << "Error opening dictionary file '" << FLAGS_dictionary
232 std::cerr << "Error finding size of dictionary file '" << FLAGS_dictionary
240 std::cerr << "Unable to read dictionary file '" << FLAGS_dictionary
253 FILE** file,
257 if (!*file && file_name.empty()) {
261 *file = stdin;
264 if (!*file) {
265 *file = fopen(file_name.c_str(), "rb");
266 if (!*file) {
267 std::cerr << "Error opening " << file_type << " file '"
273 if (!FileSize(*file, &file_size)) {
274 std::cerr << "Error finding size of " << file_type << " file '"
280 // Allocate just enough memory to store the entire file
288 // Opens the output file for streamed read operations using the
302 std::cerr << "Error opening " << output_file_type_ << " file '"
312 // Read from file or stdin
315 std::cerr << "Error reading from " << input_file_type_ << " file '"
326 // to the output file or to stdout.
330 << output_file_type_ << " file '" << output_file_name_
342 // the output file.
351 std::cerr << "Error reading from " << output_file_type_ << " file '"
356 std::cerr << "Decoded target is longer than original target file"
361 std::cerr << "Original target file does not match decoded target"
487 << " may not be a valid VCDIFF delta file" << std::endl;
551 << " may not be a valid VCDIFF delta file" << std::endl;
560 std::cerr << "Decoded target is shorter than original target file"
565 std::cerr << "Error reading end-of-file indicator from target file"
593 << ": Must specify --dictionary <file-name>" << std::endl;
623 // and --delta file arguments must be specified, rather than using stdin
624 // or stdout. It produces a delta file just as for "vcdiff encode".
627 << " test: Must specify both --target <file-name>"
628 " and --delta <file-name>" << std::endl;