454 |
454 |
f.separator = f.readonly = true;
|
455 |
455 |
sep = false;
|
456 |
456 |
}
|
|
457 |
#ifndef PLATFORM_WIN32
|
457 |
458 |
Sort(files);
|
458 |
459 |
Sort(dirs);
|
|
460 |
#endif
|
459 |
461 |
for(int i = 0; i < files.GetCount(); i++) {
|
460 |
462 |
if(pi.StepCanceled())
|
461 |
463 |
throw String();
|
462 |
464 |
String name = GetFileName(files[i]);
|
463 |
|
SaveFile(SourcePath(active, name), LoadFile(files[i]));
|
|
465 |
FileCopy(files[i], SourcePath(active, name));
|
464 |
466 |
Package::File& f = actual.file.Add();
|
465 |
467 |
f = name;
|
466 |
468 |
f.separator = f.readonly = false;
|
... | ... | |
469 |
471 |
DoImport(dirs[i], mask, true, pi);
|
470 |
472 |
}
|
471 |
473 |
|
|
474 |
void WorkspaceWork::DoImportTree(const String& dir, const String& mask, bool sep, int from, Progress& pi)
|
|
475 |
{
|
|
476 |
String active = GetActivePackage();
|
|
477 |
if(active.IsEmpty()) return;
|
|
478 |
FindFile ff(AppendFileName(dir, "*.*"));
|
|
479 |
Vector<String> dirs, files;
|
|
480 |
while(ff) {
|
|
481 |
String p = AppendFileName(dir, ff.GetName());
|
|
482 |
if(ff.IsFile() && PatternMatchMulti(mask, ff.GetName()))
|
|
483 |
files.Add(p);
|
|
484 |
if(ff.IsFolder())
|
|
485 |
dirs.Add(p);
|
|
486 |
ff.Next();
|
|
487 |
}
|
|
488 |
const String relPath(dir.Mid(from)),
|
|
489 |
absPath = SourcePath(active, relPath);
|
|
490 |
if(sep && files.GetCount()) {
|
|
491 |
if (!DirectoryExists(absPath))
|
|
492 |
RealizeDirectory(absPath);
|
|
493 |
Package::File& f = actual.file.Add();
|
|
494 |
f = relPath;
|
|
495 |
f.separator = f.readonly = true;
|
|
496 |
sep = false;
|
|
497 |
}
|
|
498 |
#ifndef PLATFORM_WIN32
|
|
499 |
Sort(files);
|
|
500 |
Sort(dirs);
|
|
501 |
#endif
|
|
502 |
for(int i = 0; i < files.GetCount(); i++) {
|
|
503 |
if(pi.StepCanceled())
|
|
504 |
throw String();
|
|
505 |
const String name = GetFileName(files[i]);
|
|
506 |
FileCopy(files[i], AppendFileName(absPath, name));
|
|
507 |
Package::File& f = actual.file.Add();
|
|
508 |
f = AppendFileName(relPath, name);
|
|
509 |
f.separator = f.readonly = false;
|
|
510 |
}
|
|
511 |
for(int i = 0; i < dirs.GetCount(); i++)
|
|
512 |
DoImportTree(dirs[i], mask, true, from, pi);
|
|
513 |
}
|
|
514 |
|
472 |
515 |
void WorkspaceWork::Import()
|
473 |
516 |
{
|
474 |
517 |
String active = GetActivePackage();
|
... | ... | |
479 |
522 |
Progress pi("Importing file %d");
|
480 |
523 |
int fci = filelist.GetCursor();
|
481 |
524 |
int cs = filelist.GetSbPos();
|
482 |
|
try {
|
483 |
|
DoImport(~dlg.folder, ~dlg.files, false, pi);
|
|
525 |
const String dir = ~dlg.folder;
|
|
526 |
if (~dlg.preserve) {
|
|
527 |
const int from = dir.EndsWith(AsString(DIR_SEP)) ? dir.GetCount() : dir.GetCount() + 1;
|
|
528 |
try {
|
|
529 |
DoImportTree(dir, ~dlg.files, false, from, pi);
|
|
530 |
}
|
|
531 |
catch(String) {}
|
|
532 |
}
|
|
533 |
else {
|
|
534 |
try {
|
|
535 |
DoImport(dir, ~dlg.files, false, pi);
|
|
536 |
}
|
|
537 |
catch(String) {}
|
484 |
538 |
}
|
485 |
|
catch(String) {}
|
486 |
539 |
SaveLoadPackage();
|
487 |
540 |
filelist.SetSbPos(cs);
|
488 |
541 |
filelist.SetCursor(fci >= 0 ? fci : filelist.GetCount() - 1);
|