mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
* edit.c (check_file_access): Return 1 on all errors, document
this behavior. Set edit->delete_file to 1 for newly created files. (edit_open_file): Don't set edit->delete_file, it's now done in check_file_access(). Reported by Saso <saso@bojler.dhs.org>
This commit is contained in:
parent
8583c24ea4
commit
2ce74d23e1
@ -1,7 +1,16 @@
|
||||
2002-06-24 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* edit.c (check_file_access): Return 1 on all errors, document
|
||||
this behavior. Set edit->delete_file to 1 for newly created
|
||||
files.
|
||||
(edit_open_file): Don't set edit->delete_file, it's now done in
|
||||
check_file_access().
|
||||
Reported by Saso <saso@bojler.dhs.org>
|
||||
|
||||
2002-05-13 Andrew V. Samoilov <kai@cmail.ru>
|
||||
|
||||
* editcmd.c (edit_save_file): Call mc_chown () and mc_chmod ()
|
||||
before mc_open () to prevent hangs over ftpfs.
|
||||
* editcmd.c (edit_save_file): Call mc_chown() and mc_chmod()
|
||||
before mc_open() to prevent hangs over ftpfs.
|
||||
|
||||
* edit.h: Remove open, close, write, read and mkdir definitions.
|
||||
* edit.c: Use mc_open, mc_close, mc_write, mc_read, mc_rename,
|
||||
|
10
edit/edit.c
10
edit/edit.c
@ -398,6 +398,7 @@ int edit_insert_file (WEdit * edit, const char *filename)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Open file and create it if necessary. Return 0 for success, 1 for error. */
|
||||
static int check_file_access (WEdit *edit, const char *filename, struct stat *st)
|
||||
{
|
||||
int file;
|
||||
@ -417,7 +418,7 @@ static int check_file_access (WEdit *edit, const char *filename, struct stat *st
|
||||
/* Open the file, create it if needed */
|
||||
if ((file = mc_open (filename, O_RDONLY | O_CREAT, 0666)) < 0) {
|
||||
edit_error_dialog (_ (" Error "), get_sys_error (catstrs (_ (" Failed trying to open file for reading: "), filename, " ", 0)));
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* If the file has just been created, we don't have valid stat yet, so do it now */
|
||||
@ -428,6 +429,11 @@ static int check_file_access (WEdit *edit, const char *filename, struct stat *st
|
||||
}
|
||||
mc_close (file);
|
||||
|
||||
/* If it's a new file, delete it if it's not modified or saved */
|
||||
if (!stat_ok && st->st_size == 0) {
|
||||
edit->delete_file = 1;
|
||||
}
|
||||
|
||||
if (st->st_size >= SIZE_LIMIT) {
|
||||
/* The file-name is printed after the ':' */
|
||||
edit_error_dialog (_ (" Error "), catstrs (_ (" File is too large: "), \
|
||||
@ -447,8 +453,6 @@ int edit_open_file (WEdit * edit, const char *filename, const char *text, unsign
|
||||
} else {
|
||||
int r;
|
||||
r = check_file_access (edit, filename, &st);
|
||||
if (r == 2)
|
||||
return edit->delete_file = 1;
|
||||
if (r)
|
||||
return 1;
|
||||
edit->stat1 = st;
|
||||
|
Loading…
Reference in New Issue
Block a user