If no valid packages was found in the input file we write an empty
header in the output file. This way we at least create a file. svn path=/trunk/; revision=28617
This commit is contained in:
parent
0ea6bce6af
commit
9a8e93d88b
20
editcap.c
20
editcap.c
|
@ -1230,7 +1230,6 @@ main(int argc, char *argv[])
|
|||
count++;
|
||||
}
|
||||
|
||||
g_free(filename);
|
||||
g_free(fprefix);
|
||||
g_free(fsuffix);
|
||||
|
||||
|
@ -1250,13 +1249,28 @@ main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (pdh && !wtap_dump_close(pdh, &err)) {
|
||||
if (!pdh) {
|
||||
/* No valid packages found, open the outfile so we can write an empty header */
|
||||
g_free (filename);
|
||||
filename = g_strdup(argv[optind+1]);
|
||||
|
||||
fprintf(stderr, "editcap: Error closing %s: %s\n", filename,
|
||||
pdh = wtap_dump_open(filename, out_file_type,
|
||||
out_frame_type, wtap_snapshot_length(wth), FALSE /* compressed */, &err);
|
||||
if (pdh == NULL) {
|
||||
fprintf(stderr, "editcap: Can't open or create %s: %s\n", filename,
|
||||
wtap_strerror(err));
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (!wtap_dump_close(pdh, &err)) {
|
||||
|
||||
fprintf(stderr, "editcap: Error writing to %s: %s\n", filename,
|
||||
wtap_strerror(err));
|
||||
exit(2);
|
||||
|
||||
}
|
||||
g_free(filename);
|
||||
}
|
||||
|
||||
if (dup_detect) {
|
||||
|
|
Loading…
Reference in New Issue