Installer makes use of FSCopyFolder in libtracker.so

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15839 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2006-01-04 07:57:21 +00:00
parent ee6bcb7d78
commit ebc8a403e5
5 changed files with 75 additions and 19 deletions

View File

@ -6,9 +6,22 @@
#include "CopyEngine.h" #include "CopyEngine.h"
#include "InstallerWindow.h" #include "InstallerWindow.h"
#include "PartitionMenuItem.h" #include "PartitionMenuItem.h"
#include "FSUndoRedo.h"
#include "FSUtils.h"
#include <FindDirectory.h>
#include <DiskDeviceVisitor.h> #include <DiskDeviceVisitor.h>
#include <DiskDeviceTypes.h> #include <DiskDeviceTypes.h>
#include <Path.h> #include <Path.h>
#include <String.h>
#include <VolumeRoster.h>
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); extern void SizeAsString(off_t size, char *string);
@ -39,42 +52,84 @@ CopyEngine::CopyEngine(InstallerWindow *window)
: BLooper("copy_engine"), : BLooper("copy_engine"),
fWindow(window) fWindow(window)
{ {
fControl = new InstallerCopyLoopControl(window);
} }
void 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 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 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 // 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 // check if target is initialized
// ask if init ou mount as is // ask if init ou mount as is
LaunchInitScript(volume); LaunchInitScript(directory);
// copy source volume // 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 // copy selected packages
LaunchFinishScript(volume); LaunchFinishScript(directory);
} }

View File

@ -6,6 +6,8 @@
#ifndef _CopyEngine_h #ifndef _CopyEngine_h
#define _CopyEngine_h #define _CopyEngine_h
#include "InstallerCopyLoopControl.h"
#include <DiskDevice.h> #include <DiskDevice.h>
#include <DiskDeviceRoster.h> #include <DiskDeviceRoster.h>
#include <Looper.h> #include <Looper.h>
@ -18,15 +20,16 @@ class InstallerWindow;
class CopyEngine : public BLooper { class CopyEngine : public BLooper {
public: public:
CopyEngine(InstallerWindow *window); CopyEngine(InstallerWindow *window);
void Start(); void Start(BMenu *srcMenu, BMenu *targetMenu);
void ScanDisksPartitions(BMenu *srcMenu, BMenu *targetMenu); void ScanDisksPartitions(BMenu *srcMenu, BMenu *targetMenu);
private: private:
void LaunchInitScript(BVolume *volume); void LaunchInitScript(BPath &path);
void LaunchFinishScript(BVolume *volume); void LaunchFinishScript(BPath &path);
InstallerWindow *fWindow; InstallerWindow *fWindow;
BDiskDeviceRoster fDDRoster; BDiskDeviceRoster fDDRoster;
InstallerCopyLoopControl *fControl;
}; };
#endif /* _CopyEngine_h */ #endif /* _CopyEngine_h */

View File

@ -8,7 +8,7 @@
#define _INSTALLERCOPYLOOPCONTROL_H #define _INSTALLERCOPYLOOPCONTROL_H
#include "FSUtils.h" #include "FSUtils.h"
#include "InstallerWindow.h" class InstallerWindow;
class InstallerCopyLoopControl : public CopyLoopControl class InstallerCopyLoopControl : public CopyLoopControl
{ {

View File

@ -163,7 +163,7 @@ InstallerWindow::MessageReceived(BMessage *msg)
StartScan(); StartScan();
break; break;
case BEGIN_MESSAGE: case BEGIN_MESSAGE:
fCopyEngine.Start(); fCopyEngine.Start(fSrcMenu, fDestMenu);
break; break;
case SHOW_BOTTOM_MESSAGE: case SHOW_BOTTOM_MESSAGE:
ShowBottom(); ShowBottom();

View File

@ -1449,20 +1449,18 @@ FSDuplicate(BObjectList<entry_ref> *srcList, BList *pointList)
} }
#if 0
status_t status_t
FSCopyFolder(BEntry *srcEntry, BDirectory *destDir, CopyLoopControl *loopControl, FSCopyFolder(BEntry *srcEntry, BDirectory *destDir, CopyLoopControl *loopControl,
BPoint *loc, bool makeOriginalName) BPoint *loc, bool makeOriginalName, Undo &undo)
{ {
try { try {
CopyFolder(srcEntry, destDir, loopControl, loc, makeOriginalName); CopyFolder(srcEntry, destDir, loopControl, loc, makeOriginalName, undo);
} catch (status_t error) { } catch (status_t error) {
return error; return error;
} }
return B_OK; return B_OK;
} }
#endif
status_t status_t