├── .gitignore ├── .looper.yml ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── java │ └── io │ │ └── takari │ │ └── jdkget │ │ ├── Arch.java │ │ ├── CachingOutput.java │ │ ├── IJdkExtractor.java │ │ ├── IOutput.java │ │ ├── ITransport.java │ │ ├── ITransportFactory.java │ │ ├── JCEExtractor.java │ │ ├── JdkGetter.java │ │ ├── Main.java │ │ ├── MirrorRemote.java │ │ ├── StdOutput.java │ │ ├── Util.java │ │ ├── extract │ │ ├── AbstractTarJDKExtractor.java │ │ ├── AbstractZipExtractor.java │ │ ├── BinJDKExtractor.java │ │ ├── OsxJDKExtractor.java │ │ ├── TZJDKExtractor.java │ │ ├── TgzJDKExtractor.java │ │ ├── WindowsJDKExtractor.java │ │ └── ZipJDKExtractor.java │ │ ├── model │ │ ├── BinaryType.java │ │ ├── JCE.java │ │ ├── JavaReleasesData.java │ │ ├── JdkBinary.java │ │ ├── JdkRelease.java │ │ ├── JdkReleases.java │ │ ├── JdkReleasesParser.java │ │ └── JdkVersion.java │ │ ├── oracle │ │ ├── OracleTransportFactory.java │ │ └── OracleWebsiteTransport.java │ │ ├── osx │ │ ├── PosixModes.java │ │ ├── UnHFS.java │ │ ├── csjc │ │ │ ├── AbstractStruct.java │ │ │ ├── DynamicStruct.java │ │ │ ├── MutableStruct.java │ │ │ ├── PrintableStruct.java │ │ │ ├── StaticStruct.java │ │ │ ├── StructElements.java │ │ │ └── structelements │ │ │ │ ├── ASCIIStringField.java │ │ │ │ ├── Array.java │ │ │ │ ├── ArrayBuilder.java │ │ │ │ ├── BooleanRepresentableField.java │ │ │ │ ├── ByteArrayDataHandle.java │ │ │ │ ├── ByteArrayField.java │ │ │ │ ├── DataHandle.java │ │ │ │ ├── Dictionary.java │ │ │ │ ├── DictionaryBuilder.java │ │ │ │ ├── EncodedStringField.java │ │ │ │ ├── Endianness.java │ │ │ │ ├── Field.java │ │ │ │ ├── FieldType.java │ │ │ │ ├── FlagField.java │ │ │ │ ├── IntegerField.java │ │ │ │ ├── IntegerFieldBits.java │ │ │ │ ├── IntegerFieldDataHandle.java │ │ │ │ ├── IntegerFieldRepresentation.java │ │ │ │ ├── Signedness.java │ │ │ │ ├── StringRepresentableField.java │ │ │ │ └── StructElement.java │ │ ├── dmg │ │ │ └── udif │ │ │ │ ├── Debug.java │ │ │ │ ├── Koly.java │ │ │ │ ├── Koly.struct │ │ │ │ ├── Plist.java │ │ │ │ ├── PlistPartition.java │ │ │ │ ├── UDIFBlock.java │ │ │ │ ├── UDIFBlockInputStream.java │ │ │ │ ├── UDIFDetector.java │ │ │ │ ├── UDIFFile.java │ │ │ │ ├── UDIFFileView.java │ │ │ │ └── UDIFRandomAccessStream.java │ │ ├── hfs │ │ │ ├── AllocationFile.java │ │ │ ├── AttributesFile.java │ │ │ ├── BTreeFile.java │ │ │ ├── CatalogFile.java │ │ │ ├── ExtentsOverflowFile.java │ │ │ ├── FastUnicodeCompare.java │ │ │ ├── HFSVolume.java │ │ │ ├── HotFilesFile.java │ │ │ ├── Journal.java │ │ │ ├── ProgressMonitor.java │ │ │ ├── UnicodeNormalizationToolkit.java │ │ │ ├── io │ │ │ │ ├── ForkFilter.java │ │ │ │ └── ReadableBlockCachingStream.java │ │ │ ├── original │ │ │ │ ├── CharsetStringCodec.java │ │ │ │ ├── HFSOriginalAllocationFile.java │ │ │ │ ├── HFSOriginalVolume.java │ │ │ │ ├── MutableStringCodec.java │ │ │ │ └── StringCodec.java │ │ │ ├── plus │ │ │ │ ├── HFSPlusAllocationFile.java │ │ │ │ ├── HFSPlusJournal.java │ │ │ │ └── HFSPlusVolume.java │ │ │ ├── types │ │ │ │ ├── carbon │ │ │ │ │ ├── FourCharCode.java │ │ │ │ │ ├── OSType.java │ │ │ │ │ ├── OSType.struct │ │ │ │ │ ├── Point.java │ │ │ │ │ ├── Point.struct │ │ │ │ │ ├── Rect.java │ │ │ │ │ └── Rect.struct │ │ │ │ ├── decmpfs │ │ │ │ │ ├── DecmpfsHeader.java │ │ │ │ │ └── DecmpfsHeader.struct │ │ │ │ ├── finder │ │ │ │ │ ├── CommonExtendedFinderInfo.java │ │ │ │ │ ├── CommonFinderInfo.java │ │ │ │ │ ├── DInfo.java │ │ │ │ │ ├── DInfo.struct │ │ │ │ │ ├── DXInfo.java │ │ │ │ │ ├── DXInfo.struct │ │ │ │ │ ├── ExtendedFileInfo.java │ │ │ │ │ ├── ExtendedFileInfo.struct │ │ │ │ │ ├── ExtendedFolderInfo.java │ │ │ │ │ ├── ExtendedFolderInfo.struct │ │ │ │ │ ├── FInfo.java │ │ │ │ │ ├── FInfo.struct │ │ │ │ │ ├── FXInfo.java │ │ │ │ │ ├── FXInfo.struct │ │ │ │ │ ├── FileInfo.java │ │ │ │ │ ├── FileInfo.struct │ │ │ │ │ ├── FolderInfo.java │ │ │ │ │ └── FolderInfo.struct │ │ │ │ ├── hfs │ │ │ │ │ ├── BTHdrRec.java │ │ │ │ │ ├── BTHdrRec.struct │ │ │ │ │ ├── BootBlkHdr.struct │ │ │ │ │ ├── CatDataRec.java │ │ │ │ │ ├── CatDataRec.struct │ │ │ │ │ ├── CatKeyRec.java │ │ │ │ │ ├── CatKeyRec.struct │ │ │ │ │ ├── CdrDirRec.java │ │ │ │ │ ├── CdrDirRec.struct │ │ │ │ │ ├── CdrFThdRec.java │ │ │ │ │ ├── CdrFThdRec.struct │ │ │ │ │ ├── CdrFilRec.java │ │ │ │ │ ├── CdrFilRec.struct │ │ │ │ │ ├── CdrThdRec.java │ │ │ │ │ ├── CdrThdRec.struct │ │ │ │ │ ├── ExtDataRec.java │ │ │ │ │ ├── ExtDataRec.struct │ │ │ │ │ ├── ExtDescriptor.java │ │ │ │ │ ├── ExtDescriptor.struct │ │ │ │ │ ├── ExtKeyRec.java │ │ │ │ │ ├── ExtKeyRec.struct │ │ │ │ │ ├── HFSDate.java │ │ │ │ │ ├── HFSDateField.java │ │ │ │ │ ├── HFSPlusWrapperMDB.java │ │ │ │ │ ├── HFSPlusWrapperMDB.struct │ │ │ │ │ ├── HFSVolumeFinderInfo.java │ │ │ │ │ ├── HFSVolumeFinderInfo.struct │ │ │ │ │ ├── MacLegacyEncoding.java │ │ │ │ │ ├── MasterDirectoryBlock.java │ │ │ │ │ ├── MasterDirectoryBlock.struct │ │ │ │ │ ├── NodeDescriptor.java │ │ │ │ │ └── NodeDescriptor.struct │ │ │ │ ├── hfscommon │ │ │ │ │ ├── CommonBTGenericDataRecord.java │ │ │ │ │ ├── CommonBTHeaderNode.java │ │ │ │ │ ├── CommonBTHeaderRecord.java │ │ │ │ │ ├── CommonBTIndexRecord.java │ │ │ │ │ ├── CommonBTKey.java │ │ │ │ │ ├── CommonBTKeyedNode.java │ │ │ │ │ ├── CommonBTKeyedRecord.java │ │ │ │ │ ├── CommonBTLeafRecord.java │ │ │ │ │ ├── CommonBTNode.java │ │ │ │ │ ├── CommonBTNodeDescriptor.java │ │ │ │ │ ├── CommonBTRecord.java │ │ │ │ │ ├── CommonHFSAttributesIndexNode.java │ │ │ │ │ ├── CommonHFSAttributesKey.java │ │ │ │ │ ├── CommonHFSAttributesLeafNode.java │ │ │ │ │ ├── CommonHFSAttributesLeafRecord.java │ │ │ │ │ ├── CommonHFSCatalogAttributes.java │ │ │ │ │ ├── CommonHFSCatalogFile.java │ │ │ │ │ ├── CommonHFSCatalogFileRecord.java │ │ │ │ │ ├── CommonHFSCatalogFileThread.java │ │ │ │ │ ├── CommonHFSCatalogFileThreadRecord.java │ │ │ │ │ ├── CommonHFSCatalogFolder.java │ │ │ │ │ ├── CommonHFSCatalogFolderRecord.java │ │ │ │ │ ├── CommonHFSCatalogFolderThread.java │ │ │ │ │ ├── CommonHFSCatalogFolderThreadRecord.java │ │ │ │ │ ├── CommonHFSCatalogIndexNode.java │ │ │ │ │ ├── CommonHFSCatalogKey.java │ │ │ │ │ ├── CommonHFSCatalogLeafNode.java │ │ │ │ │ ├── CommonHFSCatalogLeafRecord.java │ │ │ │ │ ├── CommonHFSCatalogNodeID.java │ │ │ │ │ ├── CommonHFSCatalogString.java │ │ │ │ │ ├── CommonHFSCatalogThread.java │ │ │ │ │ ├── CommonHFSCatalogThreadRecord.java │ │ │ │ │ ├── CommonHFSExtentDescriptor.java │ │ │ │ │ ├── CommonHFSExtentIndexNode.java │ │ │ │ │ ├── CommonHFSExtentKey.java │ │ │ │ │ ├── CommonHFSExtentLeafNode.java │ │ │ │ │ ├── CommonHFSExtentLeafRecord.java │ │ │ │ │ ├── CommonHFSFinderInfo.java │ │ │ │ │ ├── CommonHFSForkData.java │ │ │ │ │ ├── CommonHFSForkType.java │ │ │ │ │ ├── CommonHFSVolumeHeader.java │ │ │ │ │ └── StringComparator.java │ │ │ │ ├── hfsplus │ │ │ │ │ ├── BTHeaderRec.java │ │ │ │ │ ├── BTKey.java │ │ │ │ │ ├── BTNodeDescriptor.java │ │ │ │ │ ├── BlockInfo.java │ │ │ │ │ ├── BlockInfo.struct │ │ │ │ │ ├── BlockList.java │ │ │ │ │ ├── BlockListHeader.java │ │ │ │ │ ├── BlockListHeader.struct │ │ │ │ │ ├── HFSCatalogNodeID.java │ │ │ │ │ ├── HFSPlusAttributesData.java │ │ │ │ │ ├── HFSPlusAttributesData.struct │ │ │ │ │ ├── HFSPlusAttributesExtents.java │ │ │ │ │ ├── HFSPlusAttributesExtents.struct │ │ │ │ │ ├── HFSPlusAttributesForkData.java │ │ │ │ │ ├── HFSPlusAttributesForkData.struct │ │ │ │ │ ├── HFSPlusAttributesKey.java │ │ │ │ │ ├── HFSPlusAttributesKey.struct │ │ │ │ │ ├── HFSPlusAttributesLeafRecord.java │ │ │ │ │ ├── HFSPlusAttributesLeafRecordData.java │ │ │ │ │ ├── HFSPlusBSDInfo.java │ │ │ │ │ ├── HFSPlusBSDInfo.struct │ │ │ │ │ ├── HFSPlusCatalogAttributes.java │ │ │ │ │ ├── HFSPlusCatalogFile.java │ │ │ │ │ ├── HFSPlusCatalogFile.struct │ │ │ │ │ ├── HFSPlusCatalogFolder.java │ │ │ │ │ ├── HFSPlusCatalogFolder.struct │ │ │ │ │ ├── HFSPlusCatalogKey.java │ │ │ │ │ ├── HFSPlusCatalogKey.struct │ │ │ │ │ ├── HFSPlusCatalogLeafRecordData.java │ │ │ │ │ ├── HFSPlusCatalogThread.java │ │ │ │ │ ├── HFSPlusCatalogThread.struct │ │ │ │ │ ├── HFSPlusDate.java │ │ │ │ │ ├── HFSPlusDateField.java │ │ │ │ │ ├── HFSPlusExtentDescriptor.java │ │ │ │ │ ├── HFSPlusExtentDescriptor.struct │ │ │ │ │ ├── HFSPlusExtentKey.java │ │ │ │ │ ├── HFSPlusExtentKey.struct │ │ │ │ │ ├── HFSPlusExtentLeafRecord.struct │ │ │ │ │ ├── HFSPlusExtentRecord.java │ │ │ │ │ ├── HFSPlusExtentRecord.struct │ │ │ │ │ ├── HFSPlusForkData.java │ │ │ │ │ ├── HFSPlusForkData.struct │ │ │ │ │ ├── HFSPlusVolumeHeader.java │ │ │ │ │ ├── HFSUniStr255.java │ │ │ │ │ ├── HFSUniStr255.struct │ │ │ │ │ ├── JournalHeader.java │ │ │ │ │ ├── JournalHeader.struct │ │ │ │ │ ├── JournalInfoBlock.java │ │ │ │ │ └── JournalInfoBlock.struct │ │ │ │ └── hfsx │ │ │ │ │ ├── HFSXCatalogKey.java │ │ │ │ │ └── HFSXKeyCompareType.java │ │ │ └── x │ │ │ │ └── HFSXVolume.java │ │ ├── hfsexplorer │ │ │ ├── IOUtil.java │ │ │ ├── Java7Util.java │ │ │ ├── Util.java │ │ │ ├── fs │ │ │ │ ├── AppleSingleBuilder.java │ │ │ │ ├── NullProgressMonitor.java │ │ │ │ └── ResourceForkReader.java │ │ │ ├── io │ │ │ │ ├── RandomAccessChannel.java │ │ │ │ └── WritableRandomAccessChannel.java │ │ │ └── types │ │ │ │ ├── applesingle │ │ │ │ ├── AppleSingleHeader.java │ │ │ │ ├── AppleSingleHeader.struct │ │ │ │ ├── AttributeEntry.java │ │ │ │ ├── AttributeEntry.struct │ │ │ │ ├── AttributeHeader.java │ │ │ │ ├── AttributeHeader.struct │ │ │ │ ├── EntryDescriptor.java │ │ │ │ └── EntryDescriptor.struct │ │ │ │ └── resff │ │ │ │ ├── ReferenceListEntry.java │ │ │ │ ├── ReferenceListEntry.struct │ │ │ │ ├── ResourceHeader.java │ │ │ │ ├── ResourceHeader.struct │ │ │ │ ├── ResourceMap.java │ │ │ │ ├── ResourceMap.struct │ │ │ │ ├── ResourceName.java │ │ │ │ ├── ResourceName.struct │ │ │ │ ├── ResourceType.java │ │ │ │ └── ResourceType.struct │ │ ├── io │ │ │ ├── .cvsignore │ │ │ ├── BasicConcatenatedStream.java │ │ │ ├── BasicReadable.java │ │ │ ├── BasicReadableRandomAccessStream.java │ │ │ ├── BasicSynchronizedReadableRandomAccessStream.java │ │ │ ├── BasicWritable.java │ │ │ ├── ByteCountInputStream.java │ │ │ ├── CharByCharReader.java │ │ │ ├── ConcatenatedReader.java │ │ │ ├── ConcatenatedStream.java │ │ │ ├── IOLog.java │ │ │ ├── InputStreamReadable.java │ │ │ ├── OutputStreamWritable.java │ │ │ ├── RandomAccess.java │ │ │ ├── RandomAccessInputStream.java │ │ │ ├── RandomAccessStream.java │ │ │ ├── Readable.java │ │ │ ├── ReadableByteArrayStream.java │ │ │ ├── ReadableConcatenatedStream.java │ │ │ ├── ReadableFileStream.java │ │ │ ├── ReadableFilterStream.java │ │ │ ├── ReadableRandomAccessInputStream.java │ │ │ ├── ReadableRandomAccessStream.java │ │ │ ├── ReadableRandomAccessSubstream.java │ │ │ ├── ReaderInputStream.java │ │ │ ├── RuntimeIOException.java │ │ │ ├── Stream.java │ │ │ ├── SynchronizedRandomAccessStream.java │ │ │ ├── SynchronizedReadable.java │ │ │ ├── SynchronizedReadableRandomAccess.java │ │ │ ├── SynchronizedReadableRandomAccessStream.java │ │ │ ├── TruncatableRandomAccess.java │ │ │ ├── TruncatableRandomAccessStream.java │ │ │ ├── Writable.java │ │ │ └── WritableRandomAccessStream.java │ │ ├── plist │ │ │ ├── PlistNode.java │ │ │ ├── XmlPlist.java │ │ │ └── XmlPlistNode.java │ │ ├── storage │ │ │ ├── fs │ │ │ │ ├── BasicFSEntry.java │ │ │ │ ├── DefaultFileSystemHandlerInfo.java │ │ │ │ ├── FSAttributes.java │ │ │ │ ├── FSEntry.java │ │ │ │ ├── FSFile.java │ │ │ │ ├── FSFolder.java │ │ │ │ ├── FSFork.java │ │ │ │ ├── FSForkType.java │ │ │ │ ├── FSLink.java │ │ │ │ ├── FileSystemCapability.java │ │ │ │ ├── FileSystemDetector.java │ │ │ │ ├── FileSystemHandler.java │ │ │ │ ├── FileSystemHandlerFactory.java │ │ │ │ ├── FileSystemHandlerInfo.java │ │ │ │ ├── FileSystemMajorType.java │ │ │ │ ├── FileSystemRecognizer.java │ │ │ │ ├── WindowsFileAttributes.java │ │ │ │ ├── hfs │ │ │ │ │ ├── HFSFileSystemHandler.java │ │ │ │ │ ├── HFSFileSystemHandlerFactory.java │ │ │ │ │ └── HFSFileSystemRecognizer.java │ │ │ │ ├── hfscommon │ │ │ │ │ ├── HFSCommonAbstractFile.java │ │ │ │ │ ├── HFSCommonAttributeFork.java │ │ │ │ │ ├── HFSCommonFSAttributes.java │ │ │ │ │ ├── HFSCommonFSEntry.java │ │ │ │ │ ├── HFSCommonFSFile.java │ │ │ │ │ ├── HFSCommonFSFolder.java │ │ │ │ │ ├── HFSCommonFSFork.java │ │ │ │ │ ├── HFSCommonFSLink.java │ │ │ │ │ ├── HFSCommonFileSystemHandler.java │ │ │ │ │ ├── HFSCommonFileSystemHandlerFactory.java │ │ │ │ │ ├── HFSCommonFileSystemRecognizer.java │ │ │ │ │ └── HFSCommonFinderInfoFork.java │ │ │ │ ├── hfsplus │ │ │ │ │ ├── HFSPlusCompressedDataFork.java │ │ │ │ │ ├── HFSPlusFSFile.java │ │ │ │ │ ├── HFSPlusFileSystemHandler.java │ │ │ │ │ ├── HFSPlusFileSystemHandlerFactory.java │ │ │ │ │ └── HFSPlusFileSystemRecognizer.java │ │ │ │ └── hfsx │ │ │ │ │ ├── HFSXFileSystemHandler.java │ │ │ │ │ ├── HFSXFileSystemHandlerFactory.java │ │ │ │ │ └── HFSXFileSystemRecognizer.java │ │ │ ├── io │ │ │ │ ├── DataLocator.java │ │ │ │ ├── ReadableStreamDataLocator.java │ │ │ │ └── SubDataLocator.java │ │ │ └── ps │ │ │ │ ├── Partition.java │ │ │ │ ├── PartitionSystemDetector.java │ │ │ │ ├── PartitionSystemHandler.java │ │ │ │ ├── PartitionSystemHandlerFactory.java │ │ │ │ ├── PartitionSystemImplementationInfo.java │ │ │ │ ├── PartitionSystemRecognizer.java │ │ │ │ ├── PartitionSystemType.java │ │ │ │ ├── PartitionType.java │ │ │ │ ├── apm │ │ │ │ ├── APMHandler.java │ │ │ │ ├── APMHandlerFactory.java │ │ │ │ ├── APMPartitionType.java │ │ │ │ ├── APMRecognizer.java │ │ │ │ └── types │ │ │ │ │ ├── APMPartition.java │ │ │ │ │ ├── ApplePartitionMap.java │ │ │ │ │ ├── DriverDescriptorEntry.java │ │ │ │ │ ├── DriverDescriptorEntry.struct │ │ │ │ │ ├── DriverDescriptorRecord.java │ │ │ │ │ └── DriverDescriptorRecord.struct │ │ │ │ ├── container │ │ │ │ ├── ContainerHandler.java │ │ │ │ ├── ContainerHandlerFactory.java │ │ │ │ ├── ContainerType.java │ │ │ │ └── hfs │ │ │ │ │ └── HFSContainerHandlerFactory.java │ │ │ │ ├── ebr │ │ │ │ ├── EBRHandler.java │ │ │ │ ├── EBRHandlerFactory.java │ │ │ │ ├── EBRPartition.java │ │ │ │ ├── EBRPartitionSystem.java │ │ │ │ ├── EBRRecognizer.java │ │ │ │ ├── ExtendedBootRecord.java │ │ │ │ └── types │ │ │ │ │ └── DOSExtendedPartitionSystem.java │ │ │ │ ├── gpt │ │ │ │ ├── GPTHandler.java │ │ │ │ ├── GPTHandlerFactory.java │ │ │ │ ├── GPTPartitionType.java │ │ │ │ ├── GPTRecognizer.java │ │ │ │ └── types │ │ │ │ │ ├── GPTEntry.java │ │ │ │ │ ├── GPTEntry.struct │ │ │ │ │ ├── GPTHeader.java │ │ │ │ │ ├── GUID.java │ │ │ │ │ └── GUIDPartitionTable.java │ │ │ │ ├── legacy │ │ │ │ └── PartitionSystem.java │ │ │ │ └── mbr │ │ │ │ ├── MBRHandler.java │ │ │ │ ├── MBRHandlerFactory.java │ │ │ │ ├── MBRPartitionType.java │ │ │ │ ├── MBRRecognizer.java │ │ │ │ └── types │ │ │ │ ├── MBRPartition.java │ │ │ │ ├── MBRPartitionTable.java │ │ │ │ └── MasterBootRecord.java │ │ ├── util │ │ │ ├── IOUtil.java │ │ │ ├── ObjectContainer.java │ │ │ └── Util.java │ │ └── xml │ │ │ ├── Attribute.java │ │ │ ├── Attribute2.java │ │ │ ├── DebugXMLContentHandler.java │ │ │ ├── ExternalID.java │ │ │ ├── NodeBuilder.java │ │ │ ├── NodeBuilderContentHandler.java │ │ │ ├── NullXMLContentHandler.java │ │ │ ├── XMLContentHandler.java │ │ │ ├── XMLElement.java │ │ │ ├── XMLNode.java │ │ │ ├── XMLText.java │ │ │ └── apx │ │ │ ├── APXParser.java │ │ │ ├── APXParser.jj │ │ │ ├── APXParserConstants.java │ │ │ ├── APXParserTokenManager.java │ │ │ ├── ParseException.java │ │ │ ├── SimpleCharStream.java │ │ │ ├── Token.java │ │ │ └── TokenMgrError.java │ │ └── win │ │ ├── ByteSource.java │ │ ├── CabConstants.java │ │ ├── CabDecompressor.java │ │ ├── CabEntry.java │ │ ├── CabIO.java │ │ ├── CabInput.java │ │ ├── Cabinet.java │ │ └── LzxDecompressionMethod.java └── resources │ ├── java_releases_v1.yml │ └── jdkreleases.xml └── test └── java └── io └── takari └── jdkget ├── DumbTransport.java ├── JdkGetterTest.java ├── SleepingTransport.java ├── VersionsTest.java └── it └── LoadAllIT.java /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .project 3 | .classpath 4 | .settings/ 5 | .idea 6 | *.iml 7 | *.ipr 8 | *.iws 9 | .DS_Store 10 | image 11 | -------------------------------------------------------------------------------- /.looper.yml: -------------------------------------------------------------------------------- 1 | language: workflow 2 | 3 | tools: 4 | jdk: 5 | - 1.8.0_91-b14 6 | maven: 7 | - 3.3.9 8 | 9 | flows: 10 | master: 11 | - (on master, name mvn clean install) mvn clean install -B 12 | pr: 13 | - call: master 14 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takari/jdkget/9acdc42e9251e3113e161da78d20f23393d58616/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JdkGet 2 | 3 | JdkGet is a Java utility that allows you to download Linux/OSX/Windows JDKs from Oracle, and extract them in arbitrary directories in a fully automated way. 4 | 5 | To install a JDK you can use something like the following: 6 | 7 | ```java 8 | JdkReleases rels = JdkReleases.get(); 9 | ITransport transport = createTransportFactory().createTransport(); 10 | 11 | JdkRelease rel = rels.select("8u201"); 12 | JCE jce = rels.getJCE(rel.getVersion()); 13 | 14 | JdkGetter getter = new JdkGetter(transport, StdOutput.INSTANCE); 15 | 16 | File outputDir = ...; 17 | getter.getJdk(rel, jce, Arch.autodetect(), outputDir); 18 | ``` 19 | 20 | You can find a list of available JDKs [here](src/main/resources/java_releases_v1.yml). 21 | 22 | By using this utilitiy you agree to the [Oracle Binary Code License Agreement for Java SE][1]. 23 | 24 | ## Building 25 | 26 | To build JDKGet use the Maven Wrapper script provided with the project: 27 | 28 | ``` 29 | ./mvnw clean install 30 | ``` 31 | 32 | ## Integration testing 33 | 34 | Testing downloads of all versions can be performed using `it` profile and providing your OTN credentials: 35 | 36 | ``` 37 | mvn clean verify -Pit -Dio.takari.jdkget.username= -Dio.takari.jdkget.password= 38 | ``` 39 | 40 | The result will produce a shaded JAR in the `target/` directory which can we executed using `java -jar jdkget-${version}.jar` 41 | 42 | ## *nix and Solaris 43 | Downloads and extracts a .tar.gz, simple and easy 44 | 45 | ## OSX 46 | This will retrieve the Java equivalent of a [turducken][2]: the GZipped CPIO files of the JDK, wrapped in an XAR file, inside an HFS disk image. Can't we just use TarGz files? No, no, that would be too easy. 47 | 48 | ## Windows 49 | Similar to OSX, but with tools.zip (with some jars pack200'd) in CAB in EXE in EXE. 50 | 51 | ## NOTES 52 | 53 | - https://ivan-site.com/2012/05/download-oracle-java-jre-jdk-using-a-script/ 54 | - https://people.freebsd.org/~kientzle/libarchive/man/cpio.5.txt 55 | 56 | [1]: http://www.oracle.com/technetwork/java/javase/terms/license/index.html 57 | [2]: https://en.wikipedia.org/wiki/Turducken -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/Arch.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget; 2 | 3 | import java.util.Locale; 4 | 5 | public enum Arch { 6 | OSX_64, 7 | NIX_32, 8 | NIX_64, 9 | WIN_32, 10 | WIN_64, 11 | SOL_64, 12 | SOL_SPARC; 13 | 14 | public static Arch autodetect() { 15 | String os = System.getProperty("os.name").toLowerCase(Locale.ENGLISH); 16 | String arch = System.getProperty("os.arch").toLowerCase(Locale.ENGLISH); 17 | 18 | boolean sixtyFour; 19 | 20 | if(arch.contains("amd64")) sixtyFour = true; 21 | else if(arch.contains("86_64")) sixtyFour = true; 22 | else if(arch.contains("86")) sixtyFour = false; 23 | else if(arch.contains("sparc")) sixtyFour = false; // well, technically it's 64 24 | //else if(arch.contains("ia64")) return Itanium; // not supported by oracle since 6u22 25 | else { 26 | throw new IllegalStateException("Unsupported architecture " + arch); 27 | } 28 | 29 | if(os.contains("linux")) { 30 | return sixtyFour ? NIX_64 : NIX_32; 31 | } else if(os.contains("windows")) { 32 | return sixtyFour ? WIN_64 : WIN_32; 33 | } else if(os.contains("mac")) { 34 | return OSX_64; 35 | } else if(arch.contains("sun") || arch.contains("solaris")) { 36 | return sixtyFour ? SOL_64 : SOL_SPARC; 37 | } else { 38 | throw new IllegalStateException("Unsupported architecture " + arch); 39 | } 40 | } 41 | 42 | public boolean isWindows() { 43 | return this == WIN_32 || this == WIN_64; 44 | } 45 | 46 | public boolean isOsx() { 47 | return this == OSX_64; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/CachingOutput.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget; 2 | 3 | import java.io.PrintStream; 4 | import java.io.PrintWriter; 5 | import java.io.StringWriter; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class CachingOutput implements IOutput { 10 | 11 | private List msgs = new ArrayList<>(); 12 | 13 | @Override 14 | public void info(String message) { 15 | msgs.add("[INFO] " + message); 16 | } 17 | 18 | @Override 19 | public void error(String message) { 20 | msgs.add("[ERROR] " + message); 21 | } 22 | 23 | @Override 24 | public void error(String message, Throwable t) { 25 | StringWriter sw = new StringWriter(); 26 | t.printStackTrace(new PrintWriter(sw)); 27 | error(message + ": " + t + "\n" + sw.toString()); 28 | } 29 | 30 | public void output(PrintStream out) { 31 | for (String msg : msgs) { 32 | out.println(msg); 33 | } 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/IJdkExtractor.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | 6 | import io.takari.jdkget.model.JdkBinary; 7 | 8 | public interface IJdkExtractor { 9 | 10 | boolean extractJdk(JdkGetter context, JdkBinary bin, File jdkImage, File outputDir) throws IOException, InterruptedException; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/IOutput.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget; 2 | 3 | public interface IOutput { 4 | 5 | public static final IOutput NULL_OUTPUT = new IOutput() { 6 | @Override 7 | public void info(String message) {} 8 | 9 | @Override 10 | public void error(String message) {} 11 | 12 | @Override 13 | public void error(String message, Throwable t) {} 14 | 15 | @Override 16 | public void printProgress(long time, long copiedBytes, long totalBytes) {} 17 | }; 18 | 19 | void info(String message); 20 | 21 | void error(String message); 22 | 23 | void error(String message, Throwable t); 24 | 25 | default void printProgress(long time, long copiedBytes, long totalBytes) { 26 | 27 | // spd 28 | long sec = time / 1000L; 29 | double spd = (((double) copiedBytes) / sec) / 1024; // kb/s 30 | String spdUnit = "kB/s"; 31 | if (spd > 1024) { 32 | spd /= 1024; 33 | spdUnit = "MB/s"; 34 | } 35 | 36 | // copied 37 | double copied = ((double) copiedBytes) / 1024; // kb 38 | String copiedUnit = "kB"; 39 | if (copied > 1024) { 40 | copied /= 1024; 41 | copiedUnit = "MB"; 42 | } 43 | if (copied > 1024) { 44 | copied /= 1024; 45 | copiedUnit = "GB"; 46 | } 47 | 48 | // total 49 | if (totalBytes > 0) { 50 | double total = ((double) totalBytes) / 1024; // kb 51 | String totalUnit = "kB"; 52 | if (total > 1024) { 53 | total /= 1024; 54 | totalUnit = "MB"; 55 | } 56 | if (total > 1024) { 57 | total /= 1024; 58 | totalUnit = "GB"; 59 | } 60 | 61 | double pct = ((double) copiedBytes * 100) / totalBytes; 62 | long eta = ((time * (totalBytes - copiedBytes)) / copiedBytes); 63 | 64 | info(String.format("Downloading %,.2f %s of %,.2f %s (%.2f%%) @ %,.2f %s ETA: %s", copied, copiedUnit, total, totalUnit, pct, spd, spdUnit, Util.timeToStr(eta))); 65 | } else { 66 | info(String.format("Downloading %,.2f %s @ %,.2f %s", copied, copiedUnit, spd, spdUnit)); 67 | } 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/ITransport.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | 6 | import io.takari.jdkget.model.JCE; 7 | import io.takari.jdkget.model.JdkBinary; 8 | 9 | public interface ITransport { 10 | 11 | void downloadJdk(JdkGetter context, JdkBinary binary, File jdkImage) throws IOException, InterruptedException; 12 | 13 | default void downloadJce(JdkGetter context, JCE jce, File jceImage) throws IOException, InterruptedException { 14 | throw new UnsupportedOperationException(); 15 | } 16 | 17 | boolean validate(JdkGetter context, JdkBinary binary, File jdkImage) throws IOException, InterruptedException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/ITransportFactory.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget; 2 | 3 | import java.io.Serializable; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | import java.util.Properties; 7 | 8 | public interface ITransportFactory extends Serializable { 9 | 10 | public static final String PARAM_BASEURL = "io.takari.jdkget.baseUrl"; 11 | public static final String PARAM_USERNAME = "io.takari.jdkget.username"; 12 | public static final String PARAM_PASSWORD = "io.takari.jdkget.password"; 13 | 14 | ITransport createTransport(Map parameters); 15 | 16 | default ITransport createTransport() { 17 | Map trParams = new HashMap<>(); 18 | Properties sprops = System.getProperties(); 19 | sprops.forEach((k, val) -> trParams.put(k.toString(), val.toString())); 20 | return createTransport(trParams); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/StdOutput.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget; 2 | 3 | public class StdOutput implements IOutput { 4 | 5 | public static final StdOutput INSTANCE = new StdOutput(); 6 | 7 | private StdOutput() { 8 | } 9 | 10 | @Override 11 | public void info(String message) { 12 | System.out.println(message); 13 | } 14 | 15 | @Override 16 | public void error(String message) { 17 | System.err.println(message); 18 | } 19 | 20 | @Override 21 | public void error(String message, Throwable e) { 22 | System.err.println(message); 23 | e.printStackTrace(System.err); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/extract/AbstractZipExtractor.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget.extract; 2 | 3 | import java.io.File; 4 | import java.io.FileOutputStream; 5 | import java.io.FilterInputStream; 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.io.OutputStream; 9 | import java.util.jar.JarOutputStream; 10 | import java.util.jar.Pack200; 11 | import java.util.zip.ZipEntry; 12 | 13 | import io.takari.jdkget.IJdkExtractor; 14 | import io.takari.jdkget.Util; 15 | import io.takari.jdkget.model.JdkVersion; 16 | 17 | public abstract class AbstractZipExtractor implements IJdkExtractor { 18 | 19 | protected void extractEntry(File outputDir, JdkVersion version, ZipEntry e, InputStream zip) 20 | throws IOException, InterruptedException { 21 | Util.checkInterrupt(); 22 | 23 | boolean unpack200 = false; 24 | String name = e.getName(); 25 | 26 | if (version != null) { 27 | name = Util.cleanEntryName(name, version); 28 | if (name == null) { 29 | return; 30 | } 31 | } 32 | 33 | if (name.endsWith(".pack")) { 34 | name = name.substring(0, name.length() - 5) + ".jar"; 35 | unpack200 = true; 36 | } 37 | 38 | File f = new File(outputDir, name); 39 | if (e.isDirectory()) { 40 | 41 | f.mkdirs(); 42 | 43 | } else { 44 | 45 | f.createNewFile(); 46 | 47 | if (unpack200) { 48 | try (JarOutputStream out = new JarOutputStream(new FileOutputStream(f))) { 49 | // prevent unpacker from closing the stream 50 | InputStream zin = new FilterInputStream(zip) { 51 | @Override 52 | public void close() throws IOException {} 53 | }; 54 | Pack200.newUnpacker().unpack(zin, out); 55 | } 56 | } else { 57 | try (OutputStream out = new FileOutputStream(f)) { 58 | Util.copyInterruptibly(zip, out); 59 | } 60 | } 61 | 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/extract/TZJDKExtractor.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget.extract; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | import org.apache.commons.compress.compressors.z.ZCompressorInputStream; 7 | 8 | public class TZJDKExtractor extends AbstractTarJDKExtractor { 9 | 10 | @Override 11 | protected InputStream wrap(InputStream in) throws IOException { 12 | return new ZCompressorInputStream(in); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/extract/TgzJDKExtractor.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget.extract; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.util.zip.GZIPInputStream; 6 | 7 | public class TgzJDKExtractor extends AbstractTarJDKExtractor { 8 | 9 | @Override 10 | protected InputStream wrap(InputStream in) throws IOException { 11 | return new GZIPInputStream(in); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/extract/WindowsJDKExtractor.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget.extract; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.List; 6 | import java.util.zip.ZipEntry; 7 | import java.util.zip.ZipInputStream; 8 | 9 | import io.takari.jdkget.JdkGetter; 10 | import io.takari.jdkget.Util; 11 | import io.takari.jdkget.model.JdkBinary; 12 | import io.takari.jdkget.win.CabEntry; 13 | import io.takari.jdkget.win.CabInput; 14 | import io.takari.jdkget.win.Cabinet; 15 | 16 | public class WindowsJDKExtractor extends AbstractZipExtractor { 17 | 18 | @Override 19 | public boolean extractJdk(JdkGetter context, JdkBinary bin, File jdkImage, File outputDir) throws IOException, InterruptedException { 20 | 21 | // <= 1.7: PE EXE <- CAB <- tools.zip (some jars are pack200'd as .pack) 22 | // > 1.7: PE EXE <- PE EXE <- CAB <- tools.zip (some jars are pack200'd as .pack) 23 | 24 | try (CabInput in = CabInput.fromFile(jdkImage)) { 25 | List cabs = Cabinet.cabd_search(in); 26 | for (Cabinet cab : cabs) { 27 | for (CabEntry e : cab.entries()) { 28 | Util.checkInterrupt(); 29 | if (e.getName().equals("tools.zip")) { 30 | 31 | // extract it 32 | outputDir.mkdirs(); 33 | try (ZipInputStream zin = new ZipInputStream(e.getInputStream())) { 34 | ZipEntry ze = zin.getNextEntry(); 35 | while (ze != null) { 36 | Util.checkInterrupt(); 37 | extractEntry(outputDir, null, ze, zin); 38 | ze = zin.getNextEntry(); 39 | } 40 | } 41 | 42 | return true; 43 | } 44 | } 45 | } 46 | } 47 | return false; 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/extract/ZipJDKExtractor.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget.extract; 2 | 3 | import java.io.BufferedInputStream; 4 | import java.io.File; 5 | import java.io.FileInputStream; 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.nio.file.Files; 9 | import java.nio.file.Path; 10 | import java.util.zip.ZipEntry; 11 | import java.util.zip.ZipInputStream; 12 | 13 | import io.takari.jdkget.JdkGetter; 14 | import io.takari.jdkget.model.JdkBinary; 15 | import io.takari.jdkget.osx.PosixModes; 16 | 17 | public class ZipJDKExtractor extends AbstractZipExtractor { 18 | 19 | @Override 20 | public boolean extractJdk(JdkGetter context, JdkBinary bin, File jdkImage, File outputDir) throws IOException, InterruptedException { 21 | 22 | context.getLog().info("Extracting " + jdkImage.getName() + " into " + outputDir); 23 | 24 | outputDir.mkdir(); 25 | 26 | try (InputStream in = new BufferedInputStream(new FileInputStream(jdkImage))) { 27 | ZipInputStream zip = new ZipInputStream(in); 28 | 29 | ZipEntry e; 30 | while ((e = zip.getNextEntry()) != null) { 31 | extractEntry(outputDir, bin.getRelease().getVersion(), e, zip); 32 | } 33 | } 34 | 35 | // make sure bin files are executables 36 | if (File.pathSeparatorChar != ';') { 37 | updateExecutables(outputDir); 38 | } 39 | 40 | return true; 41 | } 42 | 43 | private void updateExecutables(File outputDir) throws IOException { 44 | File bin = new File(outputDir, "bin"); 45 | File[] binFiles = bin.listFiles(); 46 | if (binFiles != null) { 47 | for (File ex : binFiles) { 48 | Path p = ex.toPath(); 49 | int mode = PosixModes.posixToIntMode(Files.getPosixFilePermissions(p)); 50 | Files.setPosixFilePermissions(p, PosixModes.intModeToPosix(mode | 0111)); // add +x 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/model/BinaryType.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget.model; 2 | 3 | import java.util.Arrays; 4 | import java.util.Collections; 5 | import java.util.EnumSet; 6 | import java.util.List; 7 | import java.util.Set; 8 | 9 | public enum BinaryType { 10 | JDK("jdk"), JRE("jre"), SERVERJRE("serverjre"); 11 | 12 | private String name; 13 | 14 | BinaryType(String name) { 15 | this.name = name; 16 | } 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public static BinaryType getDefault() { 23 | return JDK; 24 | } 25 | 26 | public static Set forNames(String[] typeNames) { 27 | return forNames(typeNames == null ? null : Arrays.asList(typeNames), 28 | Collections.singleton(BinaryType.getDefault())); 29 | } 30 | 31 | public static Set forNames(List typeNames) { 32 | return forNames(typeNames, Collections.singleton(BinaryType.getDefault())); 33 | } 34 | 35 | public static Set forNames(List typeNames, Set defaultTypes) { 36 | if (typeNames == null) { 37 | return defaultTypes; 38 | } 39 | 40 | Set types = EnumSet.noneOf(BinaryType.class); 41 | for (String typeName : typeNames) { 42 | BinaryType type = forName(typeName, null); 43 | if (type != null) { 44 | types.add(type); 45 | } 46 | } 47 | 48 | return types.isEmpty() ? defaultTypes : types; 49 | } 50 | 51 | public static BinaryType forName(String typeName) { 52 | return forName(typeName, getDefault()); 53 | } 54 | 55 | public static BinaryType forName(String typeName, BinaryType defaultType) { 56 | for (BinaryType t : values()) { 57 | if (t.getName().equals(typeName)) { 58 | return t; 59 | } 60 | } 61 | return defaultType; 62 | } 63 | } -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/model/JCE.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class JCE implements Serializable { 6 | private static final long serialVersionUID = 1L; 7 | 8 | private final int majorVersion; 9 | private final String path; 10 | 11 | public JCE(int majorVersion, String path) { 12 | this.majorVersion = majorVersion; 13 | this.path = path; 14 | } 15 | 16 | public int getMajorVersion() { 17 | return majorVersion; 18 | } 19 | 20 | public String getPath() { 21 | return path; 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/model/JdkBinary.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget.model; 2 | 3 | import java.io.Serializable; 4 | 5 | import io.takari.jdkget.Arch; 6 | 7 | public class JdkBinary implements Serializable { 8 | private static final long serialVersionUID = 1L; 9 | 10 | private JdkRelease release; 11 | private final Arch arch; 12 | private final String path; 13 | private final String md5; 14 | private final String sha256; 15 | private final long size; 16 | 17 | JdkBinary(Arch arch, String path, String md5, String sha256, long size) { 18 | this.arch = arch; 19 | this.path = path; 20 | this.md5 = md5; 21 | this.sha256 = sha256; 22 | this.size = size; 23 | } 24 | 25 | public JdkRelease getRelease() { 26 | return release; 27 | } 28 | 29 | void setRelease(JdkRelease release) { 30 | if (this.release != null) { 31 | throw new IllegalStateException("Release already set"); 32 | } 33 | this.release = release; 34 | } 35 | 36 | public Arch getArch() { 37 | return arch; 38 | } 39 | 40 | public String getPath() { 41 | return path; 42 | } 43 | 44 | public String getMd5() { 45 | return md5; 46 | } 47 | 48 | public String getSha256() { 49 | return sha256; 50 | } 51 | 52 | public long getSize() { 53 | return size; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/oracle/OracleTransportFactory.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget.oracle; 2 | 3 | import java.util.Map; 4 | 5 | import io.takari.jdkget.ITransport; 6 | import io.takari.jdkget.ITransportFactory; 7 | 8 | public class OracleTransportFactory implements ITransportFactory { 9 | private static final long serialVersionUID = 1L; 10 | 11 | @Override 12 | public ITransport createTransport(Map parameters) { 13 | if (parameters != null) { 14 | String website = parameters.get(PARAM_BASEURL); 15 | String otnUsername = parameters.get(PARAM_USERNAME); 16 | String otnPassword = parameters.get(PARAM_PASSWORD); 17 | 18 | if (website != null || otnUsername != null || otnPassword != null) { 19 | return new OracleWebsiteTransport(website, otnUsername, otnPassword); 20 | } 21 | } 22 | return new OracleWebsiteTransport(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/PosixModes.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget.osx; 2 | 3 | import java.nio.file.Files; 4 | import java.nio.file.Path; 5 | import java.nio.file.attribute.PosixFilePermission; 6 | import java.util.EnumSet; 7 | import java.util.Set; 8 | 9 | public final class PosixModes { 10 | static final PosixFilePermission[] PERMISSIONS = PosixFilePermission.values(); 11 | 12 | private static final int PERMISSIONS_LENGTH = PERMISSIONS.length; 13 | private static final int INT_MODE_MAX = (1 << PERMISSIONS_LENGTH) - 1; 14 | 15 | private PosixModes() { 16 | throw new Error("nice try!"); 17 | } 18 | 19 | /** 20 | * Convert an integer into a set of {@link PosixFilePermission}s 21 | * 22 | *

