65 lines
1.6 KiB
Diff
65 lines
1.6 KiB
Diff
--- minicom-2.2/src/file.c.gotodir 2005-08-14 22:39:30.000000000 +0200
|
|
+++ minicom-2.2/src/file.c 2007-03-09 10:59:51.000000000 +0100
|
|
@@ -277,6 +277,8 @@
|
|
int initial_y = (76 - (WHAT_NR_OPTIONS * WHAT_WIDTH >= 76
|
|
? 74 : WHAT_NR_OPTIONS * WHAT_WIDTH)) / 2;
|
|
size_t i;
|
|
+ int rval;
|
|
+ char * new_prev_dir;
|
|
|
|
cur = 0;
|
|
ocur = 0;
|
|
@@ -290,11 +292,6 @@
|
|
dprev = -1;
|
|
tag_cnt = 0;
|
|
|
|
- /* got to do some error-checking here!!! Maybe use mcd(), too! */
|
|
- if (prev_dir != NULL)
|
|
- free(prev_dir);
|
|
- prev_dir = getcwd(NULL, BUFSIZ);
|
|
-
|
|
/*
|
|
* get last directory
|
|
*/
|
|
@@ -324,7 +321,30 @@
|
|
if (strlen(work_dir) > 1 && work_dir[strlen(work_dir) - 1] == '/')
|
|
work_dir[strlen(work_dir) - 1] = (char)0;
|
|
|
|
- chdir(work_dir);
|
|
+ /* get the current working directory, which will become the prev_dir, on success */
|
|
+ new_prev_dir = getcwd(NULL, BUFSIZ);
|
|
+ if (new_prev_dir == NULL) {
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ rval = chdir(work_dir);
|
|
+ if (rval == 0) {
|
|
+ /* was able to change to new working directory */
|
|
+ free(prev_dir);
|
|
+ prev_dir = new_prev_dir;
|
|
+ }
|
|
+ else {
|
|
+ /* Could not change to the new working directory */
|
|
+ mc_wbell();
|
|
+ werror(
|
|
+ _("Could not change to directory %s (%s)"),
|
|
+ work_dir,
|
|
+ strerror(errno));
|
|
+
|
|
+ /* restore the previous working directory */
|
|
+ free(work_dir);
|
|
+ work_dir = set_work_dir(new_prev_dir, strlen(new_prev_dir));
|
|
+ }
|
|
|
|
/* All right, draw the file directory! */
|
|
|
|
@@ -429,7 +449,7 @@
|
|
wredraw(dsub, 1);
|
|
}
|
|
|
|
- return 0;
|
|
+ return rval;
|
|
}
|
|
|
|
|