264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
|
for(i=2; i<g.argc; i++){
char *zName;
int isDir;
zName = mprintf("%/", g.argv[i]);
isDir = file_isdir(zName);
if( isDir==1 ){
add_directory(zName, vid, &repo, pIgnore);
}else if( isDir==0 ){
fossil_fatal("not found: %s", zName);
}else if( access(zName, R_OK) ){
fossil_fatal("cannot open %s", zName);
}else{
add_one_file(zName, vid, &repo);
}
free(zName);
}
if( pIgnore ) db_finalize(pIgnore);
db_end_transaction(0);
}
/*
** Remove all contents of zDir
*/
void del_directory_content(const char *zDir){
DIR *d;
int origSize;
struct dirent *pEntry;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
for(i=2; i<g.argc; i++){
char *zName;
int isDir;
zName = mprintf("%/", g.argv[i]);
isDir = file_isdir(zName);
if( isDir==1 ){
int sz = strlen(zName);
if( sz>0 && zName[sz-1]=='/' ){ zName[sz-1] = 0; }
add_directory(zName, vid, &repo, pIgnore);
}else if( isDir==0 ){
fossil_fatal("not found: %s", zName);
}else if( access(zName, R_OK) ){
fossil_fatal("cannot open %s", zName);
}else{
add_one_file(zName, vid, &repo);
}
free(zName);
}
if( pIgnore ) db_finalize(pIgnore);
db_end_transaction(0);
}
/*
** Unmangage a single file.
*/
void delete_one_file(const char *zName){
char *zPath;
Blob pathname;
file_tree_name(zName, &pathname, 1);
zPath = blob_str(&pathname);
if( !db_exists(
"SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){
fossil_fatal("not in the repository: %s", zName);
}else{
db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath);
printf("DELETED %s\n", zPath);
}
blob_reset(&pathname);
}
/*
** Remove all contents of zDir
*/
void del_directory_content(const char *zDir){
DIR *d;
int origSize;
struct dirent *pEntry;
|
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
|
if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue;
}
blob_appendf(&path, "/%s", pEntry->d_name);
zPath = blob_str(&path);
if( file_isdir(zPath)==1 ){
del_directory_content(zPath);
}else if( file_isfile(zPath) ){
char *zFilePath;
Blob pathname;
file_tree_name(zPath, &pathname, 1);
zFilePath = blob_str(&pathname);
if( !db_exists(
"SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zFilePath)
){
printf("SKIPPED %s\n", zPath);
}else{
db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath);
printf("DELETED %s\n", zPath);
}
blob_reset(&pathname);
}
blob_resize(&path, origSize);
}
closedir(d);
}
blob_reset(&path);
}
|
<
<
<
<
<
<
<
|
<
<
<
<
<
|
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue;
}
blob_appendf(&path, "/%s", pEntry->d_name);
zPath = blob_str(&path);
if( file_isdir(zPath)==1 ){
del_directory_content(zPath);
}else if( file_isfile(zPath) ){
delete_one_file(zPath);
}
blob_resize(&path, origSize);
}
closedir(d);
}
blob_reset(&path);
}
|
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
|
}
db_begin_transaction();
for(i=2; i<g.argc; i++){
char *zName;
zName = mprintf("%/", g.argv[i]);
if( file_isdir(zName) == 1 ){
del_directory_content(zName);
} else {
char *zPath;
Blob pathname;
file_tree_name(zName, &pathname, 1);
zPath = blob_str(&pathname);
if( !db_exists(
"SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){
fossil_fatal("not in the repository: %s", zName);
}else{
db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath);
printf("DELETED %s\n", zPath);
}
blob_reset(&pathname);
}
free(zName);
}
db_multi_exec("DELETE FROM vfile WHERE deleted AND rid=0");
db_end_transaction(0);
|
>
>
<
|
|
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
|
}
db_begin_transaction();
for(i=2; i<g.argc; i++){
char *zName;
zName = mprintf("%/", g.argv[i]);
if( file_isdir(zName) == 1 ){
int sz = strlen(zName);
if( sz>0 && zName[sz-1]=='/' ){ zName[sz-1] = 0; }
del_directory_content(zName);
} else {
char *zPath;
Blob pathname;
file_tree_name(zName, &pathname, 1);
zPath = blob_str(&pathname);
if( !db_exists(
"SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){
fossil_fatal("not in the repository: %s", zName);
}else{
delete_one_file(zPath);
}
blob_reset(&pathname);
}
free(zName);
}
db_multi_exec("DELETE FROM vfile WHERE deleted AND rid=0");
db_end_transaction(0);
|