From DONOTREPLY at icculus.org Thu Apr 3 01:05:48 2008 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 3 Apr 2008 01:05:48 -0400 Subject: r940 - in trunk: . platform Message-ID: <20080403050548.26649.qmail@icculus.org> Author: icculus Date: 2008-04-03 01:05:48 -0400 (Thu, 03 Apr 2008) New Revision: 940 Modified: trunk/CHANGELOG.txt trunk/platform/posix.c Log: Fixed PHYSFS_openAppend() on Unix. Apparently O_APPEND doesn't behave like I thought it did...all these years. :/ Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2008-03-12 21:42:16 UTC (rev 939) +++ trunk/CHANGELOG.txt 2008-04-03 05:05:48 UTC (rev 940) @@ -2,6 +2,7 @@ * CHANGELOG. */ +04032008 - Fixed PHYSFS_openAppend() to work as documented on Unix. 03122008 - Fixed aliasing bug in Windows platform layer (thanks, Dennis!). 03102008 - Changed some text files from ISO-8859-1 to UTF-8. Replaced all the translations with UTF-8 encoded equivalents. Modified: trunk/platform/posix.c =================================================================== --- trunk/platform/posix.c 2008-03-12 21:42:16 UTC (rev 939) +++ trunk/platform/posix.c 2008-04-03 05:05:48 UTC (rev 940) @@ -236,13 +236,26 @@ static void *doOpen(const char *filename, int mode) { + const int appending = (mode & O_APPEND); int fd; int *retval; errno = 0; + /* O_APPEND doesn't actually behave as we'd like. */ + mode &= ~O_APPEND; + fd = open(filename, mode, S_IRUSR | S_IWUSR); BAIL_IF_MACRO(fd < 0, strerror(errno), NULL); + if (appending) + { + if (lseek(fd, 0, SEEK_END) < 0) + { + close(fd); + BAIL_MACRO(strerror(errno), NULL); + } /* if */ + } /* if */ + retval = (int *) allocator.Malloc(sizeof (int)); if (retval == NULL) { From DONOTREPLY at icculus.org Thu Apr 3 01:07:36 2008 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 3 Apr 2008 01:07:36 -0400 Subject: r941 - in branches/stable-1.0: . platform Message-ID: <20080403050736.30646.qmail@icculus.org> Author: icculus Date: 2008-04-03 01:07:35 -0400 (Thu, 03 Apr 2008) New Revision: 941 Modified: branches/stable-1.0/CHANGELOG branches/stable-1.0/platform/posix.c Log: Merged r939:940 from trunk: Fix PHYSFS_openAppend() on Unix. Modified: branches/stable-1.0/CHANGELOG =================================================================== --- branches/stable-1.0/CHANGELOG 2008-04-03 05:05:48 UTC (rev 940) +++ branches/stable-1.0/CHANGELOG 2008-04-03 05:07:35 UTC (rev 941) @@ -4,6 +4,7 @@ -- stuff in the stable-1.0 branch, backported from 2.0.0 dev branch, etc --- +04032008 - Fixed PHYSFS_openAppend() to work as documented on Unix. 03122008 - Removed a FIXME. 03112008 - Fixed wrong array index in Windows platform layer (thanks, James!). 03082008 - Fixed compiler warnings in Windows platform layer (thanks, Dennis!). Modified: branches/stable-1.0/platform/posix.c =================================================================== --- branches/stable-1.0/platform/posix.c 2008-04-03 05:05:48 UTC (rev 940) +++ branches/stable-1.0/platform/posix.c 2008-04-03 05:07:35 UTC (rev 941) @@ -344,13 +344,26 @@ static void *doOpen(const char *filename, int mode) { + const int appending = (mode & O_APPEND); int fd; int *retval; errno = 0; + /* O_APPEND doesn't actually behave as we'd like. */ + mode &= ~O_APPEND; + fd = open(filename, mode, S_IRUSR | S_IWUSR); BAIL_IF_MACRO(fd < 0, strerror(errno), NULL); + if (appending) + { + if (lseek(fd, 0, SEEK_END) < 0) + { + close(fd); + BAIL_MACRO(strerror(errno), NULL); + } /* if */ + } /* if */ + retval = (int *) malloc(sizeof (int)); if (retval == NULL) {