The problem with file.c still persists when I enter the filename from
the command line and then "save to" via the gui. This is caused by the
file requester always returning an absolute path. I've created a very
preliminary patch that resolves this. I don't know whether this has any
chance of working with Windows too, or if I should put a #ifdef Unix
around the new code. Please let me know how to improve this patch. I'm
also planning to handle the error case differently: Create a temporary
file, write to that and after that unlink the old one and rename the
temp file. As this replaces Ethereal's input file, I guess I have to
take care of that. Is this more than closing and reopening the file?
ciao
Jörg
Index: ethereal/file.c
===================================================================
RCS file: /cvsroot/ethereal/file.c,v
retrieving revision 1.282
diff -u -r1.282 file.c
--- file.c 2002/07/16 07:15:04 1.282
+++ file.c 2002/07/17 07:48:24
@@ -1725,6 +1725,9 @@
struct wtap_pkthdr hdr;
union wtap_pseudo_header pseudo_header;
guint8 pd[65536];
+#if 1
+ struct stat infile, outfile;
+#endif
name_ptr = get_basename(fname);
msg_len = strlen(name_ptr) + strlen(save_fmt) + 2;
@@ -1737,12 +1740,30 @@
* Check that the from file is not the same as to file
* We do it here so we catch all cases ...
*/
+#if 0
if (strcmp(cf->filename, fname) == 0) {
simple_dialog(ESD_TYPE_CRIT, NULL,
"Can't save over current capture file: %s!",
cf->filename);
goto fail;
}
+#else
+ /*
+ * Unfortunately, the file requester gives us an absolute file
+ * name and the read file name may be relative (if supplied on
+ * the command line).
+ */
+ infile.st_ino = 1;
+ outfile.st_ino = 2;
+ stat(cf->filename, &infile);
+ stat(fname, &outfile);
+ if (infile.st_ino == outfile.st_ino) {
+ simple_dialog(ESD_TYPE_CRIT, NULL,
+ "Can't save over current capture file: %s!",
+ cf->filename);
+ goto fail;
+ }
+#endif
if (!save_filtered && !save_marked && save_format == cf->cd_t) {
/* We're not filtering packets, and we're saving it in the format
--
Joerg Mayer <jmayer@xxxxxxxxx>
I found out that "pro" means "instead of" (as in proconsul). Now I know
what proactive means.