-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce new struct for dos time stamps.
- Loading branch information
Showing
7 changed files
with
52 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
zip_source_stat.c -- get meta information from zip_source | ||
Copyright (C) 2009-2021 Dieter Baron and Thomas Klausner | ||
zip_source_get_dostime.c -- get modification time in DOS format from source | ||
Copyright (C) 2025 Dieter Baron and Thomas Klausner | ||
This file is part of libzip, a library to manipulate ZIP archives. | ||
The authors can be contacted at <[email protected]> | ||
|
@@ -34,13 +34,13 @@ | |
|
||
#include "zipint.h" | ||
|
||
|
||
/* Returns -1 on error, 0 on no dostime avaialable, 1 for dostime returned */ | ||
ZIP_EXTERN int | ||
zip_source_get_dos_time(zip_source_t *src, zip_uint16_t *dos_time, zip_uint16_t *dos_date) { | ||
zip_source_get_dos_time(zip_source_t *src, zip_dostime_t *dos_time) { | ||
if (src->source_closed) { | ||
return -1; | ||
} | ||
if (dos_time == NULL || dos_date == NULL) { | ||
if (dos_time == NULL) { | ||
zip_error_set(&src->error, ZIP_ER_INVAL, 0); | ||
return -1; | ||
} | ||
|
@@ -50,29 +50,23 @@ zip_source_get_dos_time(zip_source_t *src, zip_uint16_t *dos_time, zip_uint16_t | |
} | ||
|
||
if (zip_source_supports(src) & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_GET_DOS_TIME)) { | ||
zip_uint16_t data[2]; | ||
if (_zip_source_call(src, data, sizeof(data), ZIP_SOURCE_GET_DOS_TIME) < 0) { | ||
return -1; | ||
} | ||
*dos_time = data[0]; | ||
*dos_date = data[1]; | ||
return 0; | ||
} | ||
else { | ||
zip_stat_t st; | ||
zip_stat_init(&st); | ||
zip_int64_t n = _zip_source_call(src, dos_time, sizeof(*dos_time), ZIP_SOURCE_GET_DOS_TIME); | ||
|
||
if (zip_source_stat(src, &st) < 0) { | ||
if (n < 0) { | ||
return -1; | ||
} | ||
|
||
if (!(st.valid & ZIP_STAT_MTIME)) { | ||
*dos_time = 0; | ||
*dos_date = 0; | ||
else if (n == 0) { | ||
return 0; | ||
} | ||
else if (n == sizeof(*dos_time)) { | ||
return 1; | ||
} | ||
else { | ||
return _zip_u2d_time(st.mtime, dos_time, dos_date, &src->error); | ||
zip_error_set(&src->error, ZIP_ER_INTERNAL, 0); | ||
return -1; | ||
} | ||
} | ||
else { | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters