|
From: <ls...@us...> - 2006-12-12 22:20:53
|
Revision: 2904
http://jnode.svn.sourceforge.net/jnode/?rev=2904&view=rev
Author: lsantha
Date: 2006-12-12 14:20:48 -0800 (Tue, 12 Dec 2006)
Log Message:
-----------
test env.
Added Paths:
-----------
trunk/distr/src/apps/org/jnode/apps/console/ShellEmu.java
trunk/distr/src/apps/org/jnode/apps/editor/EditEmu.java
Added: trunk/distr/src/apps/org/jnode/apps/console/ShellEmu.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/console/ShellEmu.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/console/ShellEmu.java 2006-12-12 22:20:48 UTC (rev 2904)
@@ -0,0 +1,21 @@
+package org.jnode.apps.console;
+
+import org.jnode.test.gui.Emu;
+import org.jnode.driver.console.swing.SwingTextScreenConsoleManager;
+import org.jnode.driver.console.TextConsole;
+import org.jnode.driver.console.ConsoleManager;
+import org.jnode.shell.CommandShell;
+
+/**
+ * @author Levente S\u00e1ntha
+ */
+public class ShellEmu extends Emu {
+
+ public static void main(String[] argv) throws Exception {
+ initEnv();
+ SwingTextScreenConsoleManager cm = new SwingTextScreenConsoleManager();
+ new Thread(new CommandShell((TextConsole) cm.createConsole(null,
+ ConsoleManager.CreateOptions.TEXT | ConsoleManager.CreateOptions.SCROLLABLE))).
+ start();
+ }
+}
Added: trunk/distr/src/apps/org/jnode/apps/editor/EditEmu.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/editor/EditEmu.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/editor/EditEmu.java 2006-12-12 22:20:48 UTC (rev 2904)
@@ -0,0 +1,31 @@
+package org.jnode.apps.editor;
+
+import org.jnode.driver.console.ConsoleManager;
+import org.jnode.driver.console.swing.SwingTextScreenConsoleManager;
+import org.jnode.driver.console.textscreen.TextScreenConsole;
+import org.jnode.test.gui.Emu;
+
+import java.io.File;
+
+/**
+ * @author Levente S\u00e1ntha
+ */
+public class EditEmu extends Emu {
+ public static void main(String[] argv) throws Exception{
+ initEnv();
+
+
+ if(argv.length == 0){
+ System.out.println("No file specified");
+ return;
+ }
+
+ SwingTextScreenConsoleManager cm = new SwingTextScreenConsoleManager();
+ final TextScreenConsole console = cm.createConsole(null,
+ ConsoleManager.CreateOptions.TEXT | ConsoleManager.CreateOptions.NO_SYSTEM_OUT_ERR_IN);
+
+ TextEditor te = new TextEditor(console);
+ File f = new File(argv[0]);
+ te.loadFile(f);
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fd...@us...> - 2007-03-18 23:57:38
|
Revision: 3143
http://jnode.svn.sourceforge.net/jnode/?rev=3143&view=rev
Author: fduminy
Date: 2007-03-18 12:35:21 -0700 (Sun, 18 Mar 2007)
Log Message:
-----------
JPartition (JNode disk partitionner) : alpha version
Added Paths:
-----------
trunk/distr/src/apps/org/jnode/apps/jpartition/
trunk/distr/src/apps/org/jnode/apps/jpartition/BasicNameSpace.java
trunk/distr/src/apps/org/jnode/apps/jpartition/FileIDEDevice.java
trunk/distr/src/apps/org/jnode/apps/jpartition/FileIDEDeviceDriver.java
trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java
trunk/distr/src/apps/org/jnode/apps/jpartition/controller/
trunk/distr/src/apps/org/jnode/apps/jpartition/controller/DevicePartitionsController.java
trunk/distr/src/apps/org/jnode/apps/jpartition/model/
trunk/distr/src/apps/org/jnode/apps/jpartition/model/DevicePartitions.java
trunk/distr/src/apps/org/jnode/apps/jpartition/model/DevicePartitionsList.java
trunk/distr/src/apps/org/jnode/apps/jpartition/model/Partition.java
trunk/distr/src/apps/org/jnode/apps/jpartition/view/
trunk/distr/src/apps/org/jnode/apps/jpartition/view/DevicePartitionsFrame.java
trunk/distr/src/apps/org/jnode/apps/jpartition/view/DevicePartitionsUI.java
trunk/distr/src/apps/org/jnode/apps/jpartition/view/FileDeviceFrame.java
trunk/distr/src/apps/org/jnode/apps/jpartition/view/PartitionUI.java
Added: trunk/distr/src/apps/org/jnode/apps/jpartition/BasicNameSpace.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/BasicNameSpace.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/BasicNameSpace.java 2007-03-18 19:35:21 UTC (rev 3143)
@@ -0,0 +1,35 @@
+/**
+ *
+ */
+package org.jnode.apps.jpartition;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.naming.NameAlreadyBoundException;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+import org.jnode.naming.NameSpace;
+
+public final class BasicNameSpace implements NameSpace {
+ protected final Map<Class<?>, Object> namespace = new HashMap<Class<?>, Object>();
+
+ public <T> void bind(Class<T> name, T service)
+ throws NamingException, NameAlreadyBoundException {
+ namespace.put(name, service);
+ }
+
+ public <T> T lookup(Class<T> name) throws NameNotFoundException {
+ return (T) namespace.get(name);
+ }
+
+ public Set<Class<?>> nameSet() {
+ return namespace.keySet();
+ }
+
+ public void unbind(Class<?> name) {
+ namespace.remove(name);
+ }
+}
\ No newline at end of file
Added: trunk/distr/src/apps/org/jnode/apps/jpartition/FileIDEDevice.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/FileIDEDevice.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/FileIDEDevice.java 2007-03-18 19:35:21 UTC (rev 3143)
@@ -0,0 +1,86 @@
+package org.jnode.apps.jpartition;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
+
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+import org.jnode.apps.vmware.disk.VMWareDisk;
+import org.jnode.apps.vmware.disk.handler.UnsupportedFormatException;
+import org.jnode.driver.DeviceManager;
+import org.jnode.driver.DriverException;
+import org.jnode.driver.block.BlockDeviceAPIHelper;
+import org.jnode.driver.block.PartitionableBlockDeviceAPI;
+import org.jnode.driver.bus.ide.IDEConstants;
+import org.jnode.driver.bus.ide.IDEDevice;
+import org.jnode.driver.bus.ide.IDEDeviceFactory;
+import org.jnode.driver.bus.ide.IDEDriverUtils;
+import org.jnode.naming.InitialNaming;
+import org.jnode.partitions.PartitionTable;
+import org.jnode.partitions.ibm.IBMPartitionTable;
+import org.jnode.partitions.ibm.IBMPartitionTableType;
+
+public class FileIDEDevice extends IDEDevice implements PartitionableBlockDeviceAPI
+{
+ private VMWareDisk vmwareDisk;
+ private PartitionTable pt;
+
+ public FileIDEDevice(File file, long fileSize,
+ boolean primary, boolean master)
+ throws IOException, DriverException, NameNotFoundException, UnsupportedFormatException
+ {
+ super(null, primary, master, file.getName(), null, null);
+ registerAPI(PartitionableBlockDeviceAPI.class, this);
+
+ vmwareDisk = new VMWareDisk(file);
+
+ setDriver(new FileIDEDeviceDriver());
+
+ pt = buildPartitionTable();
+ }
+
+ public void flush() throws IOException {
+ vmwareDisk.flush();
+ }
+
+ public long getLength() throws IOException {
+ return vmwareDisk.getLength();
+ }
+
+ public void read(long devOffset, ByteBuffer destBuf) throws IOException {
+ BlockDeviceAPIHelper.checkBounds(this, devOffset, destBuf.remaining());
+
+ vmwareDisk.read(devOffset, destBuf);
+ }
+
+ public void write(long devOffset, ByteBuffer srcBuf) throws IOException {
+ BlockDeviceAPIHelper.checkBounds(this, devOffset, srcBuf.remaining());
+
+ vmwareDisk.write(devOffset, srcBuf);
+ }
+
+ public String toString()
+ {
+ return getId();
+ }
+
+ public PartitionTable getPartitionTable() throws IOException {
+ return pt;
+ }
+
+ public int getSectorSize() throws IOException {
+ return IDEConstants.SECTOR_SIZE;
+ }
+
+ protected PartitionTable buildPartitionTable() throws DriverException, IOException, NameNotFoundException
+ {
+ // Read the bootsector
+ final byte[] bs = new byte[IDEConstants.SECTOR_SIZE];
+ read(0, ByteBuffer.wrap(bs));
+
+ return new IBMPartitionTable(new IBMPartitionTableType(), bs, this);
+ }
+}
Added: trunk/distr/src/apps/org/jnode/apps/jpartition/FileIDEDeviceDriver.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/FileIDEDeviceDriver.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/FileIDEDeviceDriver.java 2007-03-18 19:35:21 UTC (rev 3143)
@@ -0,0 +1,32 @@
+package org.jnode.apps.jpartition;
+
+import org.jnode.driver.Driver;
+import org.jnode.driver.DriverException;
+import org.jnode.driver.DeviceAlreadyRegisteredException;
+import org.jnode.driver.bus.ide.IDEDevice;
+
+/**
+ *
+ * @author Fabien DUMINY (fduminy at jnode.org)
+ *
+ */
+public class FileIDEDeviceDriver extends Driver {
+ /**
+ * Start the device.
+ *
+ * @throws org.jnode.driver.DriverException
+ *
+ */
+ protected void startDevice() throws DriverException {
+ }
+
+ /**
+ * Stop the device.
+ *
+ * @throws org.jnode.driver.DriverException
+ *
+ */
+ protected void stopDevice() throws DriverException {
+
+ }
+}
Added: trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java 2007-03-18 19:35:21 UTC (rev 3143)
@@ -0,0 +1,60 @@
+package org.jnode.apps.jpartition;
+
+import java.util.Collection;
+
+import javax.naming.NameNotFoundException;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+
+import org.apache.log4j.Logger;
+import org.jnode.apps.jpartition.model.DevicePartitions;
+import org.jnode.apps.jpartition.model.DevicePartitionsList;
+import org.jnode.apps.jpartition.view.DevicePartitionsFrame;
+import org.jnode.apps.jpartition.view.FileDeviceFrame;
+import org.jnode.driver.Device;
+import org.jnode.driver.DeviceManager;
+import org.jnode.driver.block.PartitionableBlockDeviceAPI;
+import org.jnode.naming.InitialNaming;
+import org.jnode.naming.NameSpace;
+import org.jnode.test.fs.driver.stubs.StubDeviceManager;
+
+public class JPartition {
+ private static final Logger log = Logger.getLogger(JPartition.class);
+
+ public static void main(String[] args) throws Exception {
+ initJNodeCore();
+
+ FileDeviceFrame frm = new FileDeviceFrame();
+ frm.setSize(300, 300);
+ frm.setVisible(true);
+ frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ DevicePartitionsFrame mainUI = new DevicePartitionsFrame(getDevicePartitions());
+ mainUI.setSize(300, 300);
+ mainUI.setVisible(true);
+ mainUI.setLocation(frm.getX(), frm.getY() + frm.getHeight());
+ mainUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ }
+
+ public static DevicePartitionsList getDevicePartitions()
+ {
+ DevicePartitionsList devParts = new DevicePartitionsList();
+ try {
+ DeviceManager devMan = InitialNaming.lookup(DeviceManager.NAME);
+ Collection<Device> devices = devMan.getDevicesByAPI(PartitionableBlockDeviceAPI.class);
+ for(Device device : devices)
+ {
+ devParts.add(new DevicePartitions(device));
+ }
+ } catch (NameNotFoundException e) {
+ log.error(e);
+ }
+ return devParts;
+ }
+
+ private static void initJNodeCore() throws Exception {
+ NameSpace namespace = new BasicNameSpace();
+ InitialNaming.setNameSpace(namespace);
+ namespace.bind(DeviceManager.NAME, StubDeviceManager.INSTANCE);
+ }
+}
Added: trunk/distr/src/apps/org/jnode/apps/jpartition/controller/DevicePartitionsController.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/controller/DevicePartitionsController.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/controller/DevicePartitionsController.java 2007-03-18 19:35:21 UTC (rev 3143)
@@ -0,0 +1,58 @@
+package org.jnode.apps.jpartition.controller;
+
+import javax.naming.NameNotFoundException;
+
+import org.apache.log4j.Logger;
+import org.jnode.apps.jpartition.model.DevicePartitions;
+import org.jnode.apps.jpartition.model.DevicePartitionsList;
+import org.jnode.apps.jpartition.view.DevicePartitionsFrame;
+import org.jnode.apps.jpartition.view.DevicePartitionsUI;
+import org.jnode.driver.Device;
+import org.jnode.driver.DeviceListener;
+import org.jnode.driver.DeviceUtils;
+
+public class DevicePartitionsController implements DeviceListener
+{
+ private static final Logger log = Logger.getLogger(DevicePartitionsController.class);
+
+ private DevicePartitionsList model;
+ private DevicePartitionsFrame view;
+
+ public DevicePartitionsController(DevicePartitionsList model,
+ DevicePartitionsFrame view)
+ {
+ this.model = model;
+ this.view = view;
+
+ try {
+ DeviceUtils.getDeviceManager().addListener(this);
+ } catch (NameNotFoundException e) {
+ log.error(e);
+ }
+ }
+
+ public void deviceStarted(Device device) {
+ System.err.println("deviceStarted...");
+ DevicePartitions devPart = new DevicePartitions(device);
+ model.add(devPart);
+ view.getDevPartsUI().deviceAdded(devPart);
+ }
+
+ public void deviceStop(Device device) {
+ System.err.println("deviceStop...");
+ DevicePartitions devPartsToRemove = null;
+ for(DevicePartitions devParts : model)
+ {
+ if(device.equals(devParts.getDevice()))
+ {
+ devPartsToRemove = devParts;
+ break;
+ }
+ }
+ if(devPartsToRemove != null)
+ {
+ model.remove(devPartsToRemove);
+ view.getDevPartsUI().deviceRemoved(devPartsToRemove);
+ }
+ }
+}
Added: trunk/distr/src/apps/org/jnode/apps/jpartition/model/DevicePartitions.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/model/DevicePartitions.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/model/DevicePartitions.java 2007-03-18 19:35:21 UTC (rev 3143)
@@ -0,0 +1,73 @@
+package org.jnode.apps.jpartition.model;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.jnode.driver.ApiNotFoundException;
+import org.jnode.driver.Device;
+import org.jnode.driver.block.PartitionableBlockDeviceAPI;
+import org.jnode.partitions.PartitionTableEntry;
+import org.jnode.partitions.ibm.IBMPartitionTableEntry;
+
+public class DevicePartitions
+{
+ private static final Logger log = Logger.getLogger(DevicePartitions.class);
+
+ private final Device device;
+ private final List<Partition> partitions = new ArrayList<Partition>();
+
+ public DevicePartitions(Device device)
+ {
+ this.device = device;
+ try {
+ addPartitions(device);
+ } catch (Exception e) {
+ log.error(e);
+ }
+ }
+
+ public List<Partition> getPartitions()
+ {
+ return partitions;
+ }
+
+ protected void addPartitions(Device device) throws Exception
+ {
+ System.err.println("addPartitions");
+ if(device.implementsAPI(PartitionableBlockDeviceAPI.class))
+ {
+ System.err.println("implementsAPI");
+ partitions.clear();
+ PartitionableBlockDeviceAPI<?> api = device.getAPI(PartitionableBlockDeviceAPI.class);
+ for(PartitionTableEntry e : api.getPartitionTable())
+ {
+ System.err.println("PartitionTableEntry");
+ addPartition(e);
+ }
+ }
+ }
+
+ public void addPartition(PartitionTableEntry e)
+ {
+ if(e instanceof IBMPartitionTableEntry)
+ {
+ IBMPartitionTableEntry pte = (IBMPartitionTableEntry) e;
+ partitions.add(new Partition(pte));
+ }
+ else
+ {
+ log.warn("found non-IBMPartitionTableEntry");
+ }
+ }
+
+ public String toString()
+ {
+ return device.getId();
+ }
+
+ public Device getDevice() {
+ return device;
+ }
+}
Added: trunk/distr/src/apps/org/jnode/apps/jpartition/model/DevicePartitionsList.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/model/DevicePartitionsList.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/model/DevicePartitionsList.java 2007-03-18 19:35:21 UTC (rev 3143)
@@ -0,0 +1,7 @@
+package org.jnode.apps.jpartition.model;
+
+import java.util.ArrayList;
+
+public class DevicePartitionsList extends ArrayList<DevicePartitions>
+{
+}
Added: trunk/distr/src/apps/org/jnode/apps/jpartition/model/Partition.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/model/Partition.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/model/Partition.java 2007-03-18 19:35:21 UTC (rev 3143)
@@ -0,0 +1,40 @@
+package org.jnode.apps.jpartition.model;
+
+import org.jnode.driver.bus.ide.IDEConstants;
+import org.jnode.partitions.ibm.IBMPartitionTableEntry;
+import org.jnode.partitions.ibm.IBMPartitionTypes;
+
+public class Partition
+{
+ private final IBMPartitionTableEntry pte;
+
+ public Partition(IBMPartitionTableEntry pte)
+ {
+ this.pte = pte;
+ }
+
+ public boolean isEmpty()
+ {
+ return pte.isEmpty();
+ }
+
+ public boolean isBootable()
+ {
+ return pte.getBootIndicator();
+ }
+
+ public IBMPartitionTypes getType()
+ {
+ return pte.getSystemIndicator();
+ }
+
+ public long getStart()
+ {
+ return pte.getStartLba();
+ }
+
+ public long getSize()
+ {
+ return pte.getNrSectors() * IDEConstants.SECTOR_SIZE;
+ }
+}
Added: trunk/distr/src/apps/org/jnode/apps/jpartition/view/DevicePartitionsFrame.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/view/DevicePartitionsFrame.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/view/DevicePartitionsFrame.java 2007-03-18 19:35:21 UTC (rev 3143)
@@ -0,0 +1,28 @@
+package org.jnode.apps.jpartition.view;
+
+import javax.swing.JFrame;
+
+import org.jnode.apps.jpartition.controller.DevicePartitionsController;
+import org.jnode.apps.jpartition.model.DevicePartitionsList;
+
+public class DevicePartitionsFrame extends JFrame {
+ private DevicePartitionsUI devPartsUI;
+
+ private DevicePartitionsController controller;
+
+ public DevicePartitionsFrame(DevicePartitionsList devicePartitionsList)
+ {
+ setTitle("JPartition");
+
+ devPartsUI = new DevicePartitionsUI(devicePartitionsList);
+ add(devPartsUI);
+
+ controller = new DevicePartitionsController(devicePartitionsList, this);
+ }
+
+ public DevicePartitionsUI getDevPartsUI() {
+ return devPartsUI;
+ }
+
+
+}
Added: trunk/distr/src/apps/org/jnode/apps/jpartition/view/DevicePartitionsUI.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/view/DevicePartitionsUI.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/view/DevicePartitionsUI.java 2007-03-18 19:35:21 UTC (rev 3143)
@@ -0,0 +1,67 @@
+package org.jnode.apps.jpartition.view;
+
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JComboBox;
+import javax.swing.JPanel;
+
+import org.jnode.apps.jpartition.model.DevicePartitions;
+import org.jnode.apps.jpartition.model.DevicePartitionsList;
+import org.jnode.apps.jpartition.model.Partition;
+
+public class DevicePartitionsUI extends JPanel {
+ private DevicePartitionsList devicePartitions;
+
+ private DefaultComboBoxModel cboDevicesModel = new DefaultComboBoxModel();
+ private JComboBox cboDevices = new JComboBox(cboDevicesModel);
+ private JPanel partitionsPanel = new JPanel(new FlowLayout());
+
+ public DevicePartitionsUI(DevicePartitionsList devicePartitions)
+ {
+ super(new BorderLayout());
+ this.devicePartitions = devicePartitions;
+
+ add(cboDevices, BorderLayout.NORTH);
+ add(partitionsPanel, BorderLayout.CENTER);
+
+ for(DevicePartitions devParts : devicePartitions)
+ {
+ cboDevicesModel.addElement(devParts);
+ }
+
+ if(cboDevicesModel.getSize() > 0)
+ {
+ cboDevices.setSelectedIndex(0);
+ }
+
+ cboDevices.addItemListener(new ItemListener()
+ {
+ public void itemStateChanged(ItemEvent event) {
+ if(event.getStateChange() == ItemEvent.SELECTED)
+ {
+ System.err.println("itemStateChanged");
+ DevicePartitions devParts = (DevicePartitions) event.getItem();
+ partitionsPanel.removeAll();
+
+ for(Partition partition : devParts.getPartitions())
+ {
+ partitionsPanel.add(new PartitionUI(partition));
+ }
+ }
+ }
+ });
+ }
+
+ public void deviceAdded(DevicePartitions devParts) {
+ System.err.println("deviceAdded");
+ cboDevicesModel.addElement(devParts);
+ }
+
+ public void deviceRemoved(DevicePartitions devParts) {
+ cboDevicesModel.removeElement(devParts);
+ }
+}
Added: trunk/distr/src/apps/org/jnode/apps/jpartition/view/FileDeviceFrame.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/view/FileDeviceFrame.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/view/FileDeviceFrame.java 2007-03-18 19:35:21 UTC (rev 3143)
@@ -0,0 +1,133 @@
+package org.jnode.apps.jpartition.view;
+
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import javax.naming.NameNotFoundException;
+import javax.swing.DefaultListModel;
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JList;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+
+import org.apache.log4j.Logger;
+import org.jnode.apps.jpartition.FileIDEDevice;
+import org.jnode.driver.ApiNotFoundException;
+import org.jnode.driver.DeviceAlreadyRegisteredException;
+import org.jnode.driver.DeviceManager;
+import org.jnode.driver.DeviceNotFoundException;
+import org.jnode.driver.DeviceUtils;
+import org.jnode.driver.DriverException;
+import org.jnode.partitions.command.PartitionHelper;
+import org.jnode.partitions.ibm.IBMPartitionTypes;
+
+public class FileDeviceFrame extends JFrame
+{
+ private static final Logger log = Logger.getLogger(FileDeviceFrame.class);
+
+ private static final long DEFAULT_FILE_SIZE = 1000;
+
+ private DefaultListModel fileDevices = new DefaultListModel();
+
+ private JList devicesList = new JList(fileDevices);
+ private JPanel buttons = new JPanel();
+ private JButton addButton = new JButton("add device");
+ private JButton removeButton = new JButton("remove device");
+
+ public FileDeviceFrame() throws Exception
+ {
+ setTitle("File devices");
+ setLayout(new BorderLayout());
+ add(new JScrollPane(devicesList), BorderLayout.CENTER);
+ add(buttons, BorderLayout.SOUTH);
+
+ buttons.add(addButton);
+ buttons.add(removeButton);
+
+ addButton.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent event) {
+ JFileChooser jfc = new JFileChooser();
+ jfc.setDialogType(JFileChooser.SAVE_DIALOG);
+ int result = jfc.showSaveDialog(FileDeviceFrame.this);
+ if(result == JFileChooser.APPROVE_OPTION)
+ {
+ try
+ {
+ FileIDEDevice fd = createDevice(jfc.getSelectedFile());
+ if(addDevice(fd))
+ {
+ fileDevices.addElement(fd);
+ }
+ else
+ {
+ JOptionPane.showMessageDialog(FileDeviceFrame.this,
+ "failed to add device", "add device",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ } catch (Exception e) {
+ log.error(e);
+ }
+ }
+ }
+ });
+ removeButton.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent event) {
+ if(devicesList.getSelectedIndex() >= 0)
+ {
+ //TODO
+ }
+ }
+ });
+ }
+
+ protected FileIDEDevice createDevice(File file) throws Exception
+ {
+ //return new FileDevice(file, "rw");
+ FileIDEDevice dev = new FileIDEDevice(file, DEFAULT_FILE_SIZE,
+ true, true);
+ return dev;
+ }
+
+ private boolean addDevice(FileIDEDevice device)
+ {
+ boolean success = false;
+ try
+ {
+ DeviceManager devMan = DeviceUtils.getDeviceManager();
+ devMan.register(device);
+ success = true;
+
+ PartitionHelper helper = new PartitionHelper(device.getId(), devMan);
+ helper.initMbr();
+ helper.write();
+ helper.modifyPartition(0, true, 0, DEFAULT_FILE_SIZE,
+ false, IBMPartitionTypes.PARTTYPE_WIN95_FAT32);
+ } catch (NameNotFoundException e) {
+ log.error(e);
+ } catch (DeviceAlreadyRegisteredException e) {
+ log.error(e);
+ } catch (DriverException e) {
+ log.error(e);
+ } catch (DeviceNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ApiNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return success;
+ }
+}
Added: trunk/distr/src/apps/org/jnode/apps/jpartition/view/PartitionUI.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/view/PartitionUI.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/view/PartitionUI.java 2007-03-18 19:35:21 UTC (rev 3143)
@@ -0,0 +1,57 @@
+package org.jnode.apps.jpartition.view;
+
+import java.awt.Color;
+
+import javax.swing.BorderFactory;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+import org.jnode.apps.jpartition.model.Partition;
+
+public class PartitionUI extends JPanel
+{
+ private Partition partition = null;
+
+ private JLabel lblInfos = new JLabel();
+
+ public PartitionUI(Partition partition)
+ {
+ setPartition(partition);
+
+
+ setBorder(BorderFactory.createLineBorder(Color.BLUE, 5));
+ lblInfos.setBackground(Color.CYAN);
+ add(lblInfos);
+ }
+
+ public Partition getPartition() {
+ return partition;
+ }
+
+ public void setPartition(Partition partition) {
+ if(this.partition != partition)
+ {
+ this.partition = partition;
+ refreshFromModel();
+ }
+ }
+
+ public void refreshFromModel()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ String name = partition.getType().getName();
+ if(name.length() > 10)
+ {
+ name = name.substring(0, 10);
+ }
+ String boot = partition.isBootable() ? "(B)" : "(-)";
+ sb.append(boot).append(name);
+ if(!partition.isEmpty())
+ {
+ sb.append("-").append(partition.getStart());
+ sb.append("-").append(partition.getSize());
+ }
+ lblInfos.setText(sb.toString());
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fd...@us...> - 2007-03-19 00:35:35
|
Revision: 3141
http://jnode.svn.sourceforge.net/jnode/?rev=3141&view=rev
Author: fduminy
Date: 2007-03-18 12:26:26 -0700 (Sun, 18 Mar 2007)
Log Message:
-----------
vmware disk read/write access : alpha version
Added Paths:
-----------
trunk/distr/src/apps/org/jnode/apps/vmware/
trunk/distr/src/apps/org/jnode/apps/vmware/disk/
trunk/distr/src/apps/org/jnode/apps/vmware/disk/descriptor/
trunk/distr/src/apps/org/jnode/apps/vmware/disk/extent/
trunk/distr/src/apps/org/jnode/apps/vmware/disk/extent/Extent.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/simple/
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/simple/SimpleExtentFactory.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/AllocationTable.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/GrainTable.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/test/
trunk/distr/src/apps/org/jnode/apps/vmware/disk/test/TestVMWareDisk.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/test/Utils.java
trunk/distr/src/apps/org/jnode/apps/vmware/disk/test/disks/
trunk/distr/src/apps/org/jnode/apps/vmware/disk/test/disks/others/
Added: trunk/distr/src/apps/org/jnode/apps/vmware/disk/extent/Extent.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/vmware/disk/extent/Extent.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/vmware/disk/extent/Extent.java 2007-03-18 19:26:26 UTC (rev 3141)
@@ -0,0 +1,104 @@
+package org.jnode.apps.vmware.disk.extent;
+
+import java.io.File;
+
+import org.apache.log4j.Logger;
+import org.jnode.apps.vmware.disk.ExtentDeclaration;
+import org.jnode.apps.vmware.disk.IOUtils;
+import org.jnode.apps.vmware.disk.descriptor.Descriptor;
+import org.jnode.apps.vmware.disk.handler.sparse.SparseExtentFactory;
+
+/**
+ * Wrote from the 'Virtual Disk Format 1.0' specifications (from VMWare)
+ *
+ * @author Fabien DUMINY (fduminy at jnode dot org)
+ *
+ */
+public class Extent {
+ private static final Logger LOG = Logger.getLogger(Extent.class);
+
+ private Descriptor descriptor;
+
+ final private Access access;
+ final private long sizeInSectors; // a sector is 512 bytes
+ final private ExtentType extentType;
+ final private String fileName; // relative to the location of the descriptor
+ final private File file;
+ final private long offset;
+
+ public Extent(Descriptor descriptor, ExtentDeclaration extentDecl)
+ {
+ this.descriptor = descriptor;
+ this.access = extentDecl.getAccess();
+ this.sizeInSectors = extentDecl.getSizeInSectors();
+ this.extentType = extentDecl.getExtentType();
+ this.fileName = extentDecl.getFileName();
+ this.file = extentDecl.getExtentFile();
+ this.offset = extentDecl.getOffset();
+
+ LOG.debug("created extent for file "+file.getAbsolutePath()+
+ " offset="+offset+" fileSize="+file.length());
+ }
+
+ public Access getAccess() {
+ return access;
+ }
+
+ public long getSizeInSectors() {
+ return sizeInSectors;
+ }
+
+ public ExtentType getExtentType() {
+ return extentType;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public long getOffset() {
+ return offset;
+ }
+
+ final public Descriptor getDescriptor() {
+ return descriptor;
+ }
+
+ public void setDescriptor(Descriptor descriptor) {
+ if(this.descriptor != null)
+ {
+ throw new IllegalStateException("descriptor already assigned");
+ }
+
+ this.descriptor = descriptor;
+ }
+
+
+
+ public File getFile() {
+ return file;
+ }
+
+ @Override
+ public String toString() {
+ return "Extent["+fileName+"]";
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if(!(obj instanceof Extent))
+ {
+ return false;
+ }
+
+ Extent e = (Extent) obj;
+
+ return this.access.equals(e.access) &&
+ (this.sizeInSectors == e.sizeInSectors) &&
+ this.extentType.equals(e.extentType) &&
+ this.fileName.equals(e.fileName) &&
+ this.file.equals(e.file) &&
+ (this.offset == e.offset);
+ }
+}
Added: trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/simple/SimpleExtentFactory.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/simple/SimpleExtentFactory.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/simple/SimpleExtentFactory.java 2007-03-18 19:26:26 UTC (rev 3141)
@@ -0,0 +1,49 @@
+package org.jnode.apps.vmware.disk.handler.simple;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
+
+import org.jnode.apps.vmware.disk.ExtentDeclaration;
+import org.jnode.apps.vmware.disk.descriptor.Descriptor;
+import org.jnode.apps.vmware.disk.extent.Extent;
+import org.jnode.apps.vmware.disk.handler.ExtentFactory;
+import org.jnode.apps.vmware.disk.handler.FileDescriptor;
+import org.jnode.apps.vmware.disk.handler.IOHandler;
+import org.jnode.apps.vmware.disk.handler.UnsupportedFormatException;
+
+/**
+ * Wrote from the 'Virtual Disk Format 1.0' specifications (from VMWare)
+ *
+ * @author Fabien DUMINY (fduminy at jnode dot org)
+ *
+ */
+public class SimpleExtentFactory extends ExtentFactory
+{
+ protected FileDescriptor createFileDescriptor(File file,
+ RandomAccessFile raf, ByteBuffer bb,
+ boolean isMain)
+ throws IOException, UnsupportedFormatException
+ {
+ Descriptor descriptor = READER.read(file, bb, this);
+ return new FileDescriptor(descriptor, raf, this);
+ }
+
+ public Extent createMainExtent(Descriptor desc, ExtentDeclaration extentDecl)
+ {
+ return new Extent(desc, extentDecl);
+ }
+
+ public Extent createExtent(FileDescriptor fileDescriptor, ExtentDeclaration extentDecl)
+ throws IOException, UnsupportedFormatException
+ {
+ Descriptor desc = (fileDescriptor == null) ? null :
+ fileDescriptor.getDescriptor();
+ return createMainExtent(desc, extentDecl);
+ }
+
+ public IOHandler createIOHandler(FileDescriptor fileDescriptor) throws IOException, UnsupportedFormatException {
+ return new SimpleIOHandler(fileDescriptor);
+ }
+}
Added: trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/AllocationTable.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/AllocationTable.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/AllocationTable.java 2007-03-18 19:26:26 UTC (rev 3141)
@@ -0,0 +1,52 @@
+package org.jnode.apps.vmware.disk.handler.sparse;
+
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+/**
+ * Wrote from the 'Virtual Disk Format 1.0' specifications (from VMWare)
+ *
+ * @author Fabien DUMINY (fduminy at jnode dot org)
+ *
+ */
+public class AllocationTable {
+ private final GrainDirectory grainDirectory;
+ private final GrainTable[] grainTables;
+
+ public AllocationTable(RandomAccessFile raf, SparseExtentHeader header)
+ throws IOException
+ {
+ long nbGrains = header.getCapacity() / header.getGrainSize();
+ int nbGrainTables = (int) (nbGrains / header.getNumGTEsPerGT());
+
+ grainDirectory = new GrainDirectory(raf, nbGrainTables);
+ grainTables = new GrainTable[nbGrainTables];
+ for(int i = 0 ; i < grainTables.length ; i++)
+ {
+ grainTables[i] = new GrainTable(raf, header.getNumGTEsPerGT());
+ }
+ }
+
+ public void write(RandomAccessFile raf) throws IOException
+ {
+ grainDirectory.write(raf);
+ for(GrainTable gt : grainTables)
+ {
+ gt.write(raf);
+ }
+ }
+
+ public GrainDirectory getGrainDirectory() {
+ return grainDirectory;
+ }
+
+ public int getNbGrainTables()
+ {
+ return grainTables.length;
+ }
+
+ public GrainTable getGrainTable(int tableNum)
+ {
+ return grainTables[tableNum];
+ }
+}
Added: trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/GrainTable.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/GrainTable.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/GrainTable.java 2007-03-18 19:26:26 UTC (rev 3141)
@@ -0,0 +1,18 @@
+package org.jnode.apps.vmware.disk.handler.sparse;
+
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+/**
+ * Wrote from the 'Virtual Disk Format 1.0' specifications (from VMWare)
+ *
+ * @author Fabien DUMINY (fduminy at jnode dot org)
+ *
+ */
+public class GrainTable extends EntryArray
+{
+ public GrainTable(RandomAccessFile raf, int nbEntries) throws IOException
+ {
+ super(raf, nbEntries);
+ }
+}
Added: trunk/distr/src/apps/org/jnode/apps/vmware/disk/test/TestVMWareDisk.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/vmware/disk/test/TestVMWareDisk.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/vmware/disk/test/TestVMWareDisk.java 2007-03-18 19:26:26 UTC (rev 3141)
@@ -0,0 +1,141 @@
+package org.jnode.apps.vmware.disk.test;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jnode.apps.vmware.disk.VMWareDisk;
+import org.jnode.apps.vmware.disk.handler.IOHandler;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * Wrote from the 'Virtual Disk Format 1.0' specifications (from VMWare)
+ *
+ * @author Fabien DUMINY (fduminy at jnode dot org)
+ *
+ */
+@RunWith(value = Parameterized.class)
+public class TestVMWareDisk {
+ private static final String DISKS_PATH = "/home/fabien/data/Projets/JNode/jnode/distr/src/apps/org/jnode/apps/vmware/disk/test/disks/";
+ private static final String DISK_BASE_NAME = "Menuet32-";
+
+ private static final String RESTRICT_TO_FILE_NAME = "Menuet32-0";
+ //private static final String RESTRICT_TO_FILE_NAME = null;
+
+ @Parameters
+ public static List<File[]> data()
+ {
+ File directory = new File(DISKS_PATH);
+ File[] files = directory.listFiles(new FilenameFilter()
+ {
+ public boolean accept(File dir, String name) {
+ boolean ok = name.matches(DISK_BASE_NAME + "[0-9]*.vmdk");
+
+ if(RESTRICT_TO_FILE_NAME != null)
+ {
+ ok &= name.startsWith(RESTRICT_TO_FILE_NAME);
+ }
+
+ return ok;
+ }
+ });
+ List<File[]> list = new ArrayList<File[]>(files.length);
+ for(File f : files)
+ {
+ list.add(new File[]{f});
+ }
+
+ return list;
+ }
+
+ final private File originalDiskFile;
+ private File diskFile;
+
+ public TestVMWareDisk(File diskFile) throws IOException
+ {
+ super();
+ this.originalDiskFile = diskFile;
+ }
+
+ @Before
+ public void setUp() throws IOException
+ {
+ this.diskFile = Utils.copyDisk(originalDiskFile);
+ }
+
+ @After
+ public void tearDown() throws IOException
+ {
+ Utils.clearTempDir(true);
+ }
+
+ @Test
+ public void read() throws Exception
+ {
+ VMWareDisk disk = new VMWareDisk(diskFile);
+
+ ByteBuffer data = ByteBuffer.allocate(IOHandler.SECTOR_SIZE * 100);
+ disk.read(0, data);
+
+ Assert.assertEquals(toString()+": buffer should be filled", 0, data.remaining());
+ }
+
+ @Test
+ public void write() throws Exception
+ {
+ VMWareDisk disk = new VMWareDisk(diskFile);
+
+ ByteBuffer data = ByteBuffer.allocate(IOHandler.SECTOR_SIZE * 100);
+ disk.write(0, data);
+
+ Assert.assertEquals(toString()+": buffer should be fully copied", 0, data.remaining());
+ }
+
+ @Test
+ public void writeAndRead() throws Exception
+ {
+ VMWareDisk disk = new VMWareDisk(diskFile);
+
+ // write
+ int size = IOHandler.SECTOR_SIZE * 100;
+ ByteBuffer expectedData = ByteBuffer.allocate(size);
+ for(int i = 0 ; i < (size / 4) ; i++)
+ {
+ expectedData.putInt(i);
+ }
+ expectedData.rewind();
+ disk.write(0, expectedData);
+ disk.flush();
+
+ // read
+ VMWareDisk disk2 = new VMWareDisk(diskFile);
+ Assert.assertEquals("disk has different size", disk.getLength(), disk2.getLength());
+ Assert.assertEquals("disk has different descriptor", disk.getDescriptor(), disk2.getDescriptor());
+
+ expectedData.rewind();
+ ByteBuffer actualData = ByteBuffer.allocate(size);
+ disk2.read(0, actualData);
+ for(int i = 0 ; i < (size / 4) ; i++)
+ {
+ int actual = actualData.getInt(i);
+ int expected = expectedData.getInt();
+ Assert.assertEquals("bad data at index "+(i*4), expected, actual);
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return diskFile.getName();
+ }
+}
Added: trunk/distr/src/apps/org/jnode/apps/vmware/disk/test/Utils.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/vmware/disk/test/Utils.java (rev 0)
+++ trunk/distr/src/apps/org/jnode/apps/vmware/disk/test/Utils.java 2007-03-18 19:26:26 UTC (rev 3141)
@@ -0,0 +1,135 @@
+package org.jnode.apps.vmware.disk.test;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.nio.channels.FileChannel;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Wrote from the 'Virtual Disk Format 1.0' specifications (from VMWare)
+ *
+ * @author Fabien DUMINY (fduminy at jnode dot org)
+ *
+ */
+public class Utils {
+ private static final Logger LOG = Logger.getLogger(Utils.class);
+
+ private static final String TEMP_DIR = "VMWareDisk";
+
+ public static File createTempDir() throws IOException
+ {
+ String tmpDir = System.getProperty("java.io.tmpdir");
+ File dir = new File(tmpDir, TEMP_DIR);
+ if(!dir.exists())
+ {
+ if(!dir.mkdir())
+ {
+ throw new IOException("can't create directory "+dir);
+ }
+ }
+ else
+ {
+ clearTempDir(false);
+ }
+
+ return dir;
+ }
+
+ public static void clearTempDir(boolean deleteDir) throws IOException
+ {
+ String tmpDir = System.getProperty("java.io.tmpdir");
+ File dir = new File(tmpDir, TEMP_DIR);
+ if(dir.exists())
+ {
+ for(File tmpFile : dir.listFiles())
+ {
+ LOG.debug("deleting file "+tmpFile);
+ tmpFile.delete();
+ }
+ }
+
+ if(deleteDir)
+ {
+ dir.delete();
+ }
+ }
+
+ public static File copyDisk(final File mainFile) throws IOException
+ {
+ final String name = mainFile.getName();
+ final int idx = name.lastIndexOf('.');
+ final String beginName = name.substring(0, idx);
+ final String endName = name.substring(idx);
+
+ final File parentDir = mainFile.getParentFile();
+ File[] files = parentDir.listFiles(new FilenameFilter()
+ {
+ public boolean accept(File dir, String name) {
+ boolean ok = name.startsWith(beginName) &&
+ name.endsWith(endName);
+ return ok;
+ }
+ });
+
+ File tmpDir = createTempDir();
+
+ File mainFileCopy = null;
+ for(File file : files)
+ {
+ File f = copyFile(file, tmpDir);
+ if(file.getName().equals(mainFile.getName()))
+ {
+ mainFileCopy = f;
+ }
+ }
+
+ return mainFileCopy;
+ }
+
+ public static File copyFile(File file, File dir) throws IOException
+ {
+ LOG.debug("copying file "+file.getName()+" to "+dir.getName());
+ FileInputStream fis = null;
+ FileOutputStream fos = null;
+ File outFile = null;
+
+ try
+ {
+ fis = new FileInputStream(file);
+ FileChannel inCh = fis.getChannel();
+
+ outFile = new File(dir, file.getName());
+ fos = new FileOutputStream(outFile);
+ FileChannel outCh = fos.getChannel();
+
+ outCh.transferFrom(inCh, 0, inCh.size());
+
+ return outFile;
+ }
+ catch(IOException ioe)
+ {
+ ioe.printStackTrace();
+ throw ioe;
+ }
+ finally
+ {
+ try {
+ if(fos != null)
+ {
+ fos.close();
+ }
+ }
+ finally
+ {
+ if(fis != null)
+ {
+ fis.close();
+ }
+ }
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|