aboutsummaryrefslogtreecommitdiffstats
path: root/file.h
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2012-05-24 02:16:53 +0000
committerGuy Harris <guy@alum.mit.edu>2012-05-24 02:16:53 +0000
commitb655197a9dbfc5ea973ffa37b9642de0c1baeec1 (patch)
treee326402cc6f277500eb2b23fed4fa9269376c5ed /file.h
parent25e70c04d7a4ed27472948d5e0c7dd2e403adc97 (diff)
In the "Save As" and "Export Specified Packets" code path, do a "safe
save" if the destination file exists. Don't forbid overwriting an existing file in either of those cases (we still forbid overwriting the current capture file) - the GUI asks the user whether they want to do the overwrite, and allows them to cancel out of it - and don't remove the file before writing to it (doing so makes the save *un*safe). Attempt to do a save of an unedited temporary file by just moving the file on Windows as well as on UN*X - ws_rename() will remove the target if necessary on Windows (and won't do it as a separate operation before attempting the rename), so it behaves like ws_rename() on UN*X (which is just a wrapper around rename()). svn path=/trunk/; revision=42816
Diffstat (limited to 'file.h')
-rw-r--r--file.h29
1 files changed, 11 insertions, 18 deletions
diff --git a/file.h b/file.h
index ea6b908e90..c136e2fc2f 100644
--- a/file.h
+++ b/file.h
@@ -118,7 +118,7 @@ void cf_reload(capture_file *cf);
* Read all packets of a capture file into the internal structures.
*
* @param cf the capture file to be read
- * @param from_save reread asked from cf_save
+ * @param from_save reread asked from cf_save_packets
* @return one of cf_read_status_t
*/
cf_read_status_t cf_read(capture_file *cf, gboolean from_save);
@@ -196,21 +196,11 @@ cf_read_status_t cf_finish_tail(capture_file *cf, int *err);
gboolean cf_can_save_as(capture_file *cf);
/**
- * Save a capture file. Does a "safe save" if the specified
- * pathname already exists.
- *
- * @param cf the capture file to save to
- * @param fname the filename to save to
- * @param save_format the format of the file to save (libpcap, ...)
- * @param compressed whether to gzip compress the file
- * @return one of cf_status_t
- */
-cf_status_t cf_save(capture_file * cf, const char *fname, guint save_format, gboolean compressed);
-
-/**
* Save all packets in a capture file to a new file, and, if that succeeds,
- * make that file the current capture file. Fails if the specified
- * target file already exists.
+ * make that file the current capture file. If there's already a file with
+ * that name, do a "safe save", writing to a temporary file in the same
+ * directory and, if the write succeeds, renaming the new file on top of the
+ * old file, so that if the write fails, the old file is still intact.
*
* @param cf the capture file to save to
* @param fname the filename to save to
@@ -218,11 +208,14 @@ cf_status_t cf_save(capture_file * cf, const char *fname, guint save_format, gbo
* @param compressed whether to gzip compress the file
* @return one of cf_status_t
*/
-cf_status_t cf_save_as(capture_file * cf, const char *fname, guint save_format, gboolean compressed);
+cf_status_t cf_save_packets(capture_file * cf, const char *fname, guint save_format, gboolean compressed);
/**
- * Export some or all packets from a capture file to a new file. Fails if
- * the specified target file already exists.
+ * Export some or all packets from a capture file to a new file. If there's
+ * already a file with that name, do a "safe save", writing to a temporary
+ * file in the same directory and, if the write succeeds, renaming the new
+ * file on top of the old file, so that if the write fails, the old file is
+ * still intact.
*
* @param cf the capture file to write to
* @param fname the filename to write to