From ebc8a403e56695c94de08e50957e9ceb218e0976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Wed, 4 Jan 2006 07:57:21 +0000 Subject: [PATCH] Installer makes use of FSCopyFolder in libtracker.so git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15839 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/installer/CopyEngine.cpp | 75 ++++++++++++++++--- src/apps/installer/CopyEngine.h | 9 ++- src/apps/installer/InstallerCopyLoopControl.h | 2 +- src/apps/installer/InstallerWindow.cpp | 2 +- src/kits/tracker/FSUtils.cpp | 6 +- 5 files changed, 75 insertions(+), 19 deletions(-) diff --git a/src/apps/installer/CopyEngine.cpp b/src/apps/installer/CopyEngine.cpp index 7481ebb582..cc67f4bc9b 100644 --- a/src/apps/installer/CopyEngine.cpp +++ b/src/apps/installer/CopyEngine.cpp @@ -6,9 +6,22 @@ #include "CopyEngine.h" #include "InstallerWindow.h" #include "PartitionMenuItem.h" +#include "FSUndoRedo.h" +#include "FSUtils.h" +#include #include #include #include +#include +#include + +namespace BPrivate { + +extern status_t FSCopyFolder(BEntry *srcEntry, BDirectory *destDir, CopyLoopControl *loopControl, + BPoint *loc, bool makeOriginalName, Undo &undo); +} // namespace BPrivate + +using namespace BPrivate; extern void SizeAsString(off_t size, char *string); @@ -39,42 +52,84 @@ CopyEngine::CopyEngine(InstallerWindow *window) : BLooper("copy_engine"), fWindow(window) { - + fControl = new InstallerCopyLoopControl(window); } void -CopyEngine::LaunchInitScript(BVolume *volume) +CopyEngine::LaunchInitScript(BPath &path) { - fWindow->SetStatusMessage("Starting Installation."); + BPath bootPath; + find_directory(B_BEOS_BOOT_DIRECTORY, &bootPath); + BString command(bootPath.Path()); + command += "/InstallerInitScript "; + command += path.Path(); + fWindow->SetStatusMessage("Starting Installation."); + system(command.String()); } void -CopyEngine::LaunchFinishScript(BVolume *volume) +CopyEngine::LaunchFinishScript(BPath &path) { - fWindow->SetStatusMessage("Finishing Installation."); + BPath bootPath; + find_directory(B_BEOS_BOOT_DIRECTORY, &bootPath); + BString command(bootPath.Path()); + command += "/InstallerFinishScript "; + command += path.Path(); + fWindow->SetStatusMessage("Finishing Installation."); + system(command.String()); } void -CopyEngine::Start() +CopyEngine::Start(BMenu *srcMenu, BMenu *targetMenu) { - BVolume *volume; + PartitionMenuItem *item = (PartitionMenuItem *)targetMenu->FindMarked(); + if (!item) + return; + + BPath directory; + BDiskDevice device; + BPartition *partition; + if (fDDRoster.GetPartitionWithID(item->ID(), &device, &partition) == B_OK) { + if (partition->GetMountPoint(&directory)!=B_OK) + return; + } else if (fDDRoster.GetDeviceWithID(item->ID(), &device) == B_OK) { + if (device.GetMountPoint(&directory)!=B_OK) + return; + } else + return; // shouldn't happen + // check not installing on boot volume - + BVolume bootVolume; + BDirectory bootDir; + BEntry bootEntry; + BPath bootPath; + BVolumeRoster().GetBootVolume(&bootVolume); + bootVolume.GetRootDirectory(&bootDir); + bootDir.GetEntry(&bootEntry); + bootEntry.GetPath(&bootPath); + if (strncmp(bootPath.Path(), directory.Path(), strlen(bootPath.Path())) == 0) { + + } // check if target is initialized // ask if init ou mount as is - LaunchInitScript(volume); + LaunchInitScript(directory); // copy source volume + BDirectory targetDir(directory.Path()); + bootPath.Append("/beos"); + BEntry srcEntry(bootPath.Path()); + Undo undo; + FSCopyFolder(&srcEntry, &targetDir, fControl, NULL, false, undo); // copy selected packages - LaunchFinishScript(volume); + LaunchFinishScript(directory); } diff --git a/src/apps/installer/CopyEngine.h b/src/apps/installer/CopyEngine.h index 617da9aae8..1af449fd73 100644 --- a/src/apps/installer/CopyEngine.h +++ b/src/apps/installer/CopyEngine.h @@ -6,6 +6,8 @@ #ifndef _CopyEngine_h #define _CopyEngine_h +#include "InstallerCopyLoopControl.h" + #include #include #include @@ -18,15 +20,16 @@ class InstallerWindow; class CopyEngine : public BLooper { public: CopyEngine(InstallerWindow *window); - void Start(); + void Start(BMenu *srcMenu, BMenu *targetMenu); void ScanDisksPartitions(BMenu *srcMenu, BMenu *targetMenu); private: - void LaunchInitScript(BVolume *volume); - void LaunchFinishScript(BVolume *volume); + void LaunchInitScript(BPath &path); + void LaunchFinishScript(BPath &path); InstallerWindow *fWindow; BDiskDeviceRoster fDDRoster; + InstallerCopyLoopControl *fControl; }; #endif /* _CopyEngine_h */ diff --git a/src/apps/installer/InstallerCopyLoopControl.h b/src/apps/installer/InstallerCopyLoopControl.h index 52b80ee944..26bebd9177 100644 --- a/src/apps/installer/InstallerCopyLoopControl.h +++ b/src/apps/installer/InstallerCopyLoopControl.h @@ -8,7 +8,7 @@ #define _INSTALLERCOPYLOOPCONTROL_H #include "FSUtils.h" -#include "InstallerWindow.h" +class InstallerWindow; class InstallerCopyLoopControl : public CopyLoopControl { diff --git a/src/apps/installer/InstallerWindow.cpp b/src/apps/installer/InstallerWindow.cpp index b89d2c38b0..de0661573c 100644 --- a/src/apps/installer/InstallerWindow.cpp +++ b/src/apps/installer/InstallerWindow.cpp @@ -163,7 +163,7 @@ InstallerWindow::MessageReceived(BMessage *msg) StartScan(); break; case BEGIN_MESSAGE: - fCopyEngine.Start(); + fCopyEngine.Start(fSrcMenu, fDestMenu); break; case SHOW_BOTTOM_MESSAGE: ShowBottom(); diff --git a/src/kits/tracker/FSUtils.cpp b/src/kits/tracker/FSUtils.cpp index 5ce1d0673d..5db3870942 100644 --- a/src/kits/tracker/FSUtils.cpp +++ b/src/kits/tracker/FSUtils.cpp @@ -1449,20 +1449,18 @@ FSDuplicate(BObjectList *srcList, BList *pointList) } -#if 0 status_t FSCopyFolder(BEntry *srcEntry, BDirectory *destDir, CopyLoopControl *loopControl, - BPoint *loc, bool makeOriginalName) + BPoint *loc, bool makeOriginalName, Undo &undo) { try { - CopyFolder(srcEntry, destDir, loopControl, loc, makeOriginalName); + CopyFolder(srcEntry, destDir, loopControl, loc, makeOriginalName, undo); } catch (status_t error) { return error; } return B_OK; } -#endif status_t