uppsrc.diff

The diff file to apply for uppsrc directory - Sender Ghost, 10/19/2011 10:55 AM

Download (3.82 KB)

View differences:

uppsrc/ide/ide.lay 2011-10-19 14:16:32 +0600
622 622
	ITEM(EditString, folder, LeftPosZ(80, 312).TopPosZ(8, 19))
623 623
	ITEM(Label, dv___2, SetLabel(t_("Import files")).LeftPosZ(8, 72).TopPosZ(32, 19))
624 624
	ITEM(EditString, files, LeftPosZ(80, 312).TopPosZ(32, 19))
625
	ITEM(Option, preserve, SetLabel(t_("Preserve directories")).LeftPosZ(8, 192).TopPosZ(56, 19))
625 626
	ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(260, 64).TopPosZ(60, 24))
626 627
	ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(328, 64).TopPosZ(60, 24))
627 628
END_LAYOUT
uppsrc/ide/UppDlg.h 2011-10-19 14:01:33 +0600
217 217
	void AddItem(const String& name, bool separator, bool readonly);
218 218
	void AddTopicGroup();
219 219
	void AddSeparator();
220
	void Import();
221 220
	void DoImport(const String& dir, const String& mask, bool sep, Progress& pi);
221
	void DoImportTree(const String& dir, const String& mask, bool sep, int from, Progress& pi);
222
	void Import();
222 223
	void RemoveFile();
223 224
	void DelFile();
224 225
	void RenameFile();
uppsrc/ide/UppWspc.cpp 2011-10-19 14:07:25 +0600
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);