345
346
347
348
349
350
351
352
353
354
355
356
357
358
|
}else{
rc = 2; /* It exists and is something else. */
}
free(zFN);
return rc;
}
/*
** Wrapper around the access() system call.
*/
int file_access(const char *zFilename, int flags){
int rc;
void *zMbcs = fossil_utf8_to_path(zFilename, 0);
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
345
346
347
348
349
350
351
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
390
391
392
393
394
395
396
397
398
|
}else{
rc = 2; /* It exists and is something else. */
}
free(zFN);
return rc;
}
/*
** Return true (1) if zFilename seems like it seems like a valid
** repository database.
*/
int file_is_repository(const char *zFilename){
i64 sz;
sqlite3 *db = 0;
sqlite3_stmt *pStmt = 0;
int rc;
int i;
static const char *azReqTab[] = {
"blob", "delta", "rcvfrom", "user", "config"
};
if( !file_isfile(zFilename, ExtFILE) ) return 0;
sz = file_size(zFilename, ExtFILE);
if( sz<35328 ) return 0;
if( sz%512!=0 ) return 0;
rc = sqlite3_open_v2(zFilename, &db,
SQLITE_OPEN_READWRITE, 0);
if( rc!=0 ) goto not_a_repo;
for(i=0; i<count(azReqTab); i++){
if( sqlite3_table_column_metadata(db, "main", azReqTab[i],0,0,0,0,0,0) ){
goto not_a_repo;
}
}
rc = sqlite3_prepare_v2(db, "SELECT 1 FROM config WHERE name='project-code'",
-1, &pStmt, 0);
if( rc ) goto not_a_repo;
rc = sqlite3_step(pStmt);
if( rc!=SQLITE_ROW ) goto not_a_repo;
sqlite3_finalize(pStmt);
sqlite3_close(db);
return 1;
not_a_repo:
sqlite3_finalize(pStmt);
sqlite3_close(db);
return 0;
}
/*
** Wrapper around the access() system call.
*/
int file_access(const char *zFilename, int flags){
int rc;
void *zMbcs = fossil_utf8_to_path(zFilename, 0);
|
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
|
fossil_print(" file_mtime(RepoFILE) = %s\n", zBuf);
fossil_print(" file_mode(RepoFILE) = 0%o\n", file_mode(zPath,RepoFILE));
fossil_print(" file_isfile(RepoFILE) = %d\n", file_isfile(zPath,RepoFILE));
fossil_print(" file_isfile_or_link = %d\n", file_isfile_or_link(zPath));
fossil_print(" file_islink = %d\n", file_islink(zPath));
fossil_print(" file_isexe(RepoFILE) = %d\n", file_isexe(zPath,RepoFILE));
fossil_print(" file_isdir(RepoFILE) = %d\n", file_isdir(zPath,RepoFILE));
if( reset ) resetStat();
}
/*
** COMMAND: test-file-environment
**
** Usage: %fossil test-file-environment FILENAME...
|
>
|
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
|
fossil_print(" file_mtime(RepoFILE) = %s\n", zBuf);
fossil_print(" file_mode(RepoFILE) = 0%o\n", file_mode(zPath,RepoFILE));
fossil_print(" file_isfile(RepoFILE) = %d\n", file_isfile(zPath,RepoFILE));
fossil_print(" file_isfile_or_link = %d\n", file_isfile_or_link(zPath));
fossil_print(" file_islink = %d\n", file_islink(zPath));
fossil_print(" file_isexe(RepoFILE) = %d\n", file_isexe(zPath,RepoFILE));
fossil_print(" file_isdir(RepoFILE) = %d\n", file_isdir(zPath,RepoFILE));
fossil_print(" file_is_repository = %d\n", file_is_repository(zPath));
if( reset ) resetStat();
}
/*
** COMMAND: test-file-environment
**
** Usage: %fossil test-file-environment FILENAME...
|