diff options
author | Victor Mocanu | 2017-07-14 12:27:20 +0200 |
---|---|---|
committer | Victor Mocanu | 2017-07-14 12:27:20 +0200 |
commit | 34324ee6048646a5459686d8a65d3da6c9111d95 (patch) | |
tree | 4f187d44cf3e3588a4cbdac8e6ab0724130a0fff /src/main/java/org/openslx/util/vm/DiskImage.java | |
parent | [VBox] added function to change atribute value of a given tag (diff) | |
download | master-sync-shared-34324ee6048646a5459686d8a65d3da6c9111d95.tar.gz master-sync-shared-34324ee6048646a5459686d8a65d3da6c9111d95.tar.xz master-sync-shared-34324ee6048646a5459686d8a65d3da6c9111d95.zip |
[VBox] added handling for vdi files
Diffstat (limited to 'src/main/java/org/openslx/util/vm/DiskImage.java')
-rw-r--r-- | src/main/java/org/openslx/util/vm/DiskImage.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main/java/org/openslx/util/vm/DiskImage.java b/src/main/java/org/openslx/util/vm/DiskImage.java index 94d5d2c..cc0be88 100644 --- a/src/main/java/org/openslx/util/vm/DiskImage.java +++ b/src/main/java/org/openslx/util/vm/DiskImage.java @@ -4,6 +4,8 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; import org.openslx.bwlp.thrift.iface.Virtualizer; import org.openslx.util.Util; @@ -15,6 +17,7 @@ public class DiskImage * Big endian representation of the 4 bytes 'KDMV' */ private static final int VMDK_MAGIC = 0x4b444d56; + private static final String VDI_MAGIC = "<<< Oracle VM VirtualBox Disk Image >>>"; public enum ImageFormat { @@ -88,7 +91,19 @@ public class DiskImage } // vdi file.seek( 0 ); - // TODO + byte[] buffer = new byte[ VDI_MAGIC.length() ]; + file.readFully( buffer ); + String string = new String( buffer ); + if ( VDI_MAGIC.equals( string ) ) + { + this.isStandalone = true; + this.isCompressed = false; + this.isSnapshot = false; + this.format = ImageFormat.VDI; + this.subFormat = ""; + this.hwVersion = 0; + return; + } } throw new UnknownImageFormatException(); } |