mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
* edit.c: Use O_BINARY when opening files.
* editcmd.c: Likewise. From Alexander Varakin <avarakin00@hotmail.com>
This commit is contained in:
parent
966511399b
commit
e49a220a30
@ -1,3 +1,9 @@
|
|||||||
|
2002-09-23 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* edit.c: Use O_BINARY when opening files.
|
||||||
|
* editcmd.c: Likewise.
|
||||||
|
From Alexander Varakin <avarakin00@hotmail.com>
|
||||||
|
|
||||||
2002-09-20 Pavel Roskin <proski@gnu.org>
|
2002-09-20 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
* editwidget.c (edit_event): Add support for mouse wheel events.
|
* editwidget.c (edit_event): Add support for mouse wheel events.
|
||||||
|
@ -170,7 +170,7 @@ int init_dynamic_edit_buffers (WEdit * edit, const char *filename, const char *t
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (filename)
|
if (filename)
|
||||||
if ((file = mc_open (filename, O_RDONLY)) == -1) {
|
if ((file = mc_open (filename, O_RDONLY | O_BINARY)) == -1) {
|
||||||
/* The file-name is printed after the ':' */
|
/* The file-name is printed after the ':' */
|
||||||
edit_error_dialog (_ (" Error "), get_sys_error (catstrs (_ (" Failed trying to open file for reading: "), filename, " ", 0)));
|
edit_error_dialog (_ (" Error "), get_sys_error (catstrs (_ (" Failed trying to open file for reading: "), filename, " ", 0)));
|
||||||
return 1;
|
return 1;
|
||||||
@ -369,7 +369,7 @@ int edit_insert_file (WEdit * edit, const char *filename)
|
|||||||
int i, file, blocklen;
|
int i, file, blocklen;
|
||||||
long current = edit->curs1;
|
long current = edit->curs1;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
if ((file = mc_open (filename, O_RDONLY)) == -1)
|
if ((file = mc_open (filename, O_RDONLY | O_BINARY )) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
buf = malloc (TEMP_BUF_LEN);
|
buf = malloc (TEMP_BUF_LEN);
|
||||||
while ((blocklen = mc_read (file, (char *) buf, TEMP_BUF_LEN)) > 0) {
|
while ((blocklen = mc_read (file, (char *) buf, TEMP_BUF_LEN)) > 0) {
|
||||||
@ -404,7 +404,7 @@ static int check_file_access (WEdit *edit, const char *filename, struct stat *st
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Open the file, create it if needed */
|
/* Open the file, create it if needed */
|
||||||
if ((file = mc_open (filename, O_RDONLY | O_CREAT, 0666)) < 0) {
|
if ((file = mc_open (filename, O_RDONLY | O_CREAT | O_BINARY, 0666)) < 0) {
|
||||||
edit_error_dialog (_ (" Error "), get_sys_error (catstrs (_ (" Failed trying to open file for reading: "), filename, " ", 0)));
|
edit_error_dialog (_ (" Error "), get_sys_error (catstrs (_ (" Failed trying to open file for reading: "), filename, " ", 0)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ int edit_save_file (WEdit * edit, const char *filename)
|
|||||||
if (!*filename)
|
if (!*filename)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ((fd = mc_open (filename, O_WRONLY)) == -1) {
|
if ((fd = mc_open (filename, O_WRONLY | O_BINARY)) == -1) {
|
||||||
/*
|
/*
|
||||||
* The file does not exists yet, so no safe save or
|
* The file does not exists yet, so no safe save or
|
||||||
* backup are necessary.
|
* backup are necessary.
|
||||||
@ -237,7 +237,7 @@ int edit_save_file (WEdit * edit, const char *filename)
|
|||||||
mc_chmod (savename, edit->stat1.st_mode);
|
mc_chmod (savename, edit->stat1.st_mode);
|
||||||
mc_chown (savename, edit->stat1.st_uid, edit->stat1.st_gid);
|
mc_chown (savename, edit->stat1.st_uid, edit->stat1.st_gid);
|
||||||
|
|
||||||
if ((fd = mc_open (savename, O_CREAT | O_WRONLY | O_TRUNC | MY_O_TEXT,
|
if ((fd = mc_open (savename, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY ,
|
||||||
edit->stat1.st_mode)) == -1)
|
edit->stat1.st_mode)) == -1)
|
||||||
goto error_save;
|
goto error_save;
|
||||||
|
|
||||||
@ -428,7 +428,7 @@ int edit_save_as_cmd (WEdit * edit)
|
|||||||
if (strcmp(catstrs (edit->dir, edit->filename, 0), exp)) {
|
if (strcmp(catstrs (edit->dir, edit->filename, 0), exp)) {
|
||||||
int file;
|
int file;
|
||||||
different_filename = 1;
|
different_filename = 1;
|
||||||
if ((file = mc_open ((char *) exp, O_RDONLY)) != -1) { /* the file exists */
|
if ((file = mc_open ((char *) exp, O_RDONLY | O_BINARY)) != -1) { /* the file exists */
|
||||||
mc_close (file);
|
mc_close (file);
|
||||||
if (edit_query_dialog2 (_(" Warning "),
|
if (edit_query_dialog2 (_(" Warning "),
|
||||||
_(" A file already exists with this name. "),
|
_(" A file already exists with this name. "),
|
||||||
@ -1974,11 +1974,15 @@ unsigned char *edit_get_block (WEdit * edit, long start, long finish, int *l)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* save block, returns 1 on success */
|
/* save block, returns 1 on success */
|
||||||
int edit_save_block (WEdit * edit, const char *filename, long start, long finish)
|
int
|
||||||
|
edit_save_block (WEdit * edit, const char *filename, long start,
|
||||||
|
long finish)
|
||||||
{
|
{
|
||||||
int len, file;
|
int len, file;
|
||||||
|
|
||||||
if ((file = mc_open ((char *) filename, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) == -1)
|
if ((file =
|
||||||
|
mc_open ((char *) filename, O_CREAT | O_WRONLY | O_TRUNC,
|
||||||
|
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH | O_BINARY)) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (column_highlighting) {
|
if (column_highlighting) {
|
||||||
|
Loading…
Reference in New Issue
Block a user