diff options
| author | 2026-09-08 01:12:20 +0400 | |
|---|---|---|
| committer | 2026-09-29 17:00:18 +0200 | |
| commit | fba74cf8bd9696b9b7f42a8cbb9e16dd065b0a83 (patch) | |
| tree | 89ebb7b5a8ca5dfaa2e0e57887ae846ac147712a /tools/plistutil.c | |
| parent | 2b0754dee5c5b9c4b3d5114359436e7b737a57f4 (diff) | |
| download | libplist-fba74cf8bd9696b9b7f42a8cbb9e16dd065b0a83.tar.gz libplist-fba74cf8bd9696b9b7f42a8cbb9e16dd065b0a83.tar.bz2 | |
plistutil: preserve binary data on Windows standard streams
Diffstat (limited to 'tools/plistutil.c')
| -rw-r--r-- | tools/plistutil.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tools/plistutil.c b/tools/plistutil.c index e2ea286..8a341d0 100644 --- a/tools/plistutil.c +++ b/tools/plistutil.c @@ -33,6 +33,10 @@ #include <sys/stat.h> #include <getopt.h> #include <errno.h> +#ifdef _WIN32 +#include <fcntl.h> +#include <io.h> +#endif #ifndef _MSC_VER #include <unistd.h> #endif @@ -266,6 +270,9 @@ int main(int argc, char *argv[]) if (!options->in_file || !strcmp(options->in_file, "-")) { +#ifdef _WIN32 + _setmode(_fileno(stdin), _O_BINARY); +#endif read_size = 0; plist_entire = malloc(sizeof(char) * read_capacity); if(plist_entire == NULL) @@ -475,8 +482,12 @@ int main(int argc, char *argv[]) fclose(oplist); } // if no output file specified, write to stdout - else + else { +#ifdef _WIN32 + _setmode(_fileno(stdout), _O_BINARY); +#endif fwrite(plist_out, size, sizeof(char), stdout); + } free(plist_out); } |
