| | @@ -156,12 +156,13 @@ |
| 156 | 156 | */ |
| 157 | 157 | static void dir_cmd_rev( |
| 158 | 158 | Th_Interp *interp, |
| 159 | 159 | char **pzList, |
| 160 | 160 | int *pnList, |
| 161 | | - const char *zRev, /* Revision string given */ |
| 162 | | - const char *zGlob /* Glob pattern given */ |
| 161 | + const char *zRev, /* Revision string given */ |
| 162 | + const char *zGlob, /* Glob pattern given */ |
| 163 | + int bDetails |
| 163 | 164 | ){ |
| 164 | 165 | Stmt q; |
| 165 | 166 | char *zOrderBy = "pathname COLLATE nocase"; |
| 166 | 167 | int rid; |
| 167 | 168 | |
| | @@ -174,40 +175,62 @@ |
| 174 | 175 | " WHERE blob.rid=fileage.fid \n" |
| 175 | 176 | " ORDER BY %s;", zOrderBy /*safe-for-%s*/ |
| 176 | 177 | ); |
| 177 | 178 | while( db_step(&q)==SQLITE_ROW ){ |
| 178 | 179 | const char *zFile = db_column_text(&q, 1); |
| 179 | | - Th_ListAppend(interp, pzList, pnList, zFile, -1); |
| 180 | + if( bDetails ){ |
| 181 | + const char *zTime = db_column_text(&q, 0); |
| 182 | + int size = db_column_int(&q, 2); |
| 183 | + char zSize[50]; |
| 184 | + char *zSubList = 0; |
| 185 | + int nSubList = 0; |
| 186 | + sqlite3_snprintf(sizeof(zSize), zSize, "%d", size); |
| 187 | + Th_ListAppend(interp, &zSubList, &nSubList, zFile, -1); |
| 188 | + Th_ListAppend(interp, &zSubList, &nSubList, zSize, -1); |
| 189 | + Th_ListAppend(interp, &zSubList, &nSubList, zTime, -1); |
| 190 | + Th_ListAppend(interp, pzList, pnList, zSubList, -1); |
| 191 | + Th_Free(interp, zSubList); |
| 192 | + }else{ |
| 193 | + Th_ListAppend(interp, pzList, pnList, zFile, -1); |
| 194 | + } |
| 180 | 195 | } |
| 181 | 196 | db_finalize(&q); |
| 182 | 197 | } |
| 183 | 198 | |
| 184 | 199 | /* |
| 185 | | -** TH1 command: dir CHECKIN ?GLOB? |
| 200 | +** TH1 command: dir CHECKIN ?GLOB? ?DETAILS? |
| 186 | 201 | ** |
| 187 | 202 | ** Returns a list containing all files in CHECKIN. If GLOB is given only |
| 188 | 203 | ** the files matching the pattern GLOB within CHECKIN will be returned. |
| 204 | +** If DETAILS is non-zero, the result will be a list-of-lists, with each |
| 205 | +** element containing at least three elements: the file name, the file |
| 206 | +** size (in bytes), and the file last modification time (relative to the |
| 207 | +** time zone configured for the repository). |
| 189 | 208 | */ |
| 190 | 209 | static int dirCmd( |
| 191 | 210 | Th_Interp *interp, |
| 192 | 211 | void *ctx, |
| 193 | 212 | int argc, |
| 194 | 213 | const char **argv, |
| 195 | 214 | int *argl |
| 196 | 215 | ){ |
| 197 | 216 | const char *zGlob = 0; |
| 217 | + int bDetails = 0; |
| 198 | 218 | |
| 199 | | - if( argc!=2 && argc!=3 ){ |
| 219 | + if( argc<2 || argc>4 ){ |
| 200 | 220 | return Th_WrongNumArgs(interp, "dir CHECKIN ?GLOB?"); |
| 201 | 221 | } |
| 202 | | - if( argc==3 ){ |
| 222 | + if( argc>=3 ){ |
| 203 | 223 | zGlob = argv[2]; |
| 224 | + } |
| 225 | + if( argc>=4 && Th_ToInt(interp, argv[3], argl[3], &bDetails) ){ |
| 226 | + return TH_ERROR; |
| 204 | 227 | } |
| 205 | 228 | if( Th_IsRepositoryOpen() ){ |
| 206 | 229 | char *zList = 0; |
| 207 | 230 | int nList = 0; |
| 208 | | - dir_cmd_rev(interp, &zList, &nList, argv[1], zGlob); |
| 231 | + dir_cmd_rev(interp, &zList, &nList, argv[1], zGlob, bDetails); |
| 209 | 232 | Th_SetResult(interp, zList, nList); |
| 210 | 233 | Th_Free(interp, zList); |
| 211 | 234 | return TH_OK; |
| 212 | 235 | }else{ |
| 213 | 236 | Th_SetResult(interp, "repository unavailable", -1); |
| 214 | 237 | |