src/file/SDL_rwops.c
changeset 1453 2eb75f8a32ca
parent 1447 515df0086eb7
child 1455 f487bb150acc
     1.1 --- a/src/file/SDL_rwops.c	Mon Feb 27 18:58:12 2006 +0000
     1.2 +++ b/src/file/SDL_rwops.c	Mon Feb 27 19:19:22 2006 +0000
     1.3 @@ -59,8 +59,8 @@
     1.4  	must_exist = ( SDL_strchr(mode,'r') != NULL ) ? OPEN_EXISTING : 0;
     1.5  	truncate   = ( SDL_strchr(mode,'w') != NULL ) ? CREATE_ALWAYS : 0;
     1.6  	r_right    = ( SDL_strchr(mode,'+') != NULL || must_exist ) ? GENERIC_READ : 0;
     1.7 -	a_mode     = ( SDL_strchr(mode,'a') != NULL );
     1.8 -	w_right    = ( a_mode || SDL_strchr(mode,'w') || truncate ) ? GENERIC_WRITE : 0;
     1.9 +	a_mode     = ( SDL_strchr(mode,'a') != NULL ) ? OPEN_ALWAYS : 0;
    1.10 +	w_right    = ( a_mode || SDL_strchr(mode,'+') || truncate ) ? GENERIC_WRITE : 0;
    1.11  
    1.12  	if (!r_right && !w_right) /* inconsistent mode */
    1.13  		return -1; /* failed (invalid call)*/
    1.14 @@ -69,7 +69,7 @@
    1.15  	old_error_mode = SetErrorMode(SEM_NOOPENFILEERRORBOX|SEM_FAILCRITICALERRORS);	
    1.16  	
    1.17  	h = CreateFile(filename, (w_right|r_right), (w_right)? 0 : FILE_SHARE_READ, 
    1.18 -		           NULL, (must_exist|truncate), FILE_ATTRIBUTE_NORMAL,NULL);
    1.19 +		           NULL, (must_exist|truncate|a_mode), FILE_ATTRIBUTE_NORMAL,NULL);
    1.20  	
    1.21  	/* restore old behaviour */
    1.22  	SetErrorMode(old_error_mode);
    1.23 @@ -338,6 +338,8 @@
    1.24  
    1.25  #ifdef __WIN32__
    1.26  	rwops = SDL_AllocRW();
    1.27 +	if (!rwops)
    1.28 +		return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
    1.29  	rwops->hidden.win32io.h = INVALID_HANDLE_VALUE;
    1.30  	if (win32_file_open(rwops,file,mode)) {
    1.31  		SDL_FreeRW(rwops);