From: <fd...@us...> - 2008-08-17 11:37:58
|
Revision: 4456 http://jnode.svn.sourceforge.net/jnode/?rev=4456&view=rev Author: fduminy Date: 2008-08-17 11:37:55 +0000 (Sun, 17 Aug 2008) Log Message: ----------- instead of using System.out, PartitionHelper is now using a provided PrintStream (out) Modified Paths: -------------- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BaseDeviceCommand.java trunk/distr/src/apps/org/jnode/apps/jpartition/commands/InitMbrCommand.java trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java trunk/fs/src/fs/org/jnode/partitions/command/PartitionHelper.java Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BaseDeviceCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BaseDeviceCommand.java 2008-08-17 06:46:30 UTC (rev 4455) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/BaseDeviceCommand.java 2008-08-17 11:37:55 UTC (rev 4456) @@ -23,7 +23,8 @@ protected final PartitionHelper createPartitionHelper() throws CommandException { try { - return new PartitionHelper(device); + //FIXME replace System.out by output stream from (Console)ViewFactory + return new PartitionHelper(device, System.out); } catch (DeviceNotFoundException e) { throw new CommandException(e); } catch (ApiNotFoundException e) { Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/commands/InitMbrCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/commands/InitMbrCommand.java 2008-08-17 06:46:30 UTC (rev 4455) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/commands/InitMbrCommand.java 2008-08-17 11:37:55 UTC (rev 4456) @@ -14,7 +14,8 @@ protected void doExecute() throws CommandException { PartitionHelper helper; try { - helper = new PartitionHelper(device); + //FIXME replace System.out by output stream from (Console)ViewFactory + helper = new PartitionHelper(device, System.out); helper.initMbr(); } catch (Throwable t) { throw new CommandException(t); Modified: trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java 2008-08-17 06:46:30 UTC (rev 4455) +++ trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java 2008-08-17 11:37:55 UTC (rev 4456) @@ -116,7 +116,7 @@ err.println(dev.getId() + " is not an IDE device"); exit(1); } - final PartitionHelper helper = new PartitionHelper(dev.getId()); + final PartitionHelper helper = new PartitionHelper(dev.getId(), out); if (FLAG_BOOTABLE.isSet()) { helper.toggleBootable(getPartitionNumber(helper)); Modified: trunk/fs/src/fs/org/jnode/partitions/command/PartitionHelper.java =================================================================== --- trunk/fs/src/fs/org/jnode/partitions/command/PartitionHelper.java 2008-08-17 06:46:30 UTC (rev 4455) +++ trunk/fs/src/fs/org/jnode/partitions/command/PartitionHelper.java 2008-08-17 11:37:55 UTC (rev 4456) @@ -1,6 +1,7 @@ package org.jnode.partitions.command; import java.io.IOException; +import java.io.PrintStream; import javax.naming.NameNotFoundException; @@ -30,30 +31,32 @@ private final MasterBootRecord MBR; private BootSector bs; + + private final PrintStream out; - public PartitionHelper(String deviceId) throws DeviceNotFoundException, ApiNotFoundException, + public PartitionHelper(String deviceId, PrintStream out) throws DeviceNotFoundException, ApiNotFoundException, IOException, NameNotFoundException { - this((IDEDevice) DeviceUtils.getDeviceManager().getDevice(deviceId)); + this((IDEDevice) DeviceUtils.getDeviceManager().getDevice(deviceId), out); } - public PartitionHelper(IDEDevice device) throws DeviceNotFoundException, ApiNotFoundException, + public PartitionHelper(IDEDevice device, PrintStream out) throws DeviceNotFoundException, ApiNotFoundException, IOException { this.current = device; this.api = current.getAPI(BlockDeviceAPI.class); this.MBR = new MasterBootRecord(api); + this.out = out; reloadMBR(); } public void initMbr() throws DeviceNotFoundException, ApiNotFoundException, IOException { - System.out.println("Initialize MBR ..."); + out.println("Initialize MBR ..."); BootSector oldMBR = bs; bs = new GrubBootSector(PLAIN_MASTER_BOOT_SECTOR); if (MBR.containsPartitionTable()) { - System.out - .println("This device already contains a partition table. Copy the already existing partitions."); + out.println("This device already contains a partition table. Copy the already existing partitions."); for (int i = 0; i < 4; i++) { final IBMPartitionTableEntry oldEntry = oldMBR.getPartition(i); @@ -70,7 +73,7 @@ // reloadMBR(); } - public void write() throws IOException { + public void write() throws IOException, Exception { bs.write(api); reloadMBR(); @@ -81,11 +84,11 @@ devMan.stop(current); devMan.start(current); } catch (DeviceNotFoundException e) { - e.printStackTrace(); + throw new Exception("error while restarting device", e); } catch (DriverException e) { - e.printStackTrace(); + throw new Exception("error while restarting device", e); } catch (NameNotFoundException e) { - e.printStackTrace(); + throw new Exception("error while restarting device", e); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |