]> git.wh0rd.org Git - nano.git/commitdiff
Let's just copy joe word for word and just change the name to nano!!!!
authorChris Allegretta <chrisa@asty.org>
Sat, 9 Dec 2000 23:37:00 +0000 (23:37 +0000)
committerChris Allegretta <chrisa@asty.org>
Sat, 9 Dec 2000 23:37:00 +0000 (23:37 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@397 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

files.c

diff --git a/files.c b/files.c
index 5e2df38cbe71250d4444acae74e19eb6346d824e..09d623bcd82ffffae78fcaffe641d60ad06f4e0f 100644 (file)
--- a/files.c
+++ b/files.c
@@ -334,13 +334,18 @@ int write_file(char *name, int tmp)
        statement below (that starts "if ((!ISSET(FOLLOW_SYMLINKS)...")
        to reflect whether or not to link/unlink/rename the file */
     else if (ISSET(FOLLOW_SYMLINKS) || !S_ISLNK(lst.st_mode) || tmp) {
-
        /* Use O_EXCL if tmp == 1.  This is now copied from joe, because
-          wiggy says so *shrug* */
-       if (tmp)
-           fd = open(realname, O_WRONLY | O_CREAT | O_EXCL, (S_IRUSR|S_IWUSR));
-       else
-           fd = open(realname, O_WRONLY | O_CREAT | O_TRUNC, (S_IRUSR|S_IWUSR));
+          wiggy says so *shrug*.  We also put back the append check,
+          which we used to have, forever ago */
+       if (tmp) {
+           if ((fd = open(realname, (O_WRONLY|O_APPEND|O_NOFOLLOW))) != -1)
+               fd = open(realname, O_WRONLY | O_CREAT | O_EXCL, 
+                       (S_IRUSR|S_IWUSR));
+       } else {
+           if ((fd = open(realname, (O_WRONLY|O_APPEND))) != -1)
+               fd = open(realname, O_WRONLY | O_CREAT | O_TRUNC,
+                       (S_IRUSR|S_IWUSR));
+       }
 
        /* First, just give up if we couldn't even open the file */
        if (fd == -1) {