size_t WriteResFile (const void *lpBuf, size_t size, size_t count, uio_Stream *fp) { int retval; retval = uio_fwrite (lpBuf, size, count, fp); return (retval); }
int sdluio_write (SDL_RWops *context, const void *ptr, int size, int num) { size_t numWritten; numWritten = uio_fwrite (ptr, (size_t) size, (size_t) num, (uio_Stream *) context->hidden.unknown.data1); if (numWritten == 0 && uio_ferror ((uio_Stream *) context->hidden.unknown.data1)) { SDL_SetError ("Error writing to uio_Stream: %s", strerror(errno)); return 0; } return (size_t) numWritten; }
static int debugCmdFwriteTest(DebugContext *debugContext, int argc, char *argv[]) { uio_Stream *stream; const char testString[] = "0123456789\n"; if (argc != 2) { fprintf(debugContext->err, "Invalid number of arguments.\n"); return 1; } stream = uio_fopen(debugContext->cwd, argv[1], "w+b"); if (stream == NULL) { fprintf(debugContext->err, "Could not open file: %s\n", strerror(errno)); goto err; } if (uio_fwrite(testString, strlen(testString), 1, stream) != 1) { fprintf(debugContext->err, "uio_fwrite() failed: %s\n", strerror(errno)); goto err; } if (uio_fputs(testString, stream) == EOF) { fprintf(debugContext->err, "uio_fputs() failed: %s\n", strerror(errno)); goto err; } if (uio_fseek(stream, 15, SEEK_SET) != 0) { fprintf(debugContext->err, "uio_fseek() failed: %s\n", strerror(errno)); goto err; } if (uio_fputc('A', stream) != 'A') { fprintf(debugContext->err, "uio_fputc() failed: %s\n", strerror(errno)); goto err; } if (uio_fseek(stream, 0, SEEK_SET) != 0) { fprintf(debugContext->err, "uio_fseek() failed: %s\n", strerror(errno)); goto err; } { char buf[6]; char *ptr; int i; i = 1; while (1) { ptr = uio_fgets(buf, sizeof buf, stream); if (ptr == NULL) break; fprintf(debugContext->out, "%d: [%s]\n", i, ptr); i++; } if (uio_ferror(stream)) { fprintf(debugContext->err, "uio_fgets() failed: %s\n", strerror(errno)); goto err; } uio_clearerr(stream); } if (uio_fseek(stream, 4, SEEK_END) != 0) { fprintf(debugContext->err, "uio_fseek() failed: %s\n", strerror(errno)); goto err; } { char buf[2000]; memset(buf, 'Q', sizeof buf); if (uio_fwrite(buf, 100, 20, stream) != 20) { fprintf(debugContext->err, "uio_fwrite() failed: %s\n", strerror(errno)); goto err; } } if (uio_fseek(stream, 5, SEEK_SET) != 0) { fprintf(debugContext->err, "uio_fseek() failed: %s\n", strerror(errno)); goto err; } if (uio_fputc('B', stream) != 'B') { fprintf(debugContext->err, "uio_fputc() failed: %s\n", strerror(errno)); goto err; } uio_fclose(stream); return 0; err: uio_fclose(stream); return 1; }