Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the "filetype()" SQL function for interpreting file modes to the fileio.c extension. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | archive-improvements |
Files: | files | file ages | folders |
SHA3-256: |
58c0c74c407d93f48930a4964b6cc48f |
User & Date: | drh 2018-01-10 15:53:06.284 |
Context
2018-01-10
| ||
16:50 | Implement the ".ar --create" command using a single "REPLACE INTO sqlar SELECT ... FROM fsdir();" statement. Add the shell_putsnl() SQL function for providing --verbose output. (check-in: 28ab930436 user: drh tags: archive-improvements) | |
15:53 | Add the "filetype()" SQL function for interpreting file modes to the fileio.c extension. (check-in: 58c0c74c40 user: drh tags: archive-improvements) | |
15:17 | The ".ar" command deduces whether or not the target file is a ZIP or SQLAR and does the appropropriate thing. The "-z" option is omitted. The "--append" option is added to open auxiliary databases using apndvfs. (check-in: 430d1a7daa user: drh tags: archive-improvements) | |
Changes
Changes to ext/misc/fileio.c.
︙ | ︙ | |||
352 353 354 355 356 357 358 359 360 361 362 363 364 365 | }else if( S_ISDIR(mode) ){ ctxErrorMsg(context, "failed to create directory: %s", zFile); }else{ ctxErrorMsg(context, "failed to write file: %s", zFile); } } } #ifndef SQLITE_OMIT_VIRTUALTABLE /* ** Cursor type for recursively iterating through a directory structure. */ typedef struct fsdir_cursor fsdir_cursor; | > > > > > > > > > > > > > > > > > > > > > > > > | 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | }else if( S_ISDIR(mode) ){ ctxErrorMsg(context, "failed to create directory: %s", zFile); }else{ ctxErrorMsg(context, "failed to write file: %s", zFile); } } } /* ** SQL function: filetype(MODE) ** ** Based on the integer mode, return one of "file", "directory", or "symlink". */ static void fileTypeFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ const char *zMode; int iMode = sqlite3_value_int(argv[0]); if( S_ISLNK(iMode) ){ zMode = "symlink"; }else if( S_ISREG(iMode) ){ zMode = "file"; }else if( S_ISDIR(iMode) ){ zMode = "directory"; }else{ zMode = "unknown"; } sqlite3_result_text(context, zMode, -1, SQLITE_STATIC); } #ifndef SQLITE_OMIT_VIRTUALTABLE /* ** Cursor type for recursively iterating through a directory structure. */ typedef struct fsdir_cursor fsdir_cursor; |
︙ | ︙ | |||
764 765 766 767 768 769 770 771 772 773 774 775 | (void)pzErrMsg; /* Unused parameter */ rc = sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8, 0, readfileFunc, 0, 0); if( rc==SQLITE_OK ){ rc = sqlite3_create_function(db, "writefile", -1, SQLITE_UTF8, 0, writefileFunc, 0, 0); } if( rc==SQLITE_OK ){ rc = fsdirRegister(db); } return rc; } | > > > > | 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 | (void)pzErrMsg; /* Unused parameter */ rc = sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8, 0, readfileFunc, 0, 0); if( rc==SQLITE_OK ){ rc = sqlite3_create_function(db, "writefile", -1, SQLITE_UTF8, 0, writefileFunc, 0, 0); } if( rc==SQLITE_OK ){ rc = sqlite3_create_function(db, "fileType", 1, SQLITE_UTF8, 0, fileTypeFunc, 0, 0); } if( rc==SQLITE_OK ){ rc = fsdirRegister(db); } return rc; } |