23 | * Note that this method will not try and read {@code 755} "in octal"; you must prefix your integer 24 | * with {@code 0} so that the constant be octal, as in {@code 0755}. 25 | *

26 | * 27 | * @param intMode the mode 28 | * @return a set of POSIX permissions 29 | * @throws InvalidIntModeException invalid integer mode 30 | * 31 | * @see Files#setPosixFilePermissions(Path, Set) 32 | */ 33 | public static Set intModeToPosix(int intMode) { 34 | if ((intMode & INT_MODE_MAX) != intMode) { 35 | throw new RuntimeException("Invalid intMode: " + intMode); 36 | } 37 | final Set set = EnumSet.noneOf(PosixFilePermission.class); 38 | 39 | for (int i = 0; i < PERMISSIONS_LENGTH; i++) { 40 | if ((intMode & 1) == 1) { 41 | set.add(PERMISSIONS[PERMISSIONS_LENGTH - i - 1]); 42 | } 43 | /* 44 | * We're OK with >> instead of >>>, the sign bit will never be set 45 | */ 46 | intMode >>= 1; 47 | } 48 | return set; 49 | } 50 | 51 | public static int posixToIntMode(Set perms) { 52 | int mask = 0; 53 | for (PosixFilePermission perm : perms) { 54 | mask |= 1 << (PERMISSIONS_LENGTH - perm.ordinal() - 1); 55 | } 56 | return mask; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/csjc/AbstractStruct.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.csjc; 19 | 20 | /** 21 | * Abstract struct superinterface. 22 | * 23 | * @author Erik Larsson 24 | */ 25 | public interface AbstractStruct { 26 | /** 27 | * Returns a serialized one-to-one representation of the struct's data. 28 | * 29 | * @return a serialized one-to-one representation of the struct's data. 30 | */ 31 | public byte[] getBytes(); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/csjc/DynamicStruct.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.csjc; 19 | 20 | /** 21 | * Represents a dynamic struct, i.e. a struct with a size that varies between 22 | * instances. 23 | * 24 | * @author Erik Larsson 25 | */ 26 | public interface DynamicStruct extends AbstractStruct { 27 | public int maxSize(); 28 | 29 | public int occupiedSize(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/csjc/PrintableStruct.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.csjc; 19 | 20 | import java.io.PrintStream; 21 | 22 | /** 23 | * Represents a struct which is printable, i.e. a view of its contents can be printed to a 24 | * java.io.PrintStream.
25 | * The printed contents will be space-indented for readability. 26 | * 27 | * @author Erik Larsson 28 | */ 29 | public interface PrintableStruct { 30 | /** 31 | * Prints the name of the struct along with the fields of the struct to ps 32 | * prepending prefix to each line. 33 | * 34 | * @param ps the stream to print the contents to. 35 | * @param prefix the string prefix to prepend to each line (useful for indenting). 36 | */ 37 | public void print(PrintStream ps, String prefix); 38 | 39 | /** 40 | * Prints only the fields of the struct to ps prepending 41 | * prefix to each line. 42 | * 43 | * @param ps the stream to print the contents to. 44 | * @param prefix the string prefix to prepend to each line (useful for indenting). 45 | */ 46 | public void printFields(PrintStream ps, String prefix); 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/csjc/StaticStruct.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.csjc; 19 | 20 | /** 21 | * Represents a static struct, i.e. a struct with a fixed size. 22 | * 23 | * @author Erik Larsson 24 | */ 25 | public interface StaticStruct extends AbstractStruct { 26 | public int size(); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/csjc/structelements/Array.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.csjc.structelements; 19 | 20 | import io.takari.jdkget.osx.util.Util; 21 | 22 | /** 23 | * @author Erik Larsson 24 | */ 25 | public class Array extends StructElement { 26 | 27 | private final StructElement[] elements; 28 | 29 | public Array(String typeName, StructElement[] elements) { 30 | super(typeName + "[" + elements.length + "]"); 31 | this.elements = new StructElement[elements.length]; 32 | for (int i = 0; i < this.elements.length; ++i) { 33 | this.elements[i] = elements[i]; 34 | } 35 | } 36 | 37 | public StructElement[] getElements() { 38 | return Util.arrayCopy(elements, new StructElement[elements.length]); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/csjc/structelements/BooleanRepresentableField.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.csjc.structelements; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public abstract class BooleanRepresentableField extends Field { 24 | 25 | protected BooleanRepresentableField(String typeName, FieldType type) { 26 | super(typeName, type); 27 | } 28 | 29 | public abstract boolean getValueAsBoolean(); 30 | 31 | public abstract void setBooleanValue(boolean b); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/csjc/structelements/ByteArrayDataHandle.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2009 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.csjc.structelements; 19 | 20 | import io.takari.jdkget.osx.util.Util; 21 | 22 | /** 23 | * @author Erik Larsson 24 | */ 25 | class ByteArrayDataHandle implements DataHandle { 26 | 27 | private byte[] data; 28 | 29 | public ByteArrayDataHandle(byte[] data) { 30 | this.data = data; 31 | } 32 | 33 | @Override 34 | public byte[] getBytesAsCopy() { 35 | return getBytesAsCopy(0, data.length); 36 | } 37 | 38 | @Override 39 | public byte[] getBytesAsCopy(int offset, int length) { 40 | return Util.createCopy(data, offset, length); 41 | } 42 | 43 | @Override 44 | public int getLength() { 45 | return data.length; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/csjc/structelements/ByteArrayField.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.csjc.structelements; 19 | 20 | import io.takari.jdkget.osx.util.Util; 21 | 22 | /** 23 | * @author Erik Larsson 24 | */ 25 | public class ByteArrayField extends StringRepresentableField { 26 | 27 | private final byte[] fieldData; 28 | private final int offset; 29 | private final int length; 30 | 31 | public ByteArrayField(byte[] fieldData) { 32 | this(fieldData, 0, fieldData.length); 33 | } 34 | 35 | public ByteArrayField(byte[] fieldData, int offset, int length) { 36 | super("Byte[" + fieldData.length + "]", FieldType.BYTEARRAY); 37 | this.fieldData = fieldData; 38 | this.offset = offset; 39 | this.length = length; 40 | } 41 | 42 | @Override 43 | public String getValueAsString() { 44 | return "0x" + Util.byteArrayToHexString(fieldData, offset, length); 45 | } 46 | 47 | @Override 48 | public void setStringValue(String value) throws IllegalArgumentException { 49 | throw new UnsupportedOperationException("Can\'t set byte string to string value at this point."); 50 | } 51 | 52 | @Override 53 | public String validateStringValue(String s) { 54 | return "Can\'t set a byte string to a string value."; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/csjc/structelements/DataHandle.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2009 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.csjc.structelements; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public interface DataHandle { 24 | public byte[] getBytesAsCopy(); 25 | 26 | public byte[] getBytesAsCopy(int offset, int length); 27 | 28 | public int getLength(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/csjc/structelements/Endianness.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.csjc.structelements; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public enum Endianness { 24 | 25 | BIG_ENDIAN, LITTLE_ENDIAN 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/csjc/structelements/Field.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.csjc.structelements; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public abstract class Field extends StructElement { 24 | 25 | private final FieldType type; 26 | 27 | protected Field(String typeName, FieldType type) { 28 | this(typeName, null, type); 29 | } 30 | 31 | protected Field(String typeName, String typeDescription, FieldType type) { 32 | super(typeName, typeDescription); 33 | this.type = type; 34 | } 35 | 36 | public FieldType getType() { 37 | return type; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/csjc/structelements/FieldType.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.csjc.structelements; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public enum FieldType { 24 | 25 | BOOLEAN, INTEGER, BYTEARRAY, ASCIISTRING, CUSTOM_CHARSET_STRING, DATE 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/csjc/structelements/IntegerFieldBits.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.csjc.structelements; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public enum IntegerFieldBits { 24 | 25 | BITS_8(8), BITS_16(16), BITS_32(32), BITS_64(64); 26 | 27 | private final int bitCount; 28 | 29 | private IntegerFieldBits(int bitCount) { 30 | this.bitCount = bitCount; 31 | } 32 | 33 | public int getBits() { 34 | return bitCount; 35 | } 36 | 37 | public int getBytes() { 38 | return bitCount / 8; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/csjc/structelements/IntegerFieldRepresentation.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.csjc.structelements; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public enum IntegerFieldRepresentation { 24 | DECIMAL("", 10), HEXADECIMAL("0x", 16), OCTAL("0", 8), BINARY("0b", 2); 25 | 26 | private final String prefix; 27 | private final int radix; 28 | 29 | private IntegerFieldRepresentation(String prefix, int radix) { 30 | this.prefix = prefix; 31 | this.radix = radix; 32 | } 33 | 34 | public String getPrefix() { 35 | return prefix; 36 | } 37 | 38 | public int getRadix() { 39 | return radix; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/csjc/structelements/Signedness.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.csjc.structelements; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public enum Signedness { 24 | 25 | SIGNED, UNSIGNED 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/csjc/structelements/StringRepresentableField.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.csjc.structelements; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public abstract class StringRepresentableField extends Field { 24 | private final String unitComponent; 25 | 26 | public StringRepresentableField(String typeName, FieldType type) { 27 | this(typeName, null, type, null); 28 | } 29 | 30 | public StringRepresentableField(String typeName, FieldType type, String unitComponent) { 31 | this(typeName, null, type, unitComponent); 32 | } 33 | 34 | public StringRepresentableField(String typeName, String typeDescription, FieldType type, String unitComponent) { 35 | super(typeName, typeDescription, type); 36 | this.unitComponent = unitComponent; 37 | } 38 | 39 | public abstract String getValueAsString(); 40 | 41 | public abstract void setStringValue(String value) throws IllegalArgumentException; 42 | 43 | public abstract String validateStringValue(String s); 44 | 45 | /** 46 | * Returns the unit for this field, if applicable. For instance, a field 47 | * with an integer value might have "bytes" as units, or "inches". The unit 48 | * property is non-mandatory, so this method may return null. 49 | * 50 | * @return the unit for this field, or null if none is defined. 51 | */ 52 | public String getUnitComponent() { 53 | return unitComponent; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/csjc/structelements/StructElement.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.csjc.structelements; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public abstract class StructElement { 24 | 25 | protected final String typeName; 26 | protected final String typeDescription; 27 | 28 | protected StructElement(String typeName) { 29 | this(typeName, null); 30 | } 31 | 32 | protected StructElement(String typeName, String typeDescription) { 33 | this.typeName = typeName; 34 | this.typeDescription = typeDescription; 35 | } 36 | 37 | public String getTypeName() { 38 | return typeName; 39 | } 40 | 41 | public String getTypeDescription() { 42 | return typeDescription; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/dmg/udif/Debug.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2007 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation, either version 3 of the License, or (at your option) any 7 | * later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.dmg.udif; 19 | 20 | public class Debug { 21 | public static boolean debug = false; 22 | 23 | public static void warning(String message) { 24 | if (debug) 25 | System.err.println(message); 26 | } 27 | 28 | public static void notification(String message) { 29 | if (debug) 30 | System.out.println("------->NOTE: " + message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/dmg/udif/Koly.struct: -------------------------------------------------------------------------------- 1 | struct Koly { 2 | UInt32 fourCC; 3 | byte unknown1[28]; 4 | UInt64 plistBegin1; 5 | UInt64 plistEndSometimes; 6 | UInt64 unknown2; 7 | UInt64 unknown3; 8 | UInt64 unknown4; 9 | UInt64 unknown5; 10 | UInt64 possibleChecksumType; 11 | UInt32 unknown6; 12 | UInt32 possibleUnitSize; 13 | byte unknown7[120]; 14 | UInt64 plistBegin2; 15 | UInt64 plistSize; 16 | byte unknown8[120]; 17 | UInt32 checksumAlgorithm; 18 | UInt32 checksumSize; 19 | byte checksumData[152]; 20 | }; 21 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/dmg/udif/UDIFFile.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2006 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation, either version 3 of the License, or (at your option) any 7 | * later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.dmg.udif; 19 | 20 | import io.takari.jdkget.osx.io.ReadableRandomAccessStream; 21 | 22 | public class UDIFFile { 23 | private ReadableRandomAccessStream stream; 24 | private UDIFFileView dmgView; 25 | 26 | public UDIFFile(ReadableRandomAccessStream stream) { 27 | this.stream = stream; 28 | this.dmgView = new UDIFFileView(stream); 29 | } 30 | 31 | public UDIFFileView getView() { 32 | return dmgView; 33 | } 34 | 35 | public ReadableRandomAccessStream getStream() { 36 | return stream; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/HotFilesFile.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2006-2009 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public class HotFilesFile { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/ProgressMonitor.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2007 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public interface ProgressMonitor { 24 | 25 | public void signalCancel(); 26 | 27 | public boolean cancelSignaled(); 28 | 29 | public void confirmCancel(); 30 | 31 | public void addDataProgress(long dataSize); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/original/StringCodec.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.original; 19 | 20 | /** 21 | * Transforms data between Java strings and their respective encoded byte[] forms. 22 | * 23 | * @author Erik Larsson 24 | */ 25 | public interface StringCodec { 26 | /** 27 | * Decodes the specified data into a string. 28 | * 29 | * @param data the data to decode. 30 | * @return the decoded string. 31 | */ 32 | public String decode(byte[] data); 33 | 34 | /** 35 | * Decodes the specified data into a string. 36 | * 37 | * @param data the data to decode. 38 | * @param off the offset in data to start reading at. 39 | * @param len the amount of data to process. 40 | * @return the decoded string. 41 | */ 42 | public String decode(byte[] data, int off, int len); 43 | 44 | /** 45 | * Encodes the specified string into bytes. 46 | * 47 | * @param str the string to encode. 48 | * @return encoded data. 49 | */ 50 | public byte[] encode(String str); 51 | 52 | /** 53 | * Encodes the specified string into bytes. 54 | * 55 | * @param str the string to encode. 56 | * @param off the position to start reading in the string. 57 | * @param len the number of bytes to read from the string. 58 | * @return encoded data. 59 | */ 60 | public byte[] encode(String str, int off, int len); 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/carbon/OSType.struct: -------------------------------------------------------------------------------- 1 | struct OSType { 2 | Char osType[4]; 3 | }; 4 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/carbon/Point.struct: -------------------------------------------------------------------------------- 1 | struct Point { 2 | SInt16 v; 3 | SInt16 h; 4 | }; 5 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/carbon/Rect.struct: -------------------------------------------------------------------------------- 1 | struct Rect { 2 | SInt16 top; 3 | SInt16 left; 4 | SInt16 bottom; 5 | SInt16 right; 6 | }; 7 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/decmpfs/DecmpfsHeader.struct: -------------------------------------------------------------------------------- 1 | struct DecmpfsHeader { 2 | le32 magic; 3 | le32 compressionType; 4 | le64 fileSize; 5 | }; -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/finder/DInfo.struct: -------------------------------------------------------------------------------- 1 | struct DInfo { 2 | Rect frRect; The rectangle for the window that the Finder displays when the user opens the folder. 3 | UInt16 frFlags; Reserved. 4 | Point frLocation; Location of the folder in the parent window. 5 | SInt16 frView; The manner in which folders are displayed; this is set by the user with commands from the View menu of the Finder. 6 | }; 7 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/finder/DXInfo.struct: -------------------------------------------------------------------------------- 1 | struct DXInfo { 2 | Point frScroll; Scroll position within the Finder window. The Finder does not necessarily save this position immediately upon user action. 3 | SInt32 frOpenChain; Chain of directory IDs for open folders. The Finder numbers directory IDs. The Finder does not necessarily save this information immediately upon user action. 4 | SInt8 frScript; Extended flags. If the high-bit is set, the script system for displaying the folder's name. 5 | SInt8 frXFlags; Extended flags. See "Extended Finder Flags". 6 | SInt16 frComment; Reserved (set to 0). If the high-bit is clear, an ID number for the comment that is displayed in the information window when the user selects a folder and chooses the Get Info command from the File menu. The numbers that identify comments are assigned by the Finder. 7 | SInt32 frPutAway; If the user moves the folder onto the desktop, the directory ID of the folder from which the user moves it. 8 | }; 9 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/finder/ExtendedFileInfo.struct: -------------------------------------------------------------------------------- 1 | struct ExtendedFileInfo { 2 | SInt16 reserved1[4]; 3 | UInt16 extendedFinderFlags; 4 | SInt16 reserved2; 5 | SInt32 putAwayFolderID; 6 | }; 7 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/finder/ExtendedFolderInfo.struct: -------------------------------------------------------------------------------- 1 | struct ExtendedFolderInfo { 2 | Point scrollPosition; // Scroll position (for icon views) 3 | SInt32 reserved1; 4 | UInt16 extendedFinderFlags; 5 | SInt16 reserved2; 6 | SInt32 putAwayFolderID; 7 | }; 8 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/finder/FInfo.struct: -------------------------------------------------------------------------------- 1 | struct FInfo { 2 | OSType fdType; File type. 3 | OSType fdCreator; The signature of the application that created the file. 4 | UInt16 fdFlags; Finder flags. See "Finder Flags." 5 | Point fdLocation; The location--specified in coordinates local to the window--of the file's icon within its window. 6 | SInt16 fdFldr; The window in which the file's icon appears; this information is meaningful only to the Finder. 7 | }; 8 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/finder/FXInfo.struct: -------------------------------------------------------------------------------- 1 | struct FXInfo { 2 | SInt16 fdIconID; An ID number for the file's icon; the numbers that identify icons are assigned by the Finder. 3 | SInt16 fdReserved[3]; Reserved. 4 | SInt8 fdScript; Extended flags. Script code if high-bit is set. 5 | SInt8 fdXFlags; Extended flags. 6 | SInt16 fdComment; Reserved (set to 0). If the high-bit is clear, an ID number for the comment that is displayed in the information window when the user selects a file and chooses the Get Info command from the File menu. The numbers that identify comments are assigned by the Finder. 7 | SInt32 fdPutAway; If the user moves the file onto the desktop, the directory ID of the folder from which the user moves the file. 8 | }; 9 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/finder/FileInfo.struct: -------------------------------------------------------------------------------- 1 | struct FileInfo { 2 | OSType fileType; // The type of the file 3 | OSType fileCreator; // The file's creator 4 | UInt16 finderFlags; 5 | Point location; // File's location in the folder. 6 | UInt16 reservedField; 7 | }; 8 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/finder/FolderInfo.struct: -------------------------------------------------------------------------------- 1 | struct FolderInfo { 2 | Rect windowBounds; 3 | UInt16 finderFlags; 4 | Point location; 5 | UInt16 reservedField; 6 | }; 7 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfs/BTHdrRec.struct: -------------------------------------------------------------------------------- 1 | struct BTHdrRec { 2 | SInt16 bthDepth; current depth of tree (Integer) 3 | SInt32 bthRoot; number of root node (LongInt) 4 | SInt32 bthNRecs; number of leaf records in tree (LongInt) 5 | SInt32 bthFNode; number of first leaf node (LongInt) 6 | SInt32 bthLNode; number of last leaf node (LongInt) 7 | SInt16 bthNodeSize; size of a node (Integer) 8 | SInt16 bthKeyLen; maximum length of a key (Integer) 9 | SInt32 bthNNodes; total number of nodes in tree (LongInt) 10 | SInt32 bthFree; number of free nodes (LongInt) 11 | SInt8 bthResv[76]; reserved (ARRAY[1..76] OF SignedByte) 12 | }; 13 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfs/BootBlkHdr.struct: -------------------------------------------------------------------------------- 1 | struct BootBlkHdr { 2 | SInt16 bbID; boot blocks signature (Integer) 3 | SInt32 bbEntry; entry point to boot code (LongInt) 4 | SInt16 bbVersion; boot blocks version number (Integer) 5 | SInt16 bbPageFlags; used internally (Integer) 6 | Char bbSysName[16]; System filename (Str15) 7 | Char bbShellName[16]; Finder filename (Str15) 8 | Char bbDbg1Name[16]; debugger filename (Str15) 9 | Char bbDbg2Name[16]; debugger filename (Str15) 10 | Char bbScreenName[16]; name of startup screen (Str15) 11 | Char bbHelloName[16]; name of startup program (Str15) 12 | Char bbScrapName[16]; name of system scrap file (Str15) 13 | SInt16 bbCntFCBs; number of FCBs to allocate (Integer) 14 | SInt16 bbCntEvts; number of event queue elements (Integer) 15 | SInt32 bb128KSHeap; system heap size on 128K Mac (LongInt) 16 | SInt32 bb256KSHeap; used internally (LongInt) 17 | SInt32 bbSysHeapSize; system heap size on all machines (LongInt) 18 | SInt16 filler; reserved (Integer) 19 | SInt32 bbSysHeapExtra; additional system heap space (LongInt) 20 | SInt32 bbSysHeapFract; fraction of RAM for system heap (LongInt) 21 | }; 22 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfs/CatDataRec.struct: -------------------------------------------------------------------------------- 1 | struct CatDataRec { 2 | SInt8 cdrType; record type (SignedByte) 3 | SInt8 cdrResrv2; reserved (SignedByte) 4 | }; 5 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfs/CatKeyRec.struct: -------------------------------------------------------------------------------- 1 | struct CatKeyRec { 2 | SInt8 ckrKeyLen; key length (SignedByte) 3 | SInt8 ckrResrv1; reserved (SignedByte) 4 | SInt32 ckrParID; parent directory ID (LongInt) 5 | UInt8 ckrCNameLen length of catalog node name (part of Str31) 6 | Char ckrCName[31]; catalog node name (part of Str31) 7 | }; 8 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfs/CdrDirRec.struct: -------------------------------------------------------------------------------- 1 | struct CdrDirRec { 2 | SInt8 cdrType; record type (SignedByte) 3 | SInt8 cdrResrv2; reserved (SignedByte) 4 | SInt16 dirFlags; directory flags (Integer) 5 | SInt16 dirVal; directory valence (Integer) 6 | SInt32 dirDirID; directory ID (LongInt) 7 | SInt32 dirCrDat; date and time of creation (LongInt) 8 | SInt32 dirMdDat; date and time of last modification (LongInt) 9 | SInt32 dirBkDat; date and time of last backup (LongInt) 10 | DInfo dirUsrInfo; Finder information (DInfo) 11 | DXInfo dirFndrInfo; additional Finder information (DXInfo) 12 | SInt32 dirResrv[4]; reserved (ARRAY[1..4] OF LongInt) 13 | }; 14 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfs/CdrFThdRec.struct: -------------------------------------------------------------------------------- 1 | struct CdrFThdRec { 2 | SInt8 cdrType; record type (SignedByte) 3 | SInt8 cdrResrv2; reserved (SignedByte) 4 | SInt32 fthdResrv[2]; reserved (ARRAY[1..2] OF LongInt) 5 | SInt32 fthdParID; parent ID for this file (LongInt) 6 | Char fthdCName[32]; name of this file (Str31) 7 | }; 8 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfs/CdrFilRec.struct: -------------------------------------------------------------------------------- 1 | struct CdrFilRec { 2 | SInt8 cdrType; record type (SignedByte) 3 | SInt8 cdrResrv2; reserved (SignedByte) 4 | SInt8 filFlags; file flags (SignedByte) 5 | SInt8 filTyp; file type (SignedByte) 6 | FInfo filUsrWds; Finder information (FInfo) 7 | SInt32 filFlNum; file ID (LongInt) 8 | SInt16 filStBlk; first alloc. blk. of data fork (Integer) 9 | SInt32 filLgLen; logical EOF of data fork (LongInt) 10 | SInt32 filPyLen; physical EOF of data fork (LongInt) 11 | SInt16 filRStBlk; first alloc. blk. of resource fork (Integer) 12 | SInt32 filRLgLen; logical EOF of resource fork (LongInt) 13 | SInt32 filRPyLen; physical EOF of resource fork (LongInt) 14 | SInt32 filCrDat; date and time of creation (LongInt) 15 | SInt32 filMdDat; date and time of last modification (LongInt) 16 | SInt32 filBkDat; date and time of last backup (LongInt) 17 | FXInfo filFndrInfo; additional Finder information (FXInfo) 18 | SInt16 filClpSize; file clump size (Integer) 19 | ExtDataRec filExtRec; first data fork extent record (ExtDataRec) 20 | ExtDataRec filRExtRec; first resource fork extent record (ExtDataRec) 21 | SInt32 filResrv; reserved (LongInt) 22 | }; 23 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfs/CdrThdRec.struct: -------------------------------------------------------------------------------- 1 | struct CdrThdRec { 2 | SInt8 cdrType; record type (SignedByte) 3 | SInt8 cdrResrv2; reserved (SignedByte) 4 | SInt32 thdResrv[2]; reserved (ARRAY[1..2] OF LongInt) 5 | SInt32 thdParID; parent ID for this directory (LongInt) 6 | Char thdCName[32]; name of this directory (Str31) 7 | }; 8 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfs/ExtDataRec.struct: -------------------------------------------------------------------------------- 1 | struct ExtDataRec { 2 | ExtDescriptor extDataRec[3]; extent data record 3 | }; 4 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfs/ExtDescriptor.struct: -------------------------------------------------------------------------------- 1 | struct ExtDescriptor { 2 | UInt16 xdrStABN; first allocation block 3 | UInt16 xdrNumABlks; number of allocation blocks 4 | }; 5 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfs/ExtKeyRec.struct: -------------------------------------------------------------------------------- 1 | struct ExtKeyRec { 2 | SInt8 xkrKeyLen; key length (SignedByte) 3 | SInt8 xkrFkType; fork type (SignedByte) 4 | SInt32 xkrFNum; file number (LongInt) 5 | SInt16 xkrFABN; starting file allocation block (Integer) 6 | }; 7 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfs/HFSDateField.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.types.hfs; 19 | 20 | import io.takari.jdkget.osx.hfs.types.hfsplus.HFSPlusDateField; 21 | 22 | /** 23 | * @author Erik Larsson 24 | */ 25 | public class HFSDateField extends HFSPlusDateField { 26 | public HFSDateField(byte[] data) { 27 | this(data, 0, data.length); 28 | } 29 | 30 | public HFSDateField(byte[] data, int offset, int length) { 31 | super("HFSDate", data, offset, length, true); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfs/HFSPlusWrapperMDB.struct: -------------------------------------------------------------------------------- 1 | struct HFSPlusWrapperMDB { 2 | UInt16 drSigWord; volume signature 3 | UInt32 drCrDate; date and time of volume creation 4 | UInt32 drLsMod; date and time of last modification 5 | UInt16 drAtrb; volume attributes 6 | UInt16 drNmFls; number of files in root directory 7 | UInt16 drVBMSt; first block of volume bitmap 8 | UInt16 drAllocPtr; start of next allocation search 9 | UInt16 drNmAlBlks; number of allocation blocks in volume 10 | UInt32 drAlBlkSiz; size (in bytes) of allocation blocks 11 | UInt32 drClpSiz; default clump size 12 | UInt16 drAlBlSt; first allocation block in volume 13 | UInt32 drNxtCNID; next unused catalog node ID 14 | UInt16 drFreeBks; number of unused allocation blocks 15 | UInt8 drVNLength; length of volume name 16 | Char drVN[27]; volume name 17 | UInt32 drVolBkUp; date and time of last backup 18 | UInt16 drVSeqNum; volume backup sequence number 19 | UInt32 drWrCnt; volume write count 20 | UInt32 drXTClpSiz; clump size for extents overflow file 21 | UInt32 drCTClpSiz; clump size for catalog file 22 | UInt16 drNmRtDirs; number of directories in root directory 23 | UInt32 drFilCnt; number of files in volume 24 | UInt32 drDirCnt; number of directories in volume 25 | UInt32 drFndrInfo[8]; information used by the Finder 26 | UInt16 drEmbedSigWord; HFS+ Wrapper specific: Must always be 'H+' 27 | ExtDescriptor drEmbedExtent; HFS+ Wrapper specific: The extent containing the HFS+ volume 28 | UInt32 drXTFlSize; size of extents overflow file 29 | ExtDataRec drXTExtRec; extent record for extents overflow file 30 | UInt32 drCTFlSize; size of catalog file 31 | ExtDataRec drCTExtRec; extent record for catalog file 32 | }; 33 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfs/HFSVolumeFinderInfo.struct: -------------------------------------------------------------------------------- 1 | struct HFSVolumeFinderInfo { 2 | be32 blessedSystemFolder; 3 | be32 startupApplicationParentFolder; 4 | be32 openFolderList; 5 | be32 alternateMacOSBlessedSystemFolder; 6 | be32 reserved; 7 | be32 alternateMacOSXBlessedSystemFolder; 8 | be64 volumeUUID; 9 | }; 10 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfs/MacLegacyEncoding.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.types.hfs; 19 | 20 | /** 21 | * Very sketchy and unfinished. 22 | * 23 | * @author Erik Larsson 24 | */ 25 | public enum MacLegacyEncoding { 26 | ROMAN, ARABIC; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfs/MasterDirectoryBlock.struct: -------------------------------------------------------------------------------- 1 | struct MasterDirectoryBlock { 2 | UInt16 drSigWord; volume signature 3 | UInt32 drCrDate; date and time of volume creation 4 | UInt32 drLsMod; date and time of last modification 5 | UInt16 drAtrb; volume attributes 6 | UInt16 drNmFls; number of files in root directory 7 | UInt16 drVBMSt; first block of volume bitmap 8 | UInt16 drAllocPtr; start of next allocation search 9 | UInt16 drNmAlBlks; number of allocation blocks in volume 10 | UInt32 drAlBlkSiz; size (in bytes) of allocation blocks 11 | UInt32 drClpSiz; default clump size 12 | UInt16 drAlBlSt; first allocation block in volume 13 | UInt32 drNxtCNID; next unused catalog node ID 14 | UInt16 drFreeBks; number of unused allocation blocks 15 | UInt8 drVNLength; length of volume name 16 | Char drVN[28]; volume name 17 | UInt32 drVolBkUp; date and time of last backup 18 | UInt16 drVSeqNum; volume backup sequence number 19 | UInt32 drWrCnt; volume write count 20 | UInt32 drXTClpSiz; clump size for extents overflow file 21 | UInt32 drCTClpSiz; clump size for catalog file 22 | UInt16 drNmRtDirs; number of directories in root directory 23 | UInt32 drFilCnt; number of files in volume 24 | UInt32 drDirCnt; number of directories in volume 25 | HFSVolumeFinderInfo drFndrInfo; information used by the Finder 26 | UInt16 drVCSize; size (in blocks) of volume cache 27 | UInt16 drVBMCSize; size (in blocks) of volume bitmap cache 28 | UInt16 drCtlCSize; size (in blocks) of common volume cache 29 | UInt32 drXTFlSize; size of extents overflow file 30 | ExtDataRec drXTExtRec; extent record for extents overflow file 31 | UInt32 drCTFlSize; size of catalog file 32 | ExtDataRec drCTExtRec; extent record for catalog file 33 | }; 34 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfs/NodeDescriptor.struct: -------------------------------------------------------------------------------- 1 | struct NodeDescriptor { 2 | SInt32 ndFLink; forward link (LongInt) 3 | SInt32 ndBLink; backward link (LongInt) 4 | SInt8 ndType; node type (SignedByte) 5 | SInt8 ndNHeight; node level (SignedByte) 6 | SInt16 ndNRecs; number of records in node (Integer) 7 | SInt16 ndResv2; reserved (Integer) 8 | }; 9 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfscommon/CommonBTGenericDataRecord.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.types.hfscommon; 19 | 20 | import java.io.PrintStream; 21 | 22 | import io.takari.jdkget.osx.util.Util; 23 | 24 | /** 25 | * Record with unspecified data. 26 | * 27 | * @author Erik Larsson 28 | */ 29 | public class CommonBTGenericDataRecord extends CommonBTRecord { 30 | private final byte[] data; 31 | 32 | public CommonBTGenericDataRecord(byte[] data, int offset, int length) { 33 | this.data = new byte[length]; 34 | System.arraycopy(data, offset, this.data, 0, length); 35 | } 36 | 37 | @Override 38 | public int getSize() { 39 | return data.length; 40 | } 41 | 42 | @Override 43 | public byte[] getBytes() { 44 | return Util.createCopy(data); 45 | } 46 | 47 | @Override 48 | public void print(PrintStream ps, String prefix) { 49 | ps.println(prefix + "CommonBTGenericDataRecord:"); 50 | printFields(ps, prefix + " "); 51 | } 52 | 53 | @Override 54 | public void printFields(PrintStream ps, String prefix) { 55 | ps.println(prefix + "data: byte[" + data.length + "] (" + data + ")"); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfscommon/CommonBTKey.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.types.hfscommon; 19 | 20 | import io.takari.jdkget.osx.csjc.DynamicStruct; 21 | import io.takari.jdkget.osx.csjc.PrintableStruct; 22 | 23 | /** 24 | * @author Erik Larsson 25 | */ 26 | public abstract class CommonBTKey implements Comparable, DynamicStruct, PrintableStruct { 27 | @Override 28 | public abstract byte[] getBytes(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfscommon/CommonBTKeyedNode.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2014 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.types.hfscommon; 19 | 20 | import java.util.List; 21 | 22 | /** 23 | * @author Erik Larsson 24 | */ 25 | public abstract class CommonBTKeyedNode 26 | extends CommonBTNode { 27 | protected CommonBTKeyedNode(byte[] data, int offset, int nodeSize, 28 | FSType type) { 29 | super(data, offset, nodeSize, type); 30 | } 31 | 32 | public R getBTKeyedRecord(int index) { 33 | return getBTRecord(index); 34 | } 35 | 36 | public List getBTKeyedRecords() { 37 | return getBTRecords(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfscommon/CommonBTKeyedRecord.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2014 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.types.hfscommon; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public abstract class CommonBTKeyedRecord 24 | extends CommonBTRecord { 25 | public abstract K getKey(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfscommon/CommonBTLeafRecord.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2014 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.types.hfscommon; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public abstract class CommonBTLeafRecord> 24 | extends CommonBTKeyedRecord { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfscommon/CommonBTRecord.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.types.hfscommon; 19 | 20 | import io.takari.jdkget.osx.csjc.PrintableStruct; 21 | 22 | /** 23 | * @author Erik Larsson 24 | */ 25 | public abstract class CommonBTRecord implements PrintableStruct { 26 | public abstract int getSize(); 27 | 28 | public abstract byte[] getBytes(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfscommon/CommonHFSAttributesIndexNode.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008-2012 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.types.hfscommon; 19 | 20 | import io.takari.jdkget.osx.hfs.types.hfsplus.HFSPlusAttributesKey; 21 | 22 | /** 23 | * @author Erik Larsson 24 | */ 25 | public abstract class CommonHFSAttributesIndexNode 26 | extends CommonBTKeyedNode> { 27 | protected CommonHFSAttributesIndexNode(byte[] data, int offset, 28 | int nodeSize, FSType type) { 29 | super(data, offset, nodeSize, type); 30 | } 31 | 32 | public static CommonHFSAttributesIndexNode createHFSPlus(byte[] data, 33 | int offset, int nodeSize) { 34 | return new HFSPlusImplementation(data, offset, nodeSize); 35 | } 36 | 37 | public static class HFSPlusImplementation 38 | extends CommonHFSAttributesIndexNode { 39 | public HFSPlusImplementation(byte[] data, int offset, int nodeSize) { 40 | super(data, offset, nodeSize, FSType.HFS_PLUS); 41 | } 42 | 43 | @Override 44 | protected CommonBTIndexRecord createBTRecord( 45 | int recordNumber, byte[] data, int offset, int length) { 46 | final CommonHFSAttributesKey key = CommonHFSAttributesKey.create( 47 | new HFSPlusAttributesKey(data, offset)); 48 | 49 | return CommonBTIndexRecord.createHFSPlus(key, data, offset); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfscommon/CommonHFSAttributesLeafNode.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008-2012 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.types.hfscommon; 19 | 20 | import io.takari.jdkget.osx.hfs.types.hfsplus.HFSPlusAttributesLeafRecord; 21 | 22 | /** 23 | * @author Erik Larsson 24 | */ 25 | public abstract class CommonHFSAttributesLeafNode 26 | extends CommonBTKeyedNode { 27 | protected CommonHFSAttributesLeafNode(byte[] data, int offset, int nodeSize, 28 | FSType type) { 29 | super(data, offset, nodeSize, type); 30 | } 31 | 32 | public CommonHFSAttributesLeafRecord[] getLeafRecords() { 33 | return ic.records.toArray( 34 | new CommonHFSAttributesLeafRecord[ic.records.size()]); 35 | } 36 | 37 | public static CommonHFSAttributesLeafNode createHFSPlus(byte[] data, 38 | int offset, int nodeSize) { 39 | return new HFSPlusImplementation(data, offset, nodeSize); 40 | } 41 | 42 | public static class HFSPlusImplementation 43 | extends CommonHFSAttributesLeafNode { 44 | public HFSPlusImplementation(byte[] data, int offset, int nodeSize) { 45 | super(data, offset, nodeSize, FSType.HFS_PLUS); 46 | } 47 | 48 | @Override 49 | protected CommonHFSAttributesLeafRecord createBTRecord(int recordNumber, 50 | byte[] data, int offset, int length) { 51 | final HFSPlusAttributesLeafRecord record = 52 | new HFSPlusAttributesLeafRecord(data, offset); 53 | 54 | return CommonHFSAttributesLeafRecord.create(record); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfscommon/CommonHFSCatalogThread.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2014 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.types.hfscommon; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public abstract class CommonHFSCatalogThread { 24 | public abstract CommonHFSCatalogNodeID getParentID(); 25 | 26 | public abstract CommonHFSCatalogString getNodeName(); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfscommon/CommonHFSCatalogThreadRecord.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2014 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.types.hfscommon; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public abstract class CommonHFSCatalogThreadRecord 24 | extends CommonHFSCatalogLeafRecord { 25 | public abstract T getData(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfscommon/CommonHFSForkType.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.types.hfscommon; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public enum CommonHFSForkType { 24 | DATA_FORK, RESOURCE_FORK; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfscommon/StringComparator.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.types.hfscommon; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public interface StringComparator { 24 | public int compare(byte[] a, int aoff, int alen, byte[] b, int boff, int blen); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/BTKey.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2006 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.types.hfsplus; 19 | 20 | import io.takari.jdkget.osx.csjc.PrintableStruct; 21 | 22 | public abstract class BTKey implements Comparable, PrintableStruct { 23 | public abstract short getKeyLength(); 24 | 25 | public abstract int length(); 26 | 27 | public abstract byte[] getBytes(); 28 | 29 | /* @Override */ 30 | @Override 31 | public int compareTo(BTKey btk) { 32 | byte[] thisData = getBytes(); 33 | byte[] thatData = btk.getBytes(); 34 | 35 | for (int i = 0; i < Math.min(thisData.length, thatData.length); ++i) { 36 | int a = thisData[i] & 0xFF; 37 | int b = thatData[i] & 0xff; 38 | if (a < b) 39 | return -1; 40 | else if (a > b) 41 | return 1; 42 | } 43 | if (thisData.length < thatData.length) 44 | return -1; 45 | else if (thisData.length > thatData.length) 46 | return 1; 47 | else 48 | return 0; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/BlockInfo.struct: -------------------------------------------------------------------------------- 1 | struct BlockInfo { 2 | UInt64 bnum; 3 | UInt32 bsize; 4 | UInt32 next; 5 | }; 6 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/BlockListHeader.struct: -------------------------------------------------------------------------------- 1 | struct BlockListHeader { 2 | UInt16 maxBlocks; 3 | UInt16 numBlocks; 4 | UInt32 bytesUsed; 5 | UInt32 checksum; 6 | UInt32 pad; 7 | }; 8 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/HFSPlusAttributesData.struct: -------------------------------------------------------------------------------- 1 | struct HFSPlusAttributesData { 2 | UInt32 recordType; /* == kHFSPlusAttrInlineData */ 3 | UInt32 reserved[2]; 4 | UInt32 attrSize; /* size of attribute data in bytes */ 5 | UInt8 attrData[2]; /* variable length */ 6 | }; 7 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/HFSPlusAttributesExtents.struct: -------------------------------------------------------------------------------- 1 | struct HFSPlusAttributesExtents { 2 | UInt32 recordType; 3 | UInt32 reserved; 4 | HFSPlusExtentRecord extents; 5 | }; 6 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/HFSPlusAttributesForkData.struct: -------------------------------------------------------------------------------- 1 | struct HFSPlusAttributesForkData { 2 | UInt32 recordType; 3 | UInt32 reserved; 4 | HFSPlusForkData theFork; 5 | }; 6 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/HFSPlusAttributesKey.struct: -------------------------------------------------------------------------------- 1 | struct HFSPlusAttributeKey { 2 | UInt16 keyLength; /* key length (in bytes) */ 3 | UInt16 pad; /* set to zero */ 4 | UInt32 fileID; /* file associated with attribute */ 5 | UInt32 startBlock; /* first allocation block number for extents */ 6 | UInt16 attrNameLen; /* number of unicode characters */ 7 | UInt16 attrName[127]; /* attribute name (Unicode) */ 8 | }; 9 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/HFSPlusBSDInfo.struct: -------------------------------------------------------------------------------- 1 | struct HFSPlusBSDInfo { 2 | UInt32 ownerID; 3 | UInt32 groupID; 4 | UInt8 adminFlags; 5 | UInt8 ownerFlags; 6 | UInt16 fileMode; 7 | UInt32 special; 8 | }; 9 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/HFSPlusCatalogFile.struct: -------------------------------------------------------------------------------- 1 | struct HFSPlusCatalogFile { 2 | SInt16 recordType; 3 | UInt16 flags; 4 | UInt32 reserved1; 5 | HFSCatalogNodeID fileID; 6 | UInt32 createDate; 7 | UInt32 contentModDate; 8 | UInt32 attributeModDate; 9 | UInt32 accessDate; 10 | UInt32 backupDate; 11 | HFSPlusBSDInfo permissions; 12 | FileInfo userInfo; 13 | ExtendedFileInfo finderInfo; 14 | UInt32 textEncoding; 15 | UInt32 reserved2; 16 | HFSPlusForkData dataFork; 17 | HFSPlusForkData resourceFork; 18 | }; 19 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/HFSPlusCatalogFolder.struct: -------------------------------------------------------------------------------- 1 | struct HFSPlusCatalogFolder { 2 | SInt16 recordType; 3 | UInt16 flags; 4 | UInt32 valence; 5 | HFSCatalogNodeID folderID; 6 | UInt32 createDate; 7 | UInt32 contentModDate; 8 | UInt32 attributeModDate; 9 | UInt32 accessDate; 10 | UInt32 backupDate; 11 | HFSPlusBSDInfo permissions; 12 | FolderInfo userInfo; 13 | ExtendedFolderInfo finderInfo; 14 | UInt32 textEncoding; 15 | UInt32 reserved; 16 | }; 17 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/HFSPlusCatalogKey.struct: -------------------------------------------------------------------------------- 1 | struct HFSPlusCatalogKey { 2 | UInt16 keyLength; 3 | HFSCatalogNodeID parentID; 4 | HFSUniStr255 nodeName; 5 | }; 6 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/HFSPlusCatalogLeafRecordData.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2006 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.types.hfsplus; 19 | 20 | import io.takari.jdkget.osx.csjc.PrintableStruct; 21 | import io.takari.jdkget.osx.csjc.StructElements; 22 | import io.takari.jdkget.osx.util.Util; 23 | 24 | public abstract class HFSPlusCatalogLeafRecordData implements PrintableStruct, StructElements { 25 | public static final int RECORD_TYPE_FOLDER = 0x0001; 26 | public static final int RECORD_TYPE_FILE = 0x0002; 27 | public static final int RECORD_TYPE_FOLDER_THREAD = 0x0003; 28 | public static final int RECORD_TYPE_FILE_THREAD = 0x0004; 29 | 30 | public abstract short getRecordType(); 31 | 32 | public String getRecordTypeAsString() { 33 | int recordType = Util.unsign(getRecordType()); 34 | if (recordType == RECORD_TYPE_FOLDER) 35 | return "kHFSPlusFolderRecord"; 36 | else if (recordType == RECORD_TYPE_FILE) 37 | return "kHFSPlusFileRecord"; 38 | else if (recordType == RECORD_TYPE_FOLDER_THREAD) 39 | return "kHFSPlusFolderThreadRecord"; 40 | else if (recordType == RECORD_TYPE_FILE_THREAD) 41 | return "kHFSPlusFileThreadRecord"; 42 | else 43 | return "UNKNOWN!"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/HFSPlusCatalogThread.struct: -------------------------------------------------------------------------------- 1 | struct HFSPlusCatalogThread { 2 | SInt16 recordType; 3 | SInt16 reserved; 4 | HFSCatalogNodeID parentID; 5 | HFSUniStr255 nodeName; 6 | }; 7 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/HFSPlusExtentDescriptor.struct: -------------------------------------------------------------------------------- 1 | struct HFSPlusExtentDescriptor { 2 | UInt32 startBlock; 3 | UInt32 blockCount; 4 | }; 5 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/HFSPlusExtentKey.struct: -------------------------------------------------------------------------------- 1 | struct HFSPlusExtentKey { 2 | UInt16 keyLength; 3 | UInt8 forkType; 4 | UInt8 pad; 5 | HFSCatalogNodeID fileID; 6 | UInt32 startBlock; 7 | }; 8 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/HFSPlusExtentLeafRecord.struct: -------------------------------------------------------------------------------- 1 | struct HFSPlusExtentLeafRecord { 2 | HFSPlusExtentKey key; 3 | HFSPlusExtentRecord recordData; 4 | }; 5 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/HFSPlusExtentRecord.struct: -------------------------------------------------------------------------------- 1 | struct HFSPlusExtentRecord { 2 | HFSPlusExtentDescriptor extentDescriptors[8]; 3 | }; 4 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/HFSPlusForkData.struct: -------------------------------------------------------------------------------- 1 | struct HFSPlusForkData { 2 | UInt64 logicalSize; 3 | UInt32 clumpSize; 4 | UInt32 totalBlocks; 5 | HFSPlusExtentRecord extents; 6 | }; 7 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/HFSUniStr255.struct: -------------------------------------------------------------------------------- 1 | struct HFSUniStr255 { 2 | UInt16 length; 3 | UniChar unicode[255]; 4 | }; 5 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/JournalHeader.struct: -------------------------------------------------------------------------------- 1 | struct JournalHeader { 2 | UInt32 magic; 3 | UInt32 endian; 4 | UInt64 start; 5 | UInt64 end; 6 | UInt64 size; 7 | UInt32 blhdrSize; 8 | UInt32 checksum; 9 | UInt32 jhdrSize; 10 | }; 11 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsplus/JournalInfoBlock.struct: -------------------------------------------------------------------------------- 1 | struct JournalInfoBlock { 2 | UInt32 flags; 3 | UInt32 deviceSignature[8]; 4 | UInt64 offset; 5 | UInt64 size; 6 | UInt32 reserved[32]; 7 | }; 8 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfs/types/hfsx/HFSXKeyCompareType.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfs.types.hfsx; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public enum HFSXKeyCompareType { 24 | CASE_FOLDING, BINARY_COMPARE; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfsexplorer/Util.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2006-2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfsexplorer; 19 | 20 | public class Util extends io.takari.jdkget.osx.util.Util { 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfsexplorer/fs/NullProgressMonitor.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008-2012 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfsexplorer.fs; 19 | 20 | import io.takari.jdkget.osx.hfs.ProgressMonitor; 21 | 22 | /** 23 | * @author Erik Larsson 24 | */ 25 | public class NullProgressMonitor implements ProgressMonitor { 26 | 27 | private static final NullProgressMonitor INSTANCE = new NullProgressMonitor(); 28 | 29 | public static NullProgressMonitor getInstance() { 30 | return INSTANCE; 31 | } 32 | 33 | protected NullProgressMonitor() {} 34 | 35 | /* @Override */ 36 | @Override 37 | public void signalCancel() {} 38 | 39 | /* @Override */ 40 | @Override 41 | public boolean cancelSignaled() { 42 | return false; 43 | } 44 | 45 | /* @Override */ 46 | @Override 47 | public void confirmCancel() {} 48 | 49 | /* @Override */ 50 | @Override 51 | public void addDataProgress(long dataSize) {} 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfsexplorer/io/RandomAccessChannel.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfsexplorer.io; 19 | 20 | import java.io.IOException; 21 | import java.nio.channels.FileChannel; 22 | import java.nio.channels.ReadableByteChannel; 23 | 24 | /** 25 | * @author Erik Larsson 26 | */ 27 | public interface RandomAccessChannel extends ReadableByteChannel { 28 | 29 | public abstract long position() 30 | throws IOException; 31 | 32 | public abstract FileChannel position(long newPosition) 33 | throws IOException; 34 | 35 | public abstract long size() 36 | throws IOException; 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfsexplorer/io/WritableRandomAccessChannel.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.hfsexplorer.io; 19 | 20 | import java.io.IOException; 21 | import java.nio.channels.FileChannel; 22 | import java.nio.channels.WritableByteChannel; 23 | 24 | /** 25 | * @author Erik Larsson 26 | */ 27 | public interface WritableRandomAccessChannel extends RandomAccessChannel, WritableByteChannel { 28 | 29 | public abstract FileChannel truncate(long size) 30 | throws IOException; 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfsexplorer/types/applesingle/AppleSingleHeader.struct: -------------------------------------------------------------------------------- 1 | struct AppleSingleHeader { 2 | UInt32 magicNumber; 3 | UInt32 versionNumber; 4 | Char homeFileSystem[16]; 5 | UInt16 numEntries; 6 | }; 7 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfsexplorer/types/applesingle/AttributeEntry.struct: -------------------------------------------------------------------------------- 1 | struct AttributeEntry { 2 | ube32 offset; 3 | ube32 length; 4 | be16 flags; 5 | u8 nameLength; 6 | char name[1]; 7 | }; 8 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfsexplorer/types/applesingle/AttributeHeader.struct: -------------------------------------------------------------------------------- 1 | struct AttributeHeader { 2 | be32 magic; 3 | be32 debugTag; 4 | ube32 totalEnd; 5 | ube32 dataStart; 6 | ube32 dataLength; 7 | char reserved[12]; 8 | be16 flags; 9 | ube16 numAttrs; 10 | }; 11 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfsexplorer/types/applesingle/EntryDescriptor.struct: -------------------------------------------------------------------------------- 1 | struct EntryDescriptor { 2 | UInt32 entryId; 3 | UInt32 entryOffset; 4 | UInt32 entryLength; 5 | }; 6 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfsexplorer/types/resff/ReferenceListEntry.struct: -------------------------------------------------------------------------------- 1 | struct ReferenceListEntry { 2 | UInt16 resourceID; // Resource ID 3 | UInt16 resourceNameOffset; // Offset from beginning of resource name list to resource name 4 | UInt8 resourceAttributes; // Resource attributes 5 | UInt8 resourceDataOffset[3]; // Offset from beginning of resource data to data for this resource. 6 | UInt32 reserved1; // Reserved for handle to resource. 7 | }; 8 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfsexplorer/types/resff/ResourceHeader.struct: -------------------------------------------------------------------------------- 1 | struct ResourceHeader { 2 | UInt32 dataOffset; // Offset from the beginning of the resource fork to the beginning of the resource data. 3 | UInt32 mapOffset; // Offset from the beginning of the resource fork to the beginning of the resource map. 4 | UInt32 dataLength; // Length of resource data. 5 | UInt32 mapLength; // Length of resource map. 6 | }; 7 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfsexplorer/types/resff/ResourceMap.struct: -------------------------------------------------------------------------------- 1 | struct ResourceMap { 2 | UInt8 reserved1[16]; // Reserved for copy of resource header. 3 | UInt32 reserved2; // Reserved for handle to next resource map. 4 | UInt16 reserved3; // Reserved for file reference number. 5 | UInt16 resourceForkAttributes; // Resource fork attributes 6 | UInt16 typeListOffset; // Offset from beginning of map to resource type list. 7 | UInt16 nameListOffset; // Offset from beginning of map to resource name list. 8 | SInt16 typeCount; // Number of types in the map minus 1. 9 | ResourceType resourceTypeList[2]; // Resource type list. 10 | 11 | }; 12 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfsexplorer/types/resff/ResourceName.struct: -------------------------------------------------------------------------------- 1 | struct ResourceName { 2 | UInt8 nameLength; 3 | Char name[2]; 4 | }; 5 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/hfsexplorer/types/resff/ResourceType.struct: -------------------------------------------------------------------------------- 1 | struct ResourceType { 2 | Char type[4]; // Resource type. 3 | UInt16 instanceCount; // Number of resources of this type in map minus 1. 4 | UInt16 referenceListOffset; // Offset from beginning of resource type list to reference list for this type. 5 | }; 6 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/io/.cvsignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.class 3 | .DS_Store 4 | Thumbs.db 5 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/io/BasicReadableRandomAccessStream.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | package io.takari.jdkget.osx.io; 20 | 21 | /** 22 | * Basic implementation of many features of ReadableRandomAccessStream, to allow the subclasser to 23 | * only implement the essential methods needed to support a ReadableRandomAccessStream. 24 | * 25 | * @author Erik Larsson 26 | */ 27 | public abstract class BasicReadableRandomAccessStream extends BasicReadable implements ReadableRandomAccessStream { 28 | /** 29 | * Empty constructor (there is no state maintained in this class). 30 | */ 31 | protected BasicReadableRandomAccessStream() {} 32 | 33 | /** {@inheritDoc} */ 34 | @Override 35 | public abstract void close() throws RuntimeIOException; 36 | 37 | /** {@inheritDoc} */ 38 | @Override 39 | public abstract void seek(long pos) throws RuntimeIOException; 40 | 41 | /** {@inheritDoc} */ 42 | @Override 43 | public abstract long length() throws RuntimeIOException; 44 | 45 | /** {@inheritDoc} */ 46 | @Override 47 | public abstract long getFilePointer() throws RuntimeIOException; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/io/BasicWritable.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | package io.takari.jdkget.osx.io; 20 | 21 | /** 22 | * Basic implementation of core features of Writable, to allow the subclasser to only implement the 23 | * essential methods. 24 | * 25 | * @author Erik Larsson 26 | */ 27 | public abstract class BasicWritable implements Writable { 28 | /** 29 | * Empty constructor (there is no state maintained in this class). 30 | */ 31 | protected BasicWritable() {} 32 | 33 | /** {@inheritDoc} */ 34 | @Override 35 | public void write(byte[] b) throws RuntimeIOException { 36 | defaultWrite(this, b); 37 | } 38 | 39 | /** {@inheritDoc} */ 40 | @Override 41 | public abstract void write(byte[] b, int off, int len) throws RuntimeIOException; 42 | 43 | /** {@inheritDoc} */ 44 | @Override 45 | public void write(int b) throws RuntimeIOException { 46 | defaultWrite(this, b); 47 | } 48 | 49 | static void defaultWrite(Writable w, byte[] b) throws RuntimeIOException { 50 | w.write(b, 0, b.length); 51 | } 52 | 53 | static void defaultWrite(Writable w, int b) throws RuntimeIOException { 54 | w.write(new byte[] {(byte) (b & 0xFF)}, 0, 1); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/io/ConcatenatedReader.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2007 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation, either version 3 of the License, or (at your option) any 7 | * later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.io; 19 | 20 | import java.io.IOException; 21 | import java.io.Reader; 22 | 23 | public class ConcatenatedReader extends Reader { 24 | private final Reader[] sources; 25 | private int currentSource; 26 | private long charPos = 0; 27 | 28 | public ConcatenatedReader(Reader[] sources) { 29 | this.sources = sources; 30 | this.currentSource = 0; 31 | } 32 | 33 | @Override 34 | public void close() throws IOException { 35 | for (Reader r : sources) 36 | r.close(); 37 | } 38 | 39 | @Override 40 | public int read(char[] cbuf, int off, int len) throws IOException { 41 | int bytesRead = 0; 42 | while (bytesRead < len) { 43 | Reader currentReader = sources[currentSource]; 44 | int currentRead = currentReader.read(cbuf, off + bytesRead, len - bytesRead); 45 | while (currentRead != -1 && bytesRead < len) { 46 | bytesRead += currentRead; 47 | currentRead = currentReader.read(cbuf, off + bytesRead, len - bytesRead); 48 | } 49 | if (currentRead == -1) { 50 | if (currentSource + 1 < sources.length) 51 | ++currentSource; 52 | else 53 | break; // There wasn't enough data 54 | } 55 | } 56 | return bytesRead; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/io/InputStreamReadable.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | package io.takari.jdkget.osx.io; 20 | 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | 24 | /** 25 | * Transforms a java.io.InputStream into an org.catacombae.io.Readable. 26 | * 27 | * @author Erik Larsson 28 | */ 29 | public class InputStreamReadable extends BasicReadable implements Stream { 30 | 31 | private final InputStream is; 32 | 33 | public InputStreamReadable(InputStream is) { 34 | this.is = is; 35 | } 36 | 37 | /** {@inheritDoc} */ 38 | @Override 39 | public int read(byte[] data, int pos, int len) throws RuntimeIOException { 40 | try { 41 | return is.read(data, pos, len); 42 | } catch (IOException ex) { 43 | throw new RuntimeIOException(ex); 44 | } 45 | } 46 | 47 | /** {@inheritDoc} */ 48 | @Override 49 | public void close() throws RuntimeIOException { 50 | try { 51 | is.close(); 52 | } catch (IOException ex) { 53 | throw new RuntimeIOException(ex); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/io/OutputStreamWritable.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | package io.takari.jdkget.osx.io; 20 | 21 | import java.io.IOException; 22 | import java.io.OutputStream; 23 | 24 | /** 25 | * Transforms a java.io.OutputStream into an org.catacombae.io.Writable. 26 | * 27 | * @author Erik Larsson 28 | */ 29 | public class OutputStreamWritable extends BasicWritable implements Stream { 30 | private final OutputStream os; 31 | 32 | public OutputStreamWritable(OutputStream os) { 33 | this.os = os; 34 | } 35 | 36 | /** {@inheritDoc} */ 37 | @Override 38 | public void write(byte[] b, int off, int len) throws RuntimeIOException { 39 | try { 40 | os.write(b, off, len); 41 | } catch (IOException ex) { 42 | throw new RuntimeIOException(ex); 43 | } 44 | } 45 | 46 | /** {@inheritDoc} */ 47 | @Override 48 | public void close() throws RuntimeIOException { 49 | try { 50 | os.close(); 51 | } catch (IOException ex) { 52 | throw new RuntimeIOException(ex); 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/io/RandomAccessStream.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2007-2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | package io.takari.jdkget.osx.io; 20 | 21 | /** 22 | * Designed to mimic a subset of RandomAccessFile, except that we don't throw 23 | * checked IOExceptions, but RuntimeIOExceptions instead. 24 | * 25 | * @author Erik Larsson 26 | */ 27 | public interface RandomAccessStream extends ReadableRandomAccessStream, WritableRandomAccessStream { 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/io/ReadableConcatenatedStream.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2007-2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | package io.takari.jdkget.osx.io; 20 | 21 | /** 22 | * An implementation of ReadableRandomAccessStream which concatenates a sequence 23 | * of ReadableRandomAccessStreams (or regions of them) into a new logical 24 | * ReadableRandomAccessStream. 25 | * 26 | * @author Erik Larsson 27 | */ 28 | public class ReadableConcatenatedStream extends BasicConcatenatedStream { 29 | 30 | public ReadableConcatenatedStream(ReadableRandomAccessStream firstPart, long startOffset, long length) { 31 | super(firstPart, startOffset, length); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/io/ReadableRandomAccessStream.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | package io.takari.jdkget.osx.io; 20 | 21 | /** 22 | * This interface defines a readable stream designed for random access, i.e. the user of the stream 23 | * can tell the stream to reposition itself. It was designed to mimic RandomAccessFile, but without 24 | * limiting itself to working with files in a file system. 25 | * 26 | * @author Erik Larsson 27 | */ 28 | public interface ReadableRandomAccessStream extends Stream, RandomAccess, Readable { 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/io/Stream.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | package io.takari.jdkget.osx.io; 20 | 21 | /** 22 | * This is the superinterface of all streams in the catacombae.io package. It contains the only 23 | * method that is general enough to be applicable to all streams, the close() method. 24 | * 25 | * @author Erik Larsson 26 | */ 27 | public interface Stream { 28 | /** 29 | * Closes the stream and releases all associated resources. 30 | * 31 | * @throws io.takari.jdkget.osx.io.RuntimeIOException if an I/O error occurred, preventing the stream 32 | * to close. 33 | */ 34 | public void close() throws RuntimeIOException; 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/io/SynchronizedReadableRandomAccess.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | package io.takari.jdkget.osx.io; 20 | 21 | /** 22 | * 23 | * @author Erik Larsson 24 | */ 25 | public interface SynchronizedReadableRandomAccess extends SynchronizedReadable, RandomAccess { 26 | /** 27 | * All open substreams of this stream must be added as references so that the synchronized 28 | * stream knows when it is safe to close(); itself. 29 | * 30 | * @param referrer the object referring to this stream. 31 | */ 32 | public void addReference(Object referrer); 33 | 34 | /** 35 | * When a substream closes, it must remove itself from the reference list of the parent stream. 36 | * 37 | * @param referrer the object referring to this stream. 38 | */ 39 | public void removeReference(Object referrer); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/io/TruncatableRandomAccess.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | package io.takari.jdkget.osx.io; 20 | 21 | /** 22 | * Extension of RandomAccess for situations where the the size of the underlying 23 | * storage can be set. 24 | * 25 | * @author Erik Larsson 26 | */ 27 | public interface TruncatableRandomAccess extends RandomAccess { 28 | public void setLength(long newLength) 29 | throws RuntimeIOException; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/io/TruncatableRandomAccessStream.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | package io.takari.jdkget.osx.io; 20 | 21 | /** 22 | * 23 | * @author Erik Larsson 24 | */ 25 | public interface TruncatableRandomAccessStream extends RandomAccessStream, TruncatableRandomAccess { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/io/Writable.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | package io.takari.jdkget.osx.io; 20 | 21 | /** 22 | * This interface defines the methods that must exist for a stream to be writable. 23 | * 24 | * @author Erik Larsson 25 | */ 26 | public interface Writable { 27 | /** 28 | * Writes the complete contents of data to the stream, at its current position. 29 | * 30 | * @param data array containing the data to write to the stream. 31 | */ 32 | public void write(byte[] data) throws RuntimeIOException; 33 | 34 | /** 35 | * Writes a subset of data to the stream, starting at array offset pos 36 | * and writing len bytes in total. 37 | * 38 | * @param data array containing the data to write to the stream. 39 | * @param off the offset in data to start reading. 40 | * @param len the number of bytes to write to the stream. 41 | */ 42 | public void write(byte[] data, int off, int len) throws RuntimeIOException; 43 | 44 | /** 45 | * Writes a single byte to the stream. data will be unsigned first, so valid ranges 46 | * are 0 <= data <= 255 or -128 <= data <= 127. 47 | * 48 | * @param data integer containing the single byte to write to the stream. 49 | */ 50 | public void write(int data) throws RuntimeIOException; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/io/WritableRandomAccessStream.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | package io.takari.jdkget.osx.io; 20 | 21 | /** 22 | * This interface defines a writable stream that can be accessed in a random access way. 23 | * 24 | * @author Erik Larsson 25 | */ 26 | public interface WritableRandomAccessStream extends Stream, RandomAccess, Writable { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/plist/PlistNode.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2006-2011 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation, either version 3 of the License, or (at your option) any 7 | * later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.plist; 19 | 20 | import java.io.Reader; 21 | 22 | /** 23 | * @author Erik Larsson 24 | */ 25 | public abstract class PlistNode { 26 | public abstract PlistNode[] getChildren(); 27 | 28 | public abstract PlistNode cd(String type); 29 | 30 | public abstract PlistNode cdkey(String key); 31 | 32 | public abstract Reader getKeyValue(String key); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/fs/FSFile.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.fs; 19 | 20 | /** 21 | * This interface represents an entry corresponding to a file in the file system 22 | * presented by a FileSystemHandler. A file is an entry that does not have 23 | * subentries, like a folder, but that has associated data. A file can have one 24 | * or more "forks" of data, where one of the forks always must be considered the 25 | * "main" fork or the "data" fork. Some file systems do not support forks, in 26 | * which case the only fork available is the "main" fork. 27 | * 28 | * @author Erik Larsson 29 | */ 30 | public interface FSFile extends FSEntry { 31 | /** 32 | * Returns the main (data) fork of this file, containing the data that users 33 | * normally will see. All implementors must make sure that this FSFork 34 | * always exists. 35 | * 36 | * @return the main (data) fork of this file. 37 | */ 38 | public abstract FSFork getMainFork(); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/fs/FSForkType.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.fs; 19 | 20 | /** 21 | * Enumerates the fork types that are recognized by the API as having a special 22 | * meaning. 23 | * 24 | * @author Erik Larsson 25 | */ 26 | public enum FSForkType { 27 | /** 28 | * The data fork, the "main" fork of a file. All file system 29 | * implementations must support this fork type. 30 | */ 31 | DATA, 32 | /** 33 | * The resource fork in a MacOS file system. The resource fork has a special 34 | * meaning for MacOS operating systems, as content type, thumbnails and 35 | * other metadata are stored there. 36 | */ 37 | MACOS_RESOURCE, 38 | /** 39 | * The 32-byte metadata fork FinderInfo, used by the Mac OS Finder. 40 | */ 41 | MACOS_FINDERINFO,; 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/fs/FSLink.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.fs; 19 | 20 | /** 21 | * This class represents a link in a file system, i.e. a point of redirection to another part of 22 | * the file system. In Unix, this is equivalent to a "symbolic link". Unix hard links should be 23 | * modeled as FSFile or FSFolder types, as they're not strictly links, but just two equal file 24 | * system entries that point to the same location (there is no "source file" for the link, but 25 | * instead an inode). 26 | * 27 | * @author Erik Larsson 28 | */ 29 | public interface FSLink extends FSEntry { 30 | 31 | /** 32 | * Tries to resolve the target of the link in the context of its file system. If the link is 33 | * invalid, this method will return null. 34 | * 35 | * @param parentDir a path to the parent directory of the link (needed for links that use 36 | * relative pathnames). 37 | * @return the target of this link, if possible, or null if the link was invalid. 38 | */ 39 | public FSEntry getLinkTarget(String[] parentDir); 40 | 41 | /** 42 | * Returns a context specific string which shows the intended target for this link in the syntax 43 | * of its file system. This string is only for display purposes in info boxes or debug messages. 44 | * It doesn't have any specified format. 45 | * 46 | * @return a context specific string which shows the intended target for this link. 47 | */ 48 | public String getLinkTargetString(); 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/fs/FileSystemCapability.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2009 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.fs; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public enum FileSystemCapability { 24 | /** The file system has create time for all file system objects. */ 25 | CREATE_TIME, 26 | /** The file system has backup time for all file system objects. */ 27 | BACKUP_TIME, 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/fs/FileSystemRecognizer.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.fs; 19 | 20 | import io.takari.jdkget.osx.io.ReadableRandomAccessStream; 21 | 22 | /** 23 | * @author Erik Larsson 24 | */ 25 | public interface FileSystemRecognizer { 26 | 27 | /** 28 | * Detects whether there is a file system located at the specified offset in 29 | * fsStream. Which file system is being detected is dependent on the 30 | * context. 31 | * 32 | * @param fsStream 33 | * @param offset the offset in fsStream to the start of the file system. 34 | * @param length this parameter may be set to -1 if the length isn't 35 | * currently known. 36 | * @return true if a file system can be detected at the 37 | * specified offset in fsStream, and false otherwise. 38 | */ 39 | public boolean detect(ReadableRandomAccessStream fsStream, long offset, long length); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/fs/hfs/HFSFileSystemHandler.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008-2014 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.fs.hfs; 19 | 20 | import io.takari.jdkget.osx.hfs.original.HFSOriginalVolume; 21 | import io.takari.jdkget.osx.hfs.types.hfscommon.CommonHFSCatalogFileRecord; 22 | import io.takari.jdkget.osx.hfs.types.hfscommon.CommonHFSCatalogLeafRecord; 23 | import io.takari.jdkget.osx.storage.fs.hfscommon.HFSCommonFileSystemHandler; 24 | import io.takari.jdkget.osx.storage.io.DataLocator; 25 | 26 | /** 27 | * @author Erik Larsson 28 | */ 29 | public class HFSFileSystemHandler extends HFSCommonFileSystemHandler { 30 | 31 | public HFSFileSystemHandler(DataLocator fsLocator, boolean useCaching, 32 | boolean posixNames, String encodingName) { 33 | super(new HFSOriginalVolume(fsLocator.createReadOnlyFile(), useCaching, 34 | encodingName), posixNames, false, false); 35 | } 36 | 37 | @Override 38 | protected boolean shouldHide(CommonHFSCatalogLeafRecord rec) { 39 | // For HFS we have nothing to hide. 40 | return false; 41 | } 42 | 43 | @Override 44 | protected Long getLinkCount(CommonHFSCatalogFileRecord fr) { 45 | // HFS does not support links. 46 | return null; 47 | } 48 | 49 | @Override 50 | protected String[] getAbsoluteLinkPath(String[] path, int pathLength, 51 | CommonHFSCatalogFileRecord rec) { 52 | // HFS does not support links. 53 | return null; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/fs/hfs/HFSFileSystemRecognizer.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.fs.hfs; 19 | 20 | import io.takari.jdkget.osx.io.ReadableRandomAccessStream; 21 | import io.takari.jdkget.osx.storage.fs.FileSystemRecognizer; 22 | import io.takari.jdkget.osx.storage.fs.hfscommon.HFSCommonFileSystemRecognizer; 23 | 24 | /** 25 | * @author Erik Larsson 26 | */ 27 | public class HFSFileSystemRecognizer implements FileSystemRecognizer { 28 | 29 | @Override 30 | public boolean detect(ReadableRandomAccessStream fsStream, long offset, long length) { 31 | switch (HFSCommonFileSystemRecognizer.detectFileSystem(fsStream, offset)) { 32 | case HFS: 33 | return true; 34 | default: 35 | return false; 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/fs/hfscommon/HFSCommonFSFile.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2014 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.fs.hfscommon; 19 | 20 | import io.takari.jdkget.osx.hfs.types.hfscommon.CommonHFSCatalogFileRecord; 21 | import io.takari.jdkget.osx.hfs.types.hfscommon.CommonHFSCatalogLeafRecord; 22 | import io.takari.jdkget.osx.storage.fs.FSFile; 23 | 24 | /** 25 | * @author Erik Larsson 26 | */ 27 | public class HFSCommonFSFile extends HFSCommonAbstractFile implements FSFile { 28 | protected HFSCommonFSFile(HFSCommonFileSystemHandler parent, 29 | CommonHFSCatalogFileRecord fileRecord) { 30 | super(parent, fileRecord); 31 | } 32 | 33 | protected HFSCommonFSFile(HFSCommonFileSystemHandler parent, 34 | CommonHFSCatalogLeafRecord hardLinkRecord, 35 | CommonHFSCatalogFileRecord fileRecord) { 36 | super(parent, hardLinkRecord, fileRecord); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/fs/hfscommon/HFSCommonFileSystemHandlerFactory.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2009-2014 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.fs.hfscommon; 19 | 20 | import io.takari.jdkget.osx.storage.fs.FileSystemHandlerFactory; 21 | 22 | /** 23 | * @author Erik Larsson 24 | */ 25 | public abstract class HFSCommonFileSystemHandlerFactory extends FileSystemHandlerFactory { 26 | protected static final CustomAttribute posixFilenamesAttribute = 27 | createCustomAttribute(AttributeType.BOOLEAN, "POSIX_FILENAMES", 28 | "Controls whether filenames should be translated from " + 29 | "their on-disk format to POSIX format, swapping the ':' " + 30 | "and '/' characters.", 31 | false); 32 | 33 | @Override 34 | public CustomAttribute[] getSupportedCustomAttributes() { 35 | return new CustomAttribute[] { 36 | posixFilenamesAttribute, 37 | }; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/fs/hfsplus/HFSPlusFileSystemRecognizer.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.fs.hfsplus; 19 | 20 | import io.takari.jdkget.osx.io.ReadableRandomAccessStream; 21 | import io.takari.jdkget.osx.storage.fs.FileSystemRecognizer; 22 | import io.takari.jdkget.osx.storage.fs.hfscommon.HFSCommonFileSystemRecognizer; 23 | 24 | /** 25 | * @author Erik Larsson 26 | */ 27 | public class HFSPlusFileSystemRecognizer implements FileSystemRecognizer { 28 | 29 | @Override 30 | public boolean detect(ReadableRandomAccessStream fsStream, long offset, long length) { 31 | switch (HFSCommonFileSystemRecognizer.detectFileSystem(fsStream, offset)) { 32 | case HFS_PLUS: 33 | case HFS_WRAPPED_HFS_PLUS: 34 | return true; 35 | default: 36 | return false; 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/fs/hfsx/HFSXFileSystemHandler.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008-2014 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.fs.hfsx; 19 | 20 | import io.takari.jdkget.osx.hfs.x.HFSXVolume; 21 | import io.takari.jdkget.osx.storage.fs.hfsplus.HFSPlusFileSystemHandler; 22 | import io.takari.jdkget.osx.storage.io.DataLocator; 23 | 24 | /** 25 | * HFSX implementation of a FileSystemHandler. This implementation can be used 26 | * to access HFSX file systems. (HFSX file systems are very similar to HFS+, 27 | * but with a few extensions, like the ability to treat file names in a case 28 | * sensitive manner). 29 | * 30 | * @author Erik Larsson 31 | */ 32 | public class HFSXFileSystemHandler extends HFSPlusFileSystemHandler { 33 | 34 | public HFSXFileSystemHandler(DataLocator fsLocator, boolean useCaching, 35 | boolean posixNames, boolean doUnicodeFileNameComposition, 36 | boolean hideProtected) { 37 | super(new HFSXVolume(fsLocator.createReadOnlyFile(), useCaching), 38 | posixNames, doUnicodeFileNameComposition, hideProtected); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/fs/hfsx/HFSXFileSystemRecognizer.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.fs.hfsx; 19 | 20 | import io.takari.jdkget.osx.io.ReadableRandomAccessStream; 21 | import io.takari.jdkget.osx.storage.fs.FileSystemRecognizer; 22 | import io.takari.jdkget.osx.storage.fs.hfscommon.HFSCommonFileSystemRecognizer; 23 | 24 | /** 25 | * @author Erik Larsson 26 | */ 27 | public class HFSXFileSystemRecognizer implements FileSystemRecognizer { 28 | 29 | @Override 30 | public boolean detect(ReadableRandomAccessStream fsStream, long offset, long length) { 31 | switch (HFSCommonFileSystemRecognizer.detectFileSystem(fsStream, offset)) { 32 | case HFSX: 33 | return true; 34 | default: 35 | return false; 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/io/SubDataLocator.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2009 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.io; 19 | 20 | import io.takari.jdkget.osx.io.ConcatenatedStream; 21 | import io.takari.jdkget.osx.io.RandomAccessStream; 22 | import io.takari.jdkget.osx.io.ReadableConcatenatedStream; 23 | import io.takari.jdkget.osx.io.ReadableRandomAccessStream; 24 | 25 | /** 26 | * @author Erik Larsson 27 | */ 28 | public class SubDataLocator extends DataLocator { 29 | private DataLocator source; 30 | private long offset; 31 | private long length; 32 | 33 | public SubDataLocator(DataLocator source, long offset, long length) { 34 | this.source = source; 35 | this.offset = offset; 36 | this.length = length; 37 | 38 | this.source.addReference(this); 39 | } 40 | 41 | @Override 42 | public ReadableRandomAccessStream createReadOnlyFile() { 43 | return new ReadableConcatenatedStream(source.createReadOnlyFile(), offset, length); 44 | } 45 | 46 | @Override 47 | public boolean isWritable() { 48 | return source.isWritable(); 49 | } 50 | 51 | @Override 52 | public RandomAccessStream createReadWriteFile() throws UnsupportedOperationException { 53 | return new ConcatenatedStream(source.createReadWriteFile(), offset, length); 54 | } 55 | 56 | @Override 57 | public void releaseResources() { 58 | source.removeReference(this); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/Partition.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2006-2009 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps; 19 | 20 | import io.takari.jdkget.osx.csjc.PrintableStruct; 21 | 22 | /** 23 | *
24 |  * A partition is a string of bytes. It is a substring of some possibly larger
25 |  * string of bytes (usually representing a physical device holding the data,
26 |  * such as a hard disk, a memory stick or an optical disc).
27 |  *
28 |  * A partition usually has metadata asssociated with it, facilitating the
29 |  * interpretation of the data inside the partition. This simple abstraction
30 |  * produces three fundamental variables:
31 |  * the start offset, the length of the partition and the partition type.
32 |  *
33 |  * While most partition systems specify their offsets in sectors or blocks, the
34 |  * unit of this general partition will be one byte, so most implementations will
35 |  * need to convert from the native sector number to an actual byte offset/length.
36 |  * 
37 | * 38 | * @author Erik Larsson 39 | */ 40 | public interface Partition extends PrintableStruct { 41 | /** Returns the start offset in bytes. */ 42 | public abstract long getStartOffset(); 43 | 44 | /** Returns the length of the partition in bytes. */ 45 | public abstract long getLength(); 46 | 47 | /** Returns the type of the partition. */ 48 | public abstract PartitionType getType(); 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/PartitionSystemHandler.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps; 19 | 20 | /** 21 | * Stub. 22 | * 23 | * @author Erik Larsson 24 | */ 25 | public abstract class PartitionSystemHandler { 26 | 27 | public abstract long getPartitionCount(); 28 | 29 | public abstract Partition[] getPartitions(); 30 | 31 | public abstract void close(); 32 | 33 | /** 34 | * Returns the partition with number partitionNumber, or 35 | * null if there is no partition with the specified number. 36 | * 37 | * @param partitionNumber the requested partition number. 38 | * @return the partition with number partitionNumber, or 39 | * null if there is no partition with the specified number. 40 | */ 41 | public Partition getPartition(int partitionNumber) { 42 | Partition[] parts = getPartitions(); 43 | if (partitionNumber >= 0 && partitionNumber < parts.length) 44 | return parts[partitionNumber]; 45 | else 46 | return null; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/PartitionSystemHandlerFactory.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps; 19 | 20 | import io.takari.jdkget.osx.storage.io.DataLocator; 21 | 22 | /** 23 | * A subclass of PartitionSystemHandlerFactory must always have a empty 24 | * constructor in order to be used as such. 25 | * 26 | * @author Erik Larsson 27 | */ 28 | public abstract class PartitionSystemHandlerFactory { 29 | public abstract PartitionSystemRecognizer getRecognizer(); 30 | 31 | public abstract PartitionSystemHandler createHandler(DataLocator partitionData); 32 | 33 | //public abstract PartitionSystemRecognizer createDetector(DataLocator partitionData); 34 | public abstract PartitionSystemImplementationInfo getInfo(); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/PartitionSystemImplementationInfo.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps; 19 | 20 | /** 21 | * @author Erik Larsson 22 | */ 23 | public class PartitionSystemImplementationInfo { 24 | private String partitionSystemName; 25 | private String implementationName; 26 | private String implementationVersion; 27 | private String author; 28 | 29 | public PartitionSystemImplementationInfo(String partitionSystemName, 30 | String implementationName, String implementationVersion, 31 | String author) { 32 | this.partitionSystemName = partitionSystemName; 33 | this.implementationName = implementationName; 34 | this.implementationVersion = implementationVersion; 35 | this.author = author; 36 | } 37 | 38 | public String getPartitionSystemName() { 39 | return partitionSystemName; 40 | } 41 | 42 | public String getImplementationName() { 43 | return implementationName; 44 | } 45 | 46 | public String getImplementationVersion() { 47 | return implementationVersion; 48 | } 49 | 50 | public String getAuthor() { 51 | return author; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/PartitionSystemRecognizer.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps; 19 | 20 | import io.takari.jdkget.osx.io.ReadableRandomAccessStream; 21 | 22 | /** 23 | * @author Erik Larsson 24 | */ 25 | public interface PartitionSystemRecognizer { 26 | /* TODO: detect should take a sectorSize argument... */ 27 | /** 28 | * Detects whether there is a partition system located at the specified 29 | * offset in fsStream. Which partition system is being detected is dependent 30 | * on the context. 31 | * 32 | * @param fsStream 33 | * @param offset the offset in fsStream to the start of the file system. 34 | * @param length this parameter may be set to -1 if the length isn't 35 | * currently known. 36 | * @return true if a file system can be detected at the 37 | * specified offset in fsStream, and false otherwise. 38 | */ 39 | public boolean detect(ReadableRandomAccessStream fsStream, long offset, long length); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/apm/APMHandlerFactory.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps.apm; 19 | 20 | import io.takari.jdkget.osx.storage.io.DataLocator; 21 | import io.takari.jdkget.osx.storage.ps.PartitionSystemHandler; 22 | import io.takari.jdkget.osx.storage.ps.PartitionSystemHandlerFactory; 23 | import io.takari.jdkget.osx.storage.ps.PartitionSystemImplementationInfo; 24 | import io.takari.jdkget.osx.storage.ps.PartitionSystemRecognizer; 25 | 26 | /** 27 | * @author Erik Larsson 28 | */ 29 | public class APMHandlerFactory extends PartitionSystemHandlerFactory { 30 | private static final APMRecognizer recognizer = new APMRecognizer(); 31 | 32 | @Override 33 | public PartitionSystemHandler createHandler(DataLocator partitionData) { 34 | return new APMHandler(partitionData); 35 | } 36 | 37 | @Override 38 | public PartitionSystemImplementationInfo getInfo() { 39 | return new PartitionSystemImplementationInfo("Apple Partition Map", 40 | "Catacombae APM PS Handler", "1.0", "Catacombae"); 41 | } 42 | 43 | @Override 44 | public PartitionSystemRecognizer getRecognizer() { 45 | return recognizer; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/apm/APMPartitionType.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps.apm; 19 | 20 | import io.takari.jdkget.osx.storage.ps.PartitionType; 21 | 22 | /** 23 | * @author Erik Larsson 24 | */ 25 | public enum APMPartitionType { 26 | // Partition type 27 | APPLE_PARTITION_MAP("Apple_partition_map", PartitionType.APPLE_PARTITION_MAP), APPLE_DRIVER("Apple_Driver", PartitionType.APPLE_DRIVER), APPLE_DRIVER43("Apple_Driver43", 28 | PartitionType.APPLE_DRIVER), APPLE_MFS("Apple_MFS", PartitionType.APPLE_MFS), 29 | /** Since the Apple_HFS type can mean HFS or HFS+, we bind it to a container type */ 30 | APPLE_HFS("Apple_HFS", PartitionType.APPLE_HFS_CONTAINER), APPLE_HFSX("Apple_HFSX", PartitionType.APPLE_HFSX), APPLE_UNIX_SVR2("Apple_Unix_SVR2", 31 | PartitionType.APPLE_UNIX_SVR2), APPLE_PRODOS("Apple_PRODOS", PartitionType.APPLE_PRODOS), APPLE_FREE("Apple_Free", PartitionType.EMPTY), APPLE_SCRATCH("Apple_Scratch", PartitionType.EMPTY); 32 | 33 | private final String apmName; 34 | private final PartitionType generalType; 35 | 36 | private APMPartitionType(String apmName) { 37 | this(apmName, null); 38 | } 39 | 40 | private APMPartitionType(String apmName, PartitionType generalType) { 41 | this.apmName = apmName; 42 | this.generalType = generalType; 43 | } 44 | 45 | public String getAPMName() { 46 | return apmName; 47 | } 48 | 49 | public PartitionType getGeneralType() { 50 | return generalType; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/apm/APMRecognizer.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps.apm; 19 | 20 | import io.takari.jdkget.osx.io.ReadableRandomAccessStream; 21 | import io.takari.jdkget.osx.storage.ps.PartitionSystemRecognizer; 22 | import io.takari.jdkget.osx.storage.ps.apm.types.ApplePartitionMap; 23 | import io.takari.jdkget.osx.storage.ps.apm.types.DriverDescriptorRecord; 24 | 25 | /** 26 | * @author Erik Larsson 27 | */ 28 | public class APMRecognizer implements PartitionSystemRecognizer { 29 | 30 | @Override 31 | public boolean detect(ReadableRandomAccessStream fsStream, long offset, long length) { 32 | try { 33 | //ReadableRandomAccessStream llf = data.createReadOnlyFile(); 34 | byte[] firstBlock = new byte[512]; 35 | 36 | fsStream.seek(0); 37 | fsStream.readFully(firstBlock); 38 | 39 | // Look for APM 40 | DriverDescriptorRecord ddr = new DriverDescriptorRecord(firstBlock, 0); 41 | if (ddr.isValid()) { 42 | int blockSize = ddr.getSbBlkSize(); 43 | //long numberOfBlocksOnDevice = Util.unsign(ddr.getSbBlkCount()); 44 | //bitStream.seek(blockSize*1); // second block, first partition in list 45 | ApplePartitionMap apm = new ApplePartitionMap(fsStream, blockSize * 1, blockSize); 46 | if (apm.getUsedPartitionCount() > 0) { 47 | return true; 48 | } 49 | } 50 | } catch (Exception e) { 51 | } 52 | return false; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/apm/types/DriverDescriptorEntry.struct: -------------------------------------------------------------------------------- 1 | struct DriverDescriptorEntry { 2 | UInt32 ddBlock; // {first driver's starting block} 3 | UInt16 ddSize; // {size of the driver, in 512-byte blocks} 4 | UInt16 ddType; // {operating system type (MacOS = 1)} 5 | }; 6 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/apm/types/DriverDescriptorRecord.struct: -------------------------------------------------------------------------------- 1 | struct DriverDescriptorRecord { 2 | be16 sbSig; // Device signature. 3 | be16 sbBlkSize; // Block size of the device. 4 | be32 sbBlkCount; // Number of blocks on the device. 5 | be16 sbDevType; // Reserved. 6 | be16 sbDevId; // Reserved. 7 | be32 dbData; // Reserved. 8 | be16 sbDrvrCount; // Number of driver descriptor entries. 9 | DriverDescriptorEntry entries[1]; // Drivers, if any. 10 | u8 ddPad[1]; // Reserved. 11 | }; 12 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/container/ContainerHandler.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps.container; 19 | 20 | import io.takari.jdkget.osx.storage.fs.FileSystemMajorType; 21 | import io.takari.jdkget.osx.storage.ps.PartitionSystemType; 22 | 23 | /** 24 | * @author Erik Larsson 25 | */ 26 | public abstract class ContainerHandler { 27 | /** Returns true if the container contains a file system. */ 28 | public abstract boolean containsFileSystem(); 29 | 30 | /** Returns true if the container contains a partition system. */ 31 | public abstract boolean containsPartitionSystem(); 32 | 33 | /** Returns true if the container contains another container. */ 34 | public abstract boolean containsContainer(); 35 | 36 | /** 37 | * Probes for the file system type contained within this container. Returns 38 | * null if the file system type could not be determined. 39 | */ 40 | public abstract FileSystemMajorType detectFileSystemType(); 41 | 42 | /** 43 | * Probes for the partition system type contained within this container. 44 | * Returns null if the partition system type could not be determined. 45 | */ 46 | public abstract PartitionSystemType detectPartitionSystemType(); 47 | 48 | /** 49 | * Probes for the container type contained within this container. 50 | * Returns null if the container type could not be determined. 51 | */ 52 | public abstract ContainerType detectContainerType(); 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/container/ContainerHandlerFactory.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps.container; 19 | 20 | import io.takari.jdkget.osx.storage.io.DataLocator; 21 | 22 | /** 23 | * @author Erik Larsson 24 | */ 25 | public abstract class ContainerHandlerFactory { 26 | public abstract ContainerHandler createHandler(DataLocator containerData); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/container/hfs/HFSContainerHandlerFactory.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps.container.hfs; 19 | 20 | import io.takari.jdkget.osx.storage.io.DataLocator; 21 | import io.takari.jdkget.osx.storage.ps.container.ContainerHandler; 22 | import io.takari.jdkget.osx.storage.ps.container.ContainerHandlerFactory; 23 | 24 | /** 25 | * @author Erik Larsson 26 | */ 27 | public class HFSContainerHandlerFactory extends ContainerHandlerFactory { 28 | 29 | @Override 30 | public ContainerHandler createHandler(DataLocator containerData) { 31 | throw new UnsupportedOperationException("Not supported yet."); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/ebr/EBRHandlerFactory.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps.ebr; 19 | 20 | import io.takari.jdkget.osx.storage.io.DataLocator; 21 | import io.takari.jdkget.osx.storage.ps.PartitionSystemHandler; 22 | import io.takari.jdkget.osx.storage.ps.PartitionSystemHandlerFactory; 23 | import io.takari.jdkget.osx.storage.ps.PartitionSystemImplementationInfo; 24 | import io.takari.jdkget.osx.storage.ps.PartitionSystemRecognizer; 25 | 26 | /** 27 | * @author Erik Larsson 28 | */ 29 | public class EBRHandlerFactory extends PartitionSystemHandlerFactory { 30 | 31 | private static final EBRRecognizer recognizer = new EBRRecognizer(); 32 | 33 | @Override 34 | public PartitionSystemHandler createHandler(DataLocator data) { 35 | return new EBRHandler(data); 36 | } 37 | 38 | @Override 39 | public PartitionSystemImplementationInfo getInfo() { 40 | return new PartitionSystemImplementationInfo("Extended Boot Record", 41 | "Catacombae EBR PS Handler", "1.0", "Catacombae"); 42 | } 43 | 44 | @Override 45 | public PartitionSystemRecognizer getRecognizer() { 46 | return recognizer; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/ebr/EBRPartition.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps.ebr; 19 | 20 | import io.takari.jdkget.osx.storage.ps.mbr.types.MBRPartition; 21 | 22 | public class EBRPartition extends MBRPartition { 23 | 24 | private final long baseOffset; 25 | 26 | /** 27 | * 28 | * @param data 29 | * @param offset offset in data to the EBR partition data. 30 | * @param baseOffset the base offset which we will resolve startOffset 31 | * against. 32 | * @param sectorSize 33 | */ 34 | public EBRPartition(byte[] data, int offset, long baseOffset, int sectorSize) { 35 | super(data, offset, sectorSize); 36 | this.baseOffset = baseOffset; 37 | } 38 | 39 | /** Copy constructor. */ 40 | public EBRPartition(EBRPartition source) { 41 | super(source); 42 | this.baseOffset = source.baseOffset; 43 | } 44 | 45 | // Defined in Partition 46 | @Override 47 | public long getStartOffset() { 48 | return super.getStartOffset() + baseOffset; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/ebr/EBRRecognizer.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps.ebr; 19 | 20 | import io.takari.jdkget.osx.io.ReadableRandomAccessStream; 21 | import io.takari.jdkget.osx.storage.ps.PartitionSystemRecognizer; 22 | 23 | /** 24 | * @author Erik Larsson 25 | */ 26 | public class EBRRecognizer implements PartitionSystemRecognizer { 27 | @Override 28 | public boolean detect(ReadableRandomAccessStream fsStream, long offset, long length) { 29 | try { 30 | EBRPartitionSystem ps = new EBRPartitionSystem(fsStream, offset, 512); 31 | if (ps.isValid()) { 32 | return true; 33 | } 34 | } catch (Exception e) { 35 | } 36 | 37 | return false; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/gpt/GPTHandlerFactory.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps.gpt; 19 | 20 | import io.takari.jdkget.osx.storage.io.DataLocator; 21 | import io.takari.jdkget.osx.storage.ps.PartitionSystemHandler; 22 | import io.takari.jdkget.osx.storage.ps.PartitionSystemHandlerFactory; 23 | import io.takari.jdkget.osx.storage.ps.PartitionSystemImplementationInfo; 24 | import io.takari.jdkget.osx.storage.ps.PartitionSystemRecognizer; 25 | 26 | /** 27 | * @author Erik Larsson 28 | */ 29 | public class GPTHandlerFactory extends PartitionSystemHandlerFactory { 30 | 31 | private static final GPTRecognizer recognizer = new GPTRecognizer(); 32 | 33 | @Override 34 | public PartitionSystemHandler createHandler(DataLocator data) { 35 | return new GPTHandler(data); 36 | } 37 | 38 | @Override 39 | public PartitionSystemImplementationInfo getInfo() { 40 | return new PartitionSystemImplementationInfo("GUID Partition Table", 41 | "Catacombae GPT PS Handler", "1.0", "Catacombae"); 42 | } 43 | 44 | @Override 45 | public PartitionSystemRecognizer getRecognizer() { 46 | return recognizer; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/gpt/GPTRecognizer.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps.gpt; 19 | 20 | import io.takari.jdkget.osx.io.ReadableRandomAccessStream; 21 | import io.takari.jdkget.osx.storage.ps.PartitionSystemRecognizer; 22 | import io.takari.jdkget.osx.storage.ps.gpt.types.GPTHeader; 23 | 24 | /** 25 | * @author Erik Larsson 26 | */ 27 | public class GPTRecognizer implements PartitionSystemRecognizer { 28 | 29 | @Override 30 | public boolean detect(ReadableRandomAccessStream fsStream, long offset, long length) { 31 | try { 32 | //ReadableRandomAccessStream llf = data.createReadOnlyFile(); 33 | byte[] secondBlock = new byte[512]; 34 | fsStream.seek(512); 35 | fsStream.readFully(secondBlock); 36 | 37 | // Look for GPT 38 | // Let's assume that blocks are always 512 bytes in size with MBR and GPT. I don't know 39 | // how to detect the actual block size (at least when reading from a file, otherwise I 40 | // guess there are system specific ways)... 41 | GPTHeader gh = new GPTHeader(secondBlock, 0, 512); 42 | if (gh.isValid()) { 43 | return true; 44 | } 45 | } catch (Exception e) { 46 | } 47 | 48 | return false; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/gpt/types/GPTEntry.struct: -------------------------------------------------------------------------------- 1 | struct GPTEntry { 2 | byte[16] partitionTypeGUID; 3 | byte[16] uniquePartitionGUID; 4 | UInt64 startingLBA; 5 | UInt64 endingLBA; 6 | UInt64 attributeBits; 7 | byte[72] partitionName; 8 | }; 9 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/mbr/MBRHandlerFactory.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps.mbr; 19 | 20 | import io.takari.jdkget.osx.storage.io.DataLocator; 21 | import io.takari.jdkget.osx.storage.ps.PartitionSystemHandler; 22 | import io.takari.jdkget.osx.storage.ps.PartitionSystemHandlerFactory; 23 | import io.takari.jdkget.osx.storage.ps.PartitionSystemImplementationInfo; 24 | import io.takari.jdkget.osx.storage.ps.PartitionSystemRecognizer; 25 | 26 | /** 27 | * @author Erik Larsson 28 | */ 29 | public class MBRHandlerFactory extends PartitionSystemHandlerFactory { 30 | 31 | private static final MBRRecognizer recognizer = new MBRRecognizer(); 32 | 33 | @Override 34 | public PartitionSystemHandler createHandler(DataLocator data) { 35 | return new MBRHandler(data); 36 | } 37 | 38 | @Override 39 | public PartitionSystemImplementationInfo getInfo() { 40 | return new PartitionSystemImplementationInfo("Master Boot Record", 41 | "Catacombae MBR PS Handler", "1.0", "Catacombae"); 42 | } 43 | 44 | @Override 45 | public PartitionSystemRecognizer getRecognizer() { 46 | return recognizer; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/storage/ps/mbr/MBRRecognizer.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.storage.ps.mbr; 19 | 20 | import io.takari.jdkget.osx.io.ReadableRandomAccessStream; 21 | import io.takari.jdkget.osx.storage.ps.PartitionSystemRecognizer; 22 | import io.takari.jdkget.osx.storage.ps.mbr.types.MBRPartitionTable; 23 | 24 | /** 25 | * @author Erik Larsson 26 | */ 27 | public class MBRRecognizer implements PartitionSystemRecognizer { 28 | 29 | @Override 30 | public boolean detect(ReadableRandomAccessStream fsStream, long offset, long length) { 31 | try { 32 | byte[] firstBlock = new byte[512]; 33 | fsStream.read(firstBlock); 34 | 35 | // Look for MBR 36 | MBRPartitionTable mpt = new MBRPartitionTable(firstBlock, 0); 37 | if (mpt.isValid()) { 38 | return true; 39 | } 40 | } catch (Exception e) { 41 | } 42 | 43 | return false; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/util/ObjectContainer.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2008 Erik Larsson 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | package io.takari.jdkget.osx.util; 20 | 21 | public class ObjectContainer { 22 | 23 | public volatile A o; 24 | 25 | public ObjectContainer(A o) { 26 | super(); 27 | this.o = o; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/xml/Attribute.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2007-2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation, either version 3 of the License, or (at your option) any 7 | * later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.xml; 19 | 20 | import java.util.List; 21 | 22 | public class Attribute { 23 | public static abstract class ValueComponent { 24 | @Override 25 | public abstract String toString(); 26 | } 27 | public static class StringComponent extends ValueComponent { 28 | public String content; 29 | 30 | public StringComponent(String content) { 31 | this.content = content; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return content; 37 | } 38 | } 39 | public static class ReferenceComponent extends ValueComponent { 40 | public String content; 41 | 42 | public ReferenceComponent(String content) { 43 | this.content = content; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return content; 49 | } // should resolve the reference here 50 | } 51 | public static class Value { 52 | public List components; 53 | 54 | public Value(List components) { 55 | this.components = components; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | StringBuilder result = new StringBuilder(); 61 | for (ValueComponent vc : components) 62 | result.append(vc.toString()); 63 | return result.toString(); 64 | } 65 | } 66 | 67 | public String identifier; 68 | public Value value; 69 | 70 | public Attribute(String identifier, Value value) { 71 | this.identifier = identifier; 72 | this.value = value; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/xml/Attribute2.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2006-2008 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation, either version 3 of the License, or (at your option) any 7 | * later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.xml; 19 | 20 | public class Attribute2 { 21 | public final String localName; 22 | public final String qName; 23 | public final String type; 24 | public final String URI; 25 | public final String value; 26 | 27 | public Attribute2(String localName, String qName, String type, String URI, String value) { 28 | this.localName = localName; 29 | this.qName = qName; 30 | this.type = type; 31 | this.URI = URI; 32 | this.value = value; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/xml/ExternalID.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2007 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation, either version 3 of the License, or (at your option) any 7 | * later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.xml; 19 | 20 | public class ExternalID { 21 | public static final int SYSTEM = 0; 22 | public static final int PUBLIC = 1; 23 | public int type; 24 | public String pubidLiteral; 25 | public String systemLiteral; 26 | 27 | public ExternalID(String pubidLiteral, String systemLiteral) { 28 | this.pubidLiteral = pubidLiteral; 29 | this.systemLiteral = systemLiteral; 30 | this.type = PUBLIC; 31 | } 32 | 33 | public ExternalID(String systemLiteral) { 34 | this.systemLiteral = systemLiteral; 35 | this.type = SYSTEM; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/xml/NullXMLContentHandler.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2007 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation, either version 3 of the License, or (at your option) any 7 | * later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.xml; 19 | 20 | import java.nio.charset.Charset; 21 | import java.util.List; 22 | 23 | public class NullXMLContentHandler extends XMLContentHandler { 24 | public NullXMLContentHandler(Charset encoding) { 25 | super(encoding); 26 | } 27 | 28 | @Override 29 | public void xmlDecl(String version, String encoding, Boolean standalone) {} 30 | 31 | @Override 32 | public void pi(String id, String content) {} 33 | 34 | @Override 35 | public void comment(String comment) {} 36 | 37 | @Override 38 | public void doctype(String name, ExternalID eid) {} // Needs a DTD description also 39 | 40 | @Override 41 | public void cdata(String cdata) {} 42 | 43 | @Override 44 | public void emptyElement(String name, List attributes) {} 45 | 46 | @Override 47 | public void startElement(String name, List attributes) {} 48 | 49 | @Override 50 | public void endElement(String name) {} 51 | 52 | @Override 53 | public void chardata(int beginLine, int beginColumn, int endLine, int endColumn) {} 54 | 55 | @Override 56 | public void reference(String ref) {} 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/xml/XMLContentHandler.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2007 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation, either version 3 of the License, or (at your option) any 7 | * later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.xml; 19 | 20 | import java.nio.charset.Charset; 21 | import java.util.List; 22 | 23 | public abstract class XMLContentHandler { 24 | protected Charset encoding; 25 | 26 | public XMLContentHandler(Charset encoding) { 27 | this.encoding = encoding; 28 | } 29 | 30 | //public void doctype(String 31 | public abstract void xmlDecl(String version, String encoding, Boolean standalone); 32 | 33 | public abstract void pi(String id, String content); 34 | 35 | public abstract void comment(String comment); 36 | 37 | public abstract void doctype(String name, ExternalID eid); // Needs a DTD description also 38 | 39 | public abstract void cdata(String cdata); 40 | 41 | public abstract void emptyElement(String name, List attributes); 42 | 43 | public abstract void startElement(String name, List attributes); 44 | 45 | public abstract void endElement(String name); 46 | 47 | public abstract void chardata(int beginLine, int beginColumn, int endLine, int endColumn); 48 | 49 | public abstract void reference(String ref); 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/osx/xml/XMLElement.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 2006 Erik Larsson 3 | * 4 | * This program is free software: you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation, either version 3 of the License, or (at your option) any 7 | * later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package io.takari.jdkget.osx.xml; 19 | 20 | import java.io.PrintStream; 21 | 22 | public abstract class XMLElement { 23 | protected abstract void _printTree(PrintStream pw, int level); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/win/ByteSource.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget.win; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | public interface ByteSource { 7 | 8 | /** 9 | * @see InputStream#read(byte[], int, int) 10 | */ 11 | int read(byte[] buf, int offset, int len) throws IOException; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/io/takari/jdkget/win/CabIO.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget.win; 2 | 3 | public final class CabIO { 4 | private CabIO() {} 5 | 6 | static int EndGetI16(byte[] buf, int off) { 7 | return (buf[off] & 0xFF) | ((buf[off + 1] & 0xFF) << 8); 8 | } 9 | 10 | static int EndGetI32(byte[] buf, int off) { 11 | return (buf[off] & 0xFF) | ((buf[off + 1] & 0xFF) << 8) | ((buf[off + 2] & 0xFF) << 16) | ((buf[off + 3] & 0xFF) << 24); 12 | } 13 | 14 | static long EndGetL32(byte[] buf, int off) { 15 | return ((long) buf[off] & 0xFF) | (((long) buf[off + 1] & 0xFF) << 8) | (((long) buf[off + 2] & 0xFF) << 16) | (((long) buf[off + 3] & 0xFF) << 24); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/io/takari/jdkget/DumbTransport.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | 6 | import io.takari.jdkget.model.JdkBinary; 7 | 8 | public class DumbTransport implements ITransport { 9 | private boolean valid; 10 | int tries; 11 | 12 | public DumbTransport(boolean valid) { 13 | this.valid = valid; 14 | tries = 0; 15 | } 16 | 17 | @Override 18 | public void downloadJdk(JdkGetter context, JdkBinary binary, File jdkImage) 19 | throws IOException, InterruptedException { 20 | jdkImage.createNewFile(); 21 | tries++; 22 | } 23 | 24 | @Override 25 | public boolean validate(JdkGetter context, JdkBinary binary, File jdkImage) 26 | throws IOException, InterruptedException { 27 | return valid; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/io/takari/jdkget/JdkGetterTest.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.fail; 5 | 6 | import io.takari.jdkget.model.JdkReleases; 7 | 8 | import java.io.File; 9 | import java.io.IOException; 10 | 11 | import org.junit.Rule; 12 | import org.junit.Test; 13 | import org.junit.rules.TemporaryFolder; 14 | 15 | public class JdkGetterTest { 16 | 17 | @Rule 18 | public final TemporaryFolder temporaryFolder = new TemporaryFolder(new File("target/")); // trash target and not system 19 | 20 | @Test 21 | public void testRetries() throws Exception { 22 | 23 | DumbTransport t = new DumbTransport(false); 24 | try { 25 | JdkGetter jdkGet = new JdkGetter(t, IOutput.NULL_OUTPUT); 26 | jdkGet.getJdk(Arch.NIX_64, temporaryFolder.newFolder()); 27 | fail(); 28 | } catch (IOException e) { 29 | assertEquals(4, t.tries); 30 | } 31 | } 32 | 33 | @Test 34 | public void testInterrupts() throws Exception { 35 | 36 | JdkReleases.get(); 37 | 38 | SleepingTransport transport = new SleepingTransport(); 39 | JdkGetter jdkGet = new JdkGetter(transport, IOutput.NULL_OUTPUT); 40 | 41 | Thread cur = Thread.currentThread(); 42 | 43 | new Thread() { 44 | public void run() { 45 | synchronized (transport) { 46 | try { 47 | transport.wait(); 48 | } catch (InterruptedException e) { 49 | } 50 | } 51 | cur.interrupt(); 52 | } 53 | }.start(); 54 | 55 | try { 56 | jdkGet.getJdk(Arch.NIX_64, temporaryFolder.newFolder()); 57 | fail(); 58 | } catch (InterruptedException e) { 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/test/java/io/takari/jdkget/SleepingTransport.java: -------------------------------------------------------------------------------- 1 | package io.takari.jdkget; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | 6 | import io.takari.jdkget.model.JdkBinary; 7 | 8 | public class SleepingTransport implements ITransport { 9 | 10 | @Override 11 | public void downloadJdk(JdkGetter context, JdkBinary binary, File jdkImage) 12 | throws IOException, InterruptedException { 13 | synchronized (this) { 14 | this.notify(); 15 | this.wait(); 16 | } 17 | } 18 | 19 | @Override 20 | public boolean validate(JdkGetter context, JdkBinary binary, File jdkImage) 21 | throws IOException, InterruptedException { 22 | return true; 23 | } 24 | 25 | } 26 | --------------------------------------------------------------------------------