platform/posix.c
changeset 939 684c583cb586
parent 852 9467e96abdf1
child 1074 5ad7902d1ab9
equal deleted inserted replaced
938:ecbae90ae88d 939:684c583cb586
   234 } /* __PHYSFS_platformMkDir */
   234 } /* __PHYSFS_platformMkDir */
   235 
   235 
   236 
   236 
   237 static void *doOpen(const char *filename, int mode)
   237 static void *doOpen(const char *filename, int mode)
   238 {
   238 {
       
   239     const int appending = (mode & O_APPEND);
   239     int fd;
   240     int fd;
   240     int *retval;
   241     int *retval;
   241     errno = 0;
   242     errno = 0;
   242 
   243 
       
   244     /* O_APPEND doesn't actually behave as we'd like. */
       
   245     mode &= ~O_APPEND;
       
   246 
   243     fd = open(filename, mode, S_IRUSR | S_IWUSR);
   247     fd = open(filename, mode, S_IRUSR | S_IWUSR);
   244     BAIL_IF_MACRO(fd < 0, strerror(errno), NULL);
   248     BAIL_IF_MACRO(fd < 0, strerror(errno), NULL);
       
   249 
       
   250     if (appending)
       
   251     {
       
   252         if (lseek(fd, 0, SEEK_END) < 0)
       
   253         {
       
   254             close(fd);
       
   255             BAIL_MACRO(strerror(errno), NULL);
       
   256         } /* if */
       
   257     } /* if */
   245 
   258 
   246     retval = (int *) allocator.Malloc(sizeof (int));
   259     retval = (int *) allocator.Malloc(sizeof (int));
   247     if (retval == NULL)
   260     if (retval == NULL)
   248     {
   261     {
   249         close(fd);
   262         close(fd);