OLD | NEW |
1 /* | 1 /* |
2 ** 2013 Jan 11 | 2 ** 2013 Jan 11 |
3 ** | 3 ** |
4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
6 ** | 6 ** |
7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
10 ** | 10 ** |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 ** CREATE TABLE fstree(path TEXT, size INT, data BLOB); | 55 ** CREATE TABLE fstree(path TEXT, size INT, data BLOB); |
56 ** | 56 ** |
57 ** Running a "SELECT * FROM fstree" query on this table returns the entire | 57 ** Running a "SELECT * FROM fstree" query on this table returns the entire |
58 ** contents of the file-system, starting at "/". To restrict the search | 58 ** contents of the file-system, starting at "/". To restrict the search |
59 ** space, the virtual table supports LIKE and GLOB constraints on the | 59 ** space, the virtual table supports LIKE and GLOB constraints on the |
60 ** 'path' column. For example: | 60 ** 'path' column. For example: |
61 ** | 61 ** |
62 ** SELECT * FROM fstree WHERE path LIKE '/home/dan/sqlite/%' | 62 ** SELECT * FROM fstree WHERE path LIKE '/home/dan/sqlite/%' |
63 */ | 63 */ |
64 #include "sqliteInt.h" | 64 #include "sqliteInt.h" |
65 #include "tcl.h" | 65 #if defined(INCLUDE_SQLITE_TCL_H) |
| 66 # include "sqlite_tcl.h" |
| 67 #else |
| 68 # include "tcl.h" |
| 69 #endif |
66 | 70 |
67 #include <stdlib.h> | 71 #include <stdlib.h> |
68 #include <string.h> | 72 #include <string.h> |
69 #include <sys/types.h> | 73 #include <sys/types.h> |
70 #include <sys/stat.h> | 74 #include <sys/stat.h> |
71 #include <fcntl.h> | 75 #include <fcntl.h> |
72 | 76 |
73 #if SQLITE_OS_UNIX || defined(__MINGW_H) | 77 #if SQLITE_OS_UNIX || defined(__MINGW_H) |
74 # include <unistd.h> | 78 # include <unistd.h> |
75 # include <dirent.h> | 79 # include <dirent.h> |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 | 492 |
489 char *zRoot; | 493 char *zRoot; |
490 int nRoot; | 494 int nRoot; |
491 char *zPrefix; | 495 char *zPrefix; |
492 int nPrefix; | 496 int nPrefix; |
493 const char *zDir; | 497 const char *zDir; |
494 int nDir; | 498 int nDir; |
495 char aWild[2] = { '\0', '\0' }; | 499 char aWild[2] = { '\0', '\0' }; |
496 | 500 |
497 #if SQLITE_OS_WIN | 501 #if SQLITE_OS_WIN |
498 zRoot = sqlite3_mprintf("%s%c", getenv("SystemDrive"), '/'); | 502 const char *zDrive = windirent_getenv("fstreeDrive"); |
499 nRoot = strlen(zRoot); | 503 if( zDrive==0 ){ |
500 zPrefix = sqlite3_mprintf("%s", getenv("SystemDrive")); | 504 zDrive = windirent_getenv("SystemDrive"); |
501 nPrefix = strlen(zPrefix); | 505 } |
| 506 zRoot = sqlite3_mprintf("%s%c", zDrive, '/'); |
| 507 nRoot = sqlite3Strlen30(zRoot); |
| 508 zPrefix = sqlite3_mprintf("%s", zDrive); |
| 509 nPrefix = sqlite3Strlen30(zPrefix); |
502 #else | 510 #else |
503 zRoot = "/"; | 511 zRoot = "/"; |
504 nRoot = 1; | 512 nRoot = 1; |
505 zPrefix = ""; | 513 zPrefix = ""; |
506 nPrefix = 0; | 514 nPrefix = 0; |
507 #endif | 515 #endif |
508 | 516 |
509 zDir = zRoot; | 517 zDir = zRoot; |
510 nDir = nRoot; | 518 nDir = nRoot; |
511 | 519 |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 }; | 872 }; |
865 | 873 |
866 /* | 874 /* |
867 ** Decode a pointer to an sqlite3 object. | 875 ** Decode a pointer to an sqlite3 object. |
868 */ | 876 */ |
869 extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb); | 877 extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb); |
870 | 878 |
871 /* | 879 /* |
872 ** Register the echo virtual table module. | 880 ** Register the echo virtual table module. |
873 */ | 881 */ |
874 static int register_fs_module( | 882 static int SQLITE_TCLAPI register_fs_module( |
875 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 883 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
876 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 884 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
877 int objc, /* Number of arguments */ | 885 int objc, /* Number of arguments */ |
878 Tcl_Obj *CONST objv[] /* Command arguments */ | 886 Tcl_Obj *CONST objv[] /* Command arguments */ |
879 ){ | 887 ){ |
880 sqlite3 *db; | 888 sqlite3 *db; |
881 if( objc!=2 ){ | 889 if( objc!=2 ){ |
882 Tcl_WrongNumArgs(interp, 1, objv, "DB"); | 890 Tcl_WrongNumArgs(interp, 1, objv, "DB"); |
883 return TCL_ERROR; | 891 return TCL_ERROR; |
884 } | 892 } |
(...skipping 22 matching lines...) Expand all Loading... |
907 { "register_fs_module", register_fs_module, 0 }, | 915 { "register_fs_module", register_fs_module, 0 }, |
908 }; | 916 }; |
909 int i; | 917 int i; |
910 for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ | 918 for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ |
911 Tcl_CreateObjCommand(interp, aObjCmd[i].zName, | 919 Tcl_CreateObjCommand(interp, aObjCmd[i].zName, |
912 aObjCmd[i].xProc, aObjCmd[i].clientData, 0); | 920 aObjCmd[i].xProc, aObjCmd[i].clientData, 0); |
913 } | 921 } |
914 #endif | 922 #endif |
915 return TCL_OK; | 923 return TCL_OK; |
916 } | 924 } |
OLD | NEW |