Re-add O_CREAT since I botched the merge, some indentation fixes also, by DB
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1193 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
0547eb36c4
commit
b275175bef
16
files.c
16
files.c
|
@ -1257,7 +1257,7 @@ int write_file(char *name, int tmp, int append, int nonamechange)
|
|||
/* Don't follow symlink. Create new file. */
|
||||
else {
|
||||
buf = charalloc(strlen(realname) + 8);
|
||||
strncpy(buf, realname, strlen(realname)+1);
|
||||
strcpy(buf, realname);
|
||||
strcat(buf, ".XXXXXX");
|
||||
if ((fd = mkstemp(buf)) == -1) {
|
||||
if (ISSET(TEMP_OPT)) {
|
||||
|
@ -1272,12 +1272,7 @@ int write_file(char *name, int tmp, int append, int nonamechange)
|
|||
|
||||
dump_buffer(fileage);
|
||||
|
||||
if (append == 1) {
|
||||
f = fdopen(fd, "ab");
|
||||
} else {
|
||||
f = fdopen(fd, "wb");
|
||||
}
|
||||
|
||||
f = fdopen(fd, append==1 ? "ab" : "wb");
|
||||
if (!f) {
|
||||
statusbar(_("Could not open file for writing: %s"),
|
||||
strerror(errno));
|
||||
|
@ -1297,11 +1292,12 @@ int write_file(char *name, int tmp, int append, int nonamechange)
|
|||
strerror(errno));
|
||||
fclose(f);
|
||||
return -1;
|
||||
} else {
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else
|
||||
fprintf(stderr, _("Wrote >%s\n"), fileptr->data);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
if (ISSET(DOS_FILE) || ISSET(MAC_FILE))
|
||||
putc('\r', f);
|
||||
|
@ -1372,7 +1368,7 @@ int write_file(char *name, int tmp, int append, int nonamechange)
|
|||
close(fd_dest);
|
||||
return -1;
|
||||
}
|
||||
if ((fd_source = open(realname, O_RDONLY)) == -1) {
|
||||
if ((fd_source = open(realname, O_RDONLY | O_CREAT)) == -1) {
|
||||
statusbar(_("Could not open %s for prepend: %s"), realname, strerror(errno));
|
||||
fclose(f_dest);
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue