diff options
author | josh.macdonald <jmacd@users.noreply.github.com> | 2007-12-02 01:22:59 +0000 |
---|---|---|
committer | josh.macdonald <jmacd@users.noreply.github.com> | 2007-12-02 01:22:59 +0000 |
commit | ebd9ec25c66d21dfa5c0b1f23879f59f223fe724 (patch) | |
tree | eb7822a5ee2eba59405b97e6045380032ff6bfcb /xdelta3/xdelta3-main.h | |
parent | 22ea0b5cd1763b3ba5e8c8580bcee9f96e915341 (diff) |
Working on the test failure in dbeug mode, partial recode test written.
Diffstat (limited to 'xdelta3/xdelta3-main.h')
-rw-r--r-- | xdelta3/xdelta3-main.h | 62 |
1 files changed, 41 insertions, 21 deletions
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h index 756ec49..d8d9fd5 100644 --- a/xdelta3/xdelta3-main.h +++ b/xdelta3/xdelta3-main.h | |||
@@ -662,7 +662,8 @@ main_atou (const char* arg, usize_t *xo, usize_t low, | |||
662 | #define XOPEN_MODE (xfile->mode == XO_READ ? 0 : 0666) | 662 | #define XOPEN_MODE (xfile->mode == XO_READ ? 0 : 0666) |
663 | 663 | ||
664 | #define XF_ERROR(op, name, ret) \ | 664 | #define XF_ERROR(op, name, ret) \ |
665 | XPR(NT "file %s failed: %s: %s: %s\n", (op), XOPEN_OPNAME, (name), xd3_mainerror (ret)) | 665 | do { if (!option_quiet) { XPR(NT "file %s failed: %s: %s: %s\n", (op), \ |
666 | XOPEN_OPNAME, (name), xd3_mainerror (ret)); } } while (0) | ||
666 | 667 | ||
667 | #if XD3_STDIO | 668 | #if XD3_STDIO |
668 | #define XFNO(f) fileno(f->file) | 669 | #define XFNO(f) fileno(f->file) |
@@ -811,23 +812,32 @@ main_file_stat (main_file *xfile, xoff_t *size, int err_ifnoseek) | |||
811 | int ret = 0; | 812 | int ret = 0; |
812 | #if XD3_WIN32 | 813 | #if XD3_WIN32 |
813 | LARGE_INTEGER li; | 814 | LARGE_INTEGER li; |
814 | if (GetFileSizeEx(xfile->file, &li) == 0) { | 815 | if (GetFileSizeEx(xfile->file, &li) == 0) |
815 | ret = get_errno (); | 816 | { |
816 | } else { | 817 | ret = get_errno (); |
818 | } | ||
819 | else | ||
820 | { | ||
817 | *size = li.QuadPart; | 821 | *size = li.QuadPart; |
818 | } | 822 | } |
819 | #else | 823 | #else |
820 | struct stat sbuf; | 824 | struct stat sbuf; |
821 | if (fstat (XFNO (xfile), & sbuf) < 0) | 825 | if (fstat (XFNO (xfile), & sbuf) < 0) |
822 | { | 826 | { |
823 | ret = get_errno (); | 827 | ret = get_errno (); |
824 | if (err_ifnoseek) { XF_ERROR ("stat", xfile->filename, ret); } | 828 | if (err_ifnoseek) |
829 | { | ||
830 | XF_ERROR ("stat", xfile->filename, ret); | ||
831 | } | ||
825 | return ret; | 832 | return ret; |
826 | } | 833 | } |
827 | 834 | ||
828 | if (! S_ISREG (sbuf.st_mode)) | 835 | if (! S_ISREG (sbuf.st_mode)) |
829 | { | 836 | { |
830 | if (err_ifnoseek) { XPR(NT "source file must be seekable: %s\n", xfile->filename); } | 837 | if (err_ifnoseek) |
838 | { | ||
839 | XPR(NT "source file must be seekable: %s\n", xfile->filename); | ||
840 | } | ||
831 | return ESPIPE; | 841 | return ESPIPE; |
832 | } | 842 | } |
833 | (*size) = sbuf.st_size; | 843 | (*size) = sbuf.st_size; |
@@ -2224,7 +2234,11 @@ main_open_output (xd3_stream *stream, main_file *ofile) | |||
2224 | /* Stat the file to check for overwrite. */ | 2234 | /* Stat the file to check for overwrite. */ |
2225 | if (option_force == 0 && main_file_exists (ofile)) | 2235 | if (option_force == 0 && main_file_exists (ofile)) |
2226 | { | 2236 | { |
2227 | XPR(NT "to overwrite output file specify -f: %s\n", ofile->filename); | 2237 | if (!option_quiet) |
2238 | { | ||
2239 | XPR(NT "to overwrite output file specify -f: %s\n", | ||
2240 | ofile->filename); | ||
2241 | } | ||
2228 | return EEXIST; | 2242 | return EEXIST; |
2229 | } | 2243 | } |
2230 | 2244 | ||
@@ -2879,12 +2893,15 @@ main_input (xd3_cmd cmd, | |||
2879 | { | 2893 | { |
2880 | if (option_no_output == 0) | 2894 | if (option_no_output == 0) |
2881 | { | 2895 | { |
2882 | /* Defer opening the output file until the stream produces its first | 2896 | /* Defer opening the output file until the stream produces its |
2883 | * output for both encoder and decoder, this way we delay long enough for | 2897 | * first output for both encoder and decoder, this way we |
2884 | * the decoder to receive the application header. (Or longer if there are | 2898 | * delay long enough for the decoder to receive the |
2885 | * skipped windows, but I can't think of any reason not to delay open.) */ | 2899 | * application header. (Or longer if there are skipped |
2886 | 2900 | * windows, but I can't think of any reason not to delay | |
2887 | if (! main_file_isopen (ofile) && (ret = main_open_output (& stream, ofile)) != 0) | 2901 | * open.) */ |
2902 | |||
2903 | if (! main_file_isopen (ofile) && | ||
2904 | (ret = main_open_output (& stream, ofile)) != 0) | ||
2888 | { | 2905 | { |
2889 | return EXIT_FAILURE; | 2906 | return EXIT_FAILURE; |
2890 | } | 2907 | } |
@@ -2992,7 +3009,8 @@ done: | |||
2992 | return EXIT_FAILURE; | 3009 | return EXIT_FAILURE; |
2993 | } | 3010 | } |
2994 | 3011 | ||
2995 | /* Have to close the output before calling main_external_compression_finish, or else it hangs. */ | 3012 | /* Have to close the output before calling |
3013 | * main_external_compression_finish, or else it hangs. */ | ||
2996 | if (main_file_close (ofile) != 0) | 3014 | if (main_file_close (ofile) != 0) |
2997 | { | 3015 | { |
2998 | return EXIT_FAILURE; | 3016 | return EXIT_FAILURE; |
@@ -3297,8 +3315,9 @@ main (int argc, char **argv) | |||
3297 | else if (strcmp (my_optstr, "recode") == 0) { cmd = CMD_RECODE; } | 3315 | else if (strcmp (my_optstr, "recode") == 0) { cmd = CMD_RECODE; } |
3298 | #endif | 3316 | #endif |
3299 | 3317 | ||
3300 | /* If no option was found and still no command, let the default command be | 3318 | /* If no option was found and still no command, let the default |
3301 | * encode. The remaining args are treated as filenames. */ | 3319 | * command be encode. The remaining args are treated as |
3320 | * filenames. */ | ||
3302 | if (cmd == CMD_NONE) | 3321 | if (cmd == CMD_NONE) |
3303 | { | 3322 | { |
3304 | cmd = CMD_DEFAULT; | 3323 | cmd = CMD_DEFAULT; |
@@ -3440,8 +3459,8 @@ main (int argc, char **argv) | |||
3440 | sfile.flags = RD_FIRST; | 3459 | sfile.flags = RD_FIRST; |
3441 | sfile.filename = option_source_filename; | 3460 | sfile.filename = option_source_filename; |
3442 | 3461 | ||
3443 | /* The infile takes the next argument, if there is one. But if not, infile is set to | 3462 | /* The infile takes the next argument, if there is one. But if not, infile |
3444 | * stdin. */ | 3463 | * is set to stdin. */ |
3445 | if (argc > 0) | 3464 | if (argc > 0) |
3446 | { | 3465 | { |
3447 | ifile.filename = argv[0]; | 3466 | ifile.filename = argv[0]; |
@@ -3456,8 +3475,9 @@ main (int argc, char **argv) | |||
3456 | XSTDIN_XF (& ifile); | 3475 | XSTDIN_XF (& ifile); |
3457 | } | 3476 | } |
3458 | 3477 | ||
3459 | /* The ofile takes the following argument, if there is one. But if not, it is left NULL | 3478 | /* The ofile takes the following argument, if there is one. But if not, it |
3460 | * until the application header is processed. It will be set in main_open_output. */ | 3479 | * is left NULL until the application header is processed. It will be set |
3480 | * in main_open_output. */ | ||
3461 | if (argc > 1) | 3481 | if (argc > 1) |
3462 | { | 3482 | { |
3463 | /* Check for conflicting arguments. */ | 3483 | /* Check for conflicting arguments. */ |