From 6e38159c2510c2066016feea205762ec0efc2f15 Mon Sep 17 00:00:00 2001 From: Ulf Lamping Date: Tue, 12 Apr 2005 21:12:19 +0000 Subject: add functions file_exists and file_identical to filesystem.c (coming from file.c) svn path=/trunk/; revision=14057 --- file.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'file.c') diff --git a/file.c b/file.c index 4beb1f2065..4fec53463f 100644 --- a/file.c +++ b/file.c @@ -3074,28 +3074,13 @@ cf_save(capture_file *cf, const char *fname, packet_range_t *range, guint save_f int err; gboolean do_copy; wtap_dumper *pdh; - struct stat infile, outfile; save_callback_args_t callback_args; cf_callback_invoke(cf_cb_file_safe_started, (gpointer) fname); - /* - * Check that the from file is not the same as to file - * We do it here so we catch all cases ... - * Unfortunately, the file requester gives us an absolute file - * name and the read file name may be relative (if supplied on - * the command line). From Joerg Mayer. - * - * This is a bit tricky on win32. The st_ino field is documented as: - * "The inode, and therefore st_ino, has no meaning in the FAT, ..." - * but it *is* set to zero if stat() returns without an error, - * so this is working, but maybe not quite the way expected. ULFL - */ - infile.st_ino = 1; /* These prevent us from getting equality */ - outfile.st_ino = 2; /* If one or other of the files is not accessible */ - stat(cf->filename, &infile); - stat(fname, &outfile); - if (infile.st_ino == outfile.st_ino) { + /* don't write over an existing file. */ + /* this should've been already checked by our caller, just to be sure... */ + if (file_exists(fname)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%sCapture file: \"%s\" already exists!%s\n\n" "Please choose a different filename.", -- cgit v1.2.3