mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-12 14:29:41 +03:00
Ticket #1617: Current editing position of files don't save.
Fixed bug. Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
07b9ae3a26
commit
1b91f29cbb
12
src/util.c
12
src/util.c
@ -1404,13 +1404,11 @@ save_file_position (const char *filename, long line, long column)
|
|||||||
char *fn;
|
char *fn;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
|
|
||||||
fn = g_build_filename (home_dir, MC_USERCONF_DIR, MC_FILEPOS_FILE, NULL);
|
fn = g_build_filename (home_dir, MC_USERCONF_DIR, MC_FILEPOS_FILE, NULL);
|
||||||
if (fn == NULL)
|
if (fn == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (! mc_util_make_backup_if_possible (fn, ".tmp"))
|
mc_util_make_backup_if_possible (fn, ".tmp");
|
||||||
return;
|
|
||||||
|
|
||||||
/* open file */
|
/* open file */
|
||||||
f = fopen (fn, "a");
|
f = fopen (fn, "a");
|
||||||
@ -1424,13 +1422,14 @@ save_file_position (const char *filename, long line, long column)
|
|||||||
if (fprintf (f, "%s %ld;%ld\n", filename, line, column) < 0) {
|
if (fprintf (f, "%s %ld;%ld\n", filename, line, column) < 0) {
|
||||||
fclose (f);
|
fclose (f);
|
||||||
mc_util_restore_from_backup_if_possible (fn, ".tmp");
|
mc_util_restore_from_backup_if_possible (fn, ".tmp");
|
||||||
|
g_free (fn);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else
|
|
||||||
fclose (f);
|
|
||||||
|
|
||||||
|
fclose (f);
|
||||||
mc_util_unlink_backup_if_possible (fn, ".tmp");
|
mc_util_unlink_backup_if_possible (fn, ".tmp");
|
||||||
g_free (fn);
|
g_free (fn);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern const char *
|
extern const char *
|
||||||
@ -1486,7 +1485,6 @@ mc_util_make_backup_if_possible (const char *file_name, const char *backup_suffi
|
|||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
char *backup_path;
|
char *backup_path;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
if (!exist_file (file_name))
|
if (!exist_file (file_name))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user