aboutsummaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>1999-06-12 09:10:20 +0000
committerGuy Harris <guy@alum.mit.edu>1999-06-12 09:10:20 +0000
commit18f922b46ea4a679f2ac208ca447e0cf14b8fd67 (patch)
treefc34de1c1755f99f0a17e108f604c206e0aa8be9 /util.c
parent054da75e88e1f723994813756f35aabbe9fab436 (diff)
Improve the alert boxes put up for file open/read/write errors. (Some
influence came from http://developer.apple.com/techpubs/mac/HIGuidelines/HIGuidelines-232.html which has a section on dialog box and alert box messages. However, we're largely dealing with technoids, not with The Rest Of Us, so I didn't go as far as one perhaps should.) Unfortunately, it looks like it's a bit more work to arrange that, if you give a bad file name to the "-r" flag, the dialog box pop up only *after* the main window pops up - it has the annoying habit of popping up *before* the main window pops up, and sometimes getting *obscured* by it, when I do that. The removal of the dialog box stuff from "load_cap_file()" was intended to facilitate that work. (It might also be nice if, when an open from the "File/Open" menu item fails, we keep the file selection box open, and give the user a chance to correct typos, choose another file name, etc.) svn path=/trunk/; revision=310
Diffstat (limited to 'util.c')
-rw-r--r--util.c71
1 files changed, 1 insertions, 70 deletions
diff --git a/util.c b/util.c
index 4c8277db3c..7a84868b08 100644
--- a/util.c
+++ b/util.c
@@ -1,7 +1,7 @@
/* util.c
* Utility routines
*
- * $Id: util.c,v 1.14 1999/04/06 16:24:49 gram Exp $
+ * $Id: util.c,v 1.15 1999/06/12 09:10:18 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -174,72 +174,3 @@ simple_dialog_cancel_cb(GtkWidget *w, gpointer win) {
*btn_mask = ESD_BTN_CANCEL;
gtk_widget_destroy(GTK_WIDGET(win));
}
-
-/* Tries to mv a file. If unsuccessful, tries to cp the file.
- * Returns 0 on failure to do either, 1 on success of either
- */
-int
-file_mv(char *from, char *to)
-{
-
-#define COPY_BUFFER_SIZE 8192
-
- int retval;
-
- /* try a hard link */
- retval = link(from, to);
-
- /* or try a copy */
- if (retval < 0) {
- retval = file_cp(from, to);
- if (!retval) {
- return 0;
- }
- }
-
- unlink(from);
- return 1;
-}
-
-/* Copies a file.
- * Returns 0 on failure to do either, 1 on success of either
- */
-int
-file_cp(char *from, char *to)
-{
-
-#define COPY_BUFFER_SIZE 8192
-
- int from_fd, to_fd, nread;
- char *buffer;
- gint dialogue_button = ESD_BTN_OK;
-
- buffer = g_malloc(COPY_BUFFER_SIZE);
-
- from_fd = open(from, O_RDONLY);
- if (from_fd < 0) {
- simple_dialog(ESD_TYPE_WARN, &dialogue_button,
- "Cannot open from-file for copying.");
- return 0;
- }
-
- to_fd = creat(to, 0644);
- if (to_fd < 0) {
- simple_dialog(ESD_TYPE_WARN, &dialogue_button,
- "Cannot open to-file for copying.");
- close(from_fd);
- return 0;
- }
-
- while( (nread = read(from_fd, buffer, COPY_BUFFER_SIZE)) > 0) {
- if (write(to_fd, buffer, nread) < nread) {
- close(from_fd);
- close(to_fd);
- return 0;
- }
- }
- close(from_fd);
- close(to_fd);
-
- return 1;
-}