• Home
  • Raw
  • Download

Lines Matching refs:context

48 static int SDLCALL win32_file_open(SDL_RWops *context, const char *filename, const char *mode)  in win32_file_open()  argument
58 if (!context) in win32_file_open()
61 context->hidden.win32io.h = INVALID_HANDLE_VALUE; /* mark this as unusable */ in win32_file_open()
62 context->hidden.win32io.buffer.data = NULL; in win32_file_open()
63 context->hidden.win32io.buffer.size = 0; in win32_file_open()
64 context->hidden.win32io.buffer.left = 0; in win32_file_open()
82 context->hidden.win32io.buffer.data = (char *)SDL_malloc(READAHEAD_BUFFER_SIZE); in win32_file_open()
83 if (!context->hidden.win32io.buffer.data) { in win32_file_open()
95 SDL_free(context->hidden.win32io.buffer.data); in win32_file_open()
96 context->hidden.win32io.buffer.data = NULL; in win32_file_open()
128 SDL_free(context->hidden.win32io.buffer.data); in win32_file_open()
129 context->hidden.win32io.buffer.data = NULL; in win32_file_open()
155 SDL_free(context->hidden.win32io.buffer.data); in win32_file_open()
156 context->hidden.win32io.buffer.data = NULL; in win32_file_open()
176 SDL_free(context->hidden.win32io.buffer.data); in win32_file_open()
177 context->hidden.win32io.buffer.data = NULL; in win32_file_open()
181 context->hidden.win32io.h = h; in win32_file_open()
182 context->hidden.win32io.append = a_mode; in win32_file_open()
186 static int SDLCALL win32_file_seek(SDL_RWops *context, int offset, int whence) in win32_file_seek() argument
191 if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE) { in win32_file_seek()
197 if (whence == RW_SEEK_CUR && context->hidden.win32io.buffer.left) { in win32_file_seek()
198 offset -= context->hidden.win32io.buffer.left; in win32_file_seek()
200 context->hidden.win32io.buffer.left = 0; in win32_file_seek()
214 file_pos = SetFilePointer(context->hidden.win32io.h,offset,NULL,win32whence); in win32_file_seek()
222 static int SDLCALL win32_file_read(SDL_RWops *context, void *ptr, int size, int maxnum) in win32_file_read() argument
231 if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE || total_need<=0 || !size) in win32_file_read()
234 if (context->hidden.win32io.buffer.left > 0) { in win32_file_read()
235 void *data = (char *)context->hidden.win32io.buffer.data + in win32_file_read()
236 context->hidden.win32io.buffer.size - in win32_file_read()
237 context->hidden.win32io.buffer.left; in win32_file_read()
238 read_ahead = SDL_min(total_need, context->hidden.win32io.buffer.left); in win32_file_read()
240 context->hidden.win32io.buffer.left -= read_ahead; in win32_file_read()
251 …if (!ReadFile(context->hidden.win32io.h,context->hidden.win32io.buffer.data,READAHEAD_BUFFER_SIZE,… in win32_file_read()
256 SDL_memcpy(ptr, context->hidden.win32io.buffer.data, read_ahead); in win32_file_read()
257 context->hidden.win32io.buffer.size = byte_read; in win32_file_read()
258 context->hidden.win32io.buffer.left = byte_read-read_ahead; in win32_file_read()
261 if (!ReadFile(context->hidden.win32io.h,ptr,total_need,&byte_read,NULL)) { in win32_file_read()
269 static int SDLCALL win32_file_write(SDL_RWops *context, const void *ptr, int size, int num) in win32_file_write() argument
277 if (!context || context->hidden.win32io.h==INVALID_HANDLE_VALUE || total_bytes<=0 || !size) in win32_file_write()
280 if (context->hidden.win32io.buffer.left) { in win32_file_write()
281 SetFilePointer(context->hidden.win32io.h,-context->hidden.win32io.buffer.left,NULL,FILE_CURRENT); in win32_file_write()
282 context->hidden.win32io.buffer.left = 0; in win32_file_write()
286 if (context->hidden.win32io.append) { in win32_file_write()
287 if ( SetFilePointer(context->hidden.win32io.h,0L,NULL,FILE_END) == INVALID_SET_FILE_POINTER ) { in win32_file_write()
293 if (!WriteFile(context->hidden.win32io.h,ptr,total_bytes,&byte_written,NULL)) { in win32_file_write()
301 static int SDLCALL win32_file_close(SDL_RWops *context) in win32_file_close() argument
304 if ( context ) { in win32_file_close()
305 if (context->hidden.win32io.h != INVALID_HANDLE_VALUE) { in win32_file_close()
306 CloseHandle(context->hidden.win32io.h); in win32_file_close()
307 context->hidden.win32io.h = INVALID_HANDLE_VALUE; /* to be sure */ in win32_file_close()
309 if (context->hidden.win32io.buffer.data) { in win32_file_close()
310 SDL_free(context->hidden.win32io.buffer.data); in win32_file_close()
311 context->hidden.win32io.buffer.data = NULL; in win32_file_close()
313 SDL_FreeRW(context); in win32_file_close()
323 static int SDLCALL stdio_seek(SDL_RWops *context, int offset, int whence) in stdio_seek() argument
325 if ( fseek(context->hidden.stdio.fp, offset, whence) == 0 ) { in stdio_seek()
326 return(ftell(context->hidden.stdio.fp)); in stdio_seek()
332 static int SDLCALL stdio_read(SDL_RWops *context, void *ptr, int size, int maxnum) in stdio_read() argument
336 nread = fread(ptr, size, maxnum, context->hidden.stdio.fp); in stdio_read()
337 if ( nread == 0 && ferror(context->hidden.stdio.fp) ) { in stdio_read()
342 static int SDLCALL stdio_write(SDL_RWops *context, const void *ptr, int size, int num) in stdio_write() argument
346 nwrote = fwrite(ptr, size, num, context->hidden.stdio.fp); in stdio_write()
347 if ( nwrote == 0 && ferror(context->hidden.stdio.fp) ) { in stdio_write()
352 static int SDLCALL stdio_close(SDL_RWops *context) in stdio_close() argument
354 if ( context ) { in stdio_close()
355 if ( context->hidden.stdio.autoclose ) { in stdio_close()
357 fclose(context->hidden.stdio.fp); in stdio_close()
359 SDL_FreeRW(context); in stdio_close()
367 static int SDLCALL mem_seek(SDL_RWops *context, int offset, int whence) in mem_seek() argument
373 newpos = context->hidden.mem.base+offset; in mem_seek()
376 newpos = context->hidden.mem.here+offset; in mem_seek()
379 newpos = context->hidden.mem.stop+offset; in mem_seek()
385 if ( newpos < context->hidden.mem.base ) { in mem_seek()
386 newpos = context->hidden.mem.base; in mem_seek()
388 if ( newpos > context->hidden.mem.stop ) { in mem_seek()
389 newpos = context->hidden.mem.stop; in mem_seek()
391 context->hidden.mem.here = newpos; in mem_seek()
392 return(context->hidden.mem.here-context->hidden.mem.base); in mem_seek()
394 static int SDLCALL mem_read(SDL_RWops *context, void *ptr, int size, int maxnum) in mem_read() argument
404 mem_available = (context->hidden.mem.stop - context->hidden.mem.here); in mem_read()
409 SDL_memcpy(ptr, context->hidden.mem.here, total_bytes); in mem_read()
410 context->hidden.mem.here += total_bytes; in mem_read()
414 static int SDLCALL mem_write(SDL_RWops *context, const void *ptr, int size, int num) in mem_write() argument
416 if ( (context->hidden.mem.here + (num*size)) > context->hidden.mem.stop ) { in mem_write()
417 num = (context->hidden.mem.stop-context->hidden.mem.here)/size; in mem_write()
419 SDL_memcpy(context->hidden.mem.here, ptr, num*size); in mem_write()
420 context->hidden.mem.here += num*size; in mem_write()
423 static int SDLCALL mem_writeconst(SDL_RWops *context, const void *ptr, int size, int num) in mem_writeconst() argument
428 static int SDLCALL mem_close(SDL_RWops *context) in mem_close() argument
430 if ( context ) { in mem_close()
431 SDL_FreeRW(context); in mem_close()