MCPcopy Index your code
hub / github.com/git/git / write_zip_entry

Function write_zip_entry

archive-zip.c:294–563  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292#define STREAM_BUFFER_SIZE (1024 * 16)
293
294static int write_zip_entry(struct archiver_args *args,
295 const struct object_id *oid,
296 const char *path, size_t pathlen,
297 unsigned int mode,
298 void *buffer, unsigned long size)
299{
300 struct zip_local_header header;
301 uintmax_t offset = zip_offset;
302 struct zip_extra_mtime extra;
303 struct zip64_extra extra64;
304 size_t header_extra_size = ZIP_EXTRA_MTIME_SIZE;
305 int need_zip64_extra = 0;
306 unsigned long attr2;
307 unsigned long compressed_size;
308 unsigned long crc;
309 enum zip_method method;
310 unsigned char *out;
311 void *deflated = NULL;
312 struct odb_read_stream *stream = NULL;
313 unsigned long flags = 0;
314 int is_binary = -1;
315 const char *path_without_prefix = path + args->baselen;
316 unsigned int creator_version = 0;
317 unsigned int version_needed = 10;
318 size_t zip_dir_extra_size = ZIP_EXTRA_MTIME_SIZE;
319 size_t zip64_dir_extra_payload_size = 0;
320
321 crc = crc32(0, NULL, 0);
322
323 if (!has_only_ascii(path)) {
324 if (is_utf8(path))
325 flags |= ZIP_UTF8;
326 else
327 warning(_("path is not valid UTF-8: %s"), path);
328 }
329
330 if (pathlen > 0xffff) {
331 return error(_("path too long (%d chars, SHA1: %s): %s"),
332 (int)pathlen, oid_to_hex(oid), path);
333 }
334
335 if (S_ISDIR(mode) || S_ISGITLINK(mode)) {
336 method = ZIP_METHOD_STORE;
337 attr2 = 16;
338 out = NULL;
339 compressed_size = 0;
340 } else if (S_ISREG(mode) || S_ISLNK(mode)) {
341 method = ZIP_METHOD_STORE;
342 attr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) :
343 (mode & 0111) ? ((mode) << 16) : 0;
344 if (S_ISLNK(mode) || (mode & 0111))
345 creator_version = 0x0317;
346 if (S_ISREG(mode) && args->compression_level != 0 && size > 0)
347 method = ZIP_METHOD_DEFLATE;
348
349 if (!buffer) {
350 stream = odb_read_stream_open(args->repo->objects, oid, NULL);
351 if (!stream)

Callers

nothing calls this directly

Calls 15

has_only_asciiFunction · 0.85
is_utf8Function · 0.85
warningFunction · 0.85
errorFunction · 0.85
oid_to_hexFunction · 0.85
odb_read_stream_openFunction · 0.85
entry_is_binaryFunction · 0.85
zlib_deflate_rawFunction · 0.85
copy_le16Function · 0.85
copy_le32Function · 0.85
set_zip_header_data_descFunction · 0.85
write_or_dieFunction · 0.85

Tested by

no test coverage detected