Ticket #2710 (can't open an edit zero-length file from VFS in mcedit)

fixed problem with zero-length files from VFS in mcedit.

    steps to reproduce the problem:
    1. touch test.txt
    2. tar cf test.tar test.txt
    3. place cursor on test.tar and press Enter to enter to the archive.
    4. place cursor on test.txt and press F4 to open file in editor.
    Result: file not opened.

(cherry picked from commit 88b3f840a7)

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
This commit is contained in:
Ilia Maslakov 2012-01-04 15:42:18 +04:00 committed by Andrew Borodin
parent 9aadcfe970
commit 7e8fee6486

View File

@ -482,7 +482,7 @@ edit_load_file (WEdit * edit)
if (*edit->filename)
{
edit->undo_stack_disable = 1;
if (edit_insert_file (edit, edit->filename) == 0)
if (edit_insert_file (edit, edit->filename) < 0)
{
edit_clean (edit);
return 1;
@ -2094,7 +2094,7 @@ edit_insert_file (WEdit * edit, const char *filename)
edit_error_dialog (_("Error"), errmsg);
g_free (errmsg);
g_free (p);
return 0;
return -1;
}
}
else
@ -2104,7 +2104,7 @@ edit_insert_file (WEdit * edit, const char *filename)
edit_error_dialog (_("Error"), errmsg);
g_free (errmsg);
g_free (p);
return 0;
return -1;
}
g_free (p);
}
@ -2116,7 +2116,7 @@ edit_insert_file (WEdit * edit, const char *filename)
char *buf;
file = mc_open (filename, O_RDONLY | O_BINARY);
if (file == -1)
return 0;
return -1;
buf = g_malloc0 (TEMP_BUF_LEN);
blocklen = mc_read (file, buf, sizeof (VERTICAL_MAGIC));
if (blocklen > 0)