Overview
Comment: | Correct a few things in the file handling; make it read/write by default, but add a read-only option |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ea3c873bb0dd8af5648b8770febf49be |
User & Date: | user on 2020-12-19 07:12:41 |
Other Links: | manifest | tags |
Context
2020-12-19
| ||
22:21 | Fix a mistake in the beginning phase in exec.c check-in: 99bee720be user: user tags: trunk | |
07:12 | Correct a few things in the file handling; make it read/write by default, but add a read-only option check-in: ea3c873bb0 user: user tags: trunk | |
05:47 | Add documentation about command-line arguments check-in: cb27aaf96b user: user tags: trunk | |
Changes
Modified commandline.doc from [7edcb5b597] to [4eca270fe2].
︙ | |||
35 36 37 38 39 40 41 42 43 44 45 46 47 48 | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | + + + | -e Start in the editor instead of game. -n (not implemented yet) Create a new puzzle set. -r Open in read-only mode. -t Enable tracing. -v More verbose error logging. -x |
︙ |
Modified main.c from [4316790edd] to [0ebe47f999].
︙ | |||
141 142 143 144 145 146 147 | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | - + | sqlite3_bind_int(readusercachest,2,lvl); if(sqlite3_step(readusercachest)==SQLITE_ROW) { if(us) *us=sqlite3_value_dup(sqlite3_column_value(readusercachest,6)); if(sqlite3_column_type(readusercachest,5)==SQLITE_BLOB) { const unsigned char*con=sqlite3_column_blob(readusercachest,5); *sz=sqlite3_column_bytes(readusercachest,5); buf=malloc(*sz); |
︙ | |||
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | + + | ofs[i++]=sqlite3_column_int64(st,0); if(sqlite3_column_type(st,1)!=SQLITE_TEXT || sqlite3_column_type(st,2)!=SQLITE_BLOB) fatal("Corrupted user cache database (NAME and DATA columns have wrong types)\n"); fwrite(sqlite3_column_text(st,1),1,sqlite3_column_bytes(st,1)+1,fp); j=sqlite3_column_bytes(st,2); fputc(j>>16,fp); fputc(j>>24,fp); fputc(j,fp); fputc(j>>8,fp); ofs[i++]=ftell(fp); fwrite(sqlite3_column_blob(st,2),1,j,fp); if(ferror(fp)) fatal("I/O error: %m\n"); } if(e!=SQLITE_DONE) fatal("SQL error (%d): %s\n",e,sqlite3_errmsg(userdb)); if(ftruncate(fd,ftell(fp))) fatal("I/O error: %m\n"); rewind(fp); sqlite3_finalize(st); if(e=sqlite3_prepare_v2(userdb,"UPDATE `USERCACHEDATA` SET `OFFSET` = ?2 WHERE `ID` = ?1;",-1,&st,0)) fatal("SQL error (%d): %s\n",e,sqlite3_errmsg(userdb)); i=0; while(i<c) { sqlite3_reset(st); sqlite3_bind_int64(st,1,ofs[i++]); sqlite3_bind_int64(st,2,ofs[i++]); |
︙ | |||
436 437 438 439 440 441 442 | 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | - - + + - - + + - | fprintf(stderr,"Initializing user cache...\n"); if(z=sqlite3_exec(userdb,"BEGIN;",0,0,0)) fatal("SQL error (%d): %s\n",z,sqlite3_errmsg(userdb)); if(z=sqlite3_prepare_v2(userdb,"SELECT `ID`, `TIME` FROM `USERCACHEINDEX` WHERE `NAME` = ?1;",-1,&st,0)) fatal("SQL error (%d): %s\n",z,sqlite3_errmsg(userdb)); nam1=sqlite3_mprintf("%s.level",basefilename); if(!nam1) fatal("Allocation failed\n"); nam2=realpath(nam1,0); if(!nam2) fatal("Cannot find real path of '%s': %m\n",nam1); |
︙ |