-
Notifications
You must be signed in to change notification settings - Fork 29
read file from memory #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
affb662
some todos
Wasabi375 0415bfc
enabled read from memory tests
Wasabi375 219f838
fixed readFromMem for FBX
Wasabi375 bb201d6
fixed readFromMem for Direct X Importer
Wasabi375 8416b26
added IOStream size, not yet used everywhere
Wasabi375 8d476a6
cleaning up code adding more todos *sigh* :wink:
Wasabi375 d58d67e
Refactored ByteBuffer creation from IOStream in importers
Wasabi375 d8d1101
Fixed byte order bug in read from memory
Wasabi375 ba4580d
MemoryIOSystem now supports multiple files
Wasabi375 9b6c20d
removed unnecessary file.exists checks
Wasabi375 0d00c5c
removed some warnings
Wasabi375 1070491
removed boblampclean_assbin.kt (file is exact copy of assbin.kt just …
Wasabi375 fef0c5d
Fixed bug where URLs with spaces would not be resolved
Wasabi375 0dc97b8
Fixed read byte bug in ByteBufferBackedInputStream. stupid number con…
Wasabi375 f7c9b0e
MD2 and MD5 is working properly. MD3 is stupid
Wasabi375 01c4c02
fix bug using wrong reference to ioSystem
Wasabi375 a1df627
MD3 relative path workaround
Wasabi375 04f84f0
some final cleanups
Wasabi375 56fe528
final final cleanup
Wasabi375 31e2f45
fixed osSeperator bug on windows
Wasabi375 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,48 @@ | ||
| package assimp | ||
|
|
||
| import java.io.* | ||
| import java.nio.file.Files | ||
| import java.nio.* | ||
| import java.nio.channels.* | ||
| import java.nio.file.Path | ||
| import java.nio.file.Paths | ||
|
|
||
| class DefaultIOSystem : IOSystem { | ||
|
|
||
| override fun exists(pFile: String) = File(pFile).exists() | ||
| override fun exists(file: String) = File(file).exists() | ||
|
|
||
| override fun open(pFile: String): IOStream { | ||
| override fun open(file: String): IOStream { | ||
|
|
||
| val path: Path = Paths.get(pFile) | ||
| if (!Files.exists(path)) | ||
| throw IOException("File doesn't exist: $pFile") | ||
| val path: Path = Paths.get(file) | ||
| if (!exists(file)) | ||
| throw IOException("File doesn't exist: $file") | ||
|
|
||
|
|
||
| return FileIOStream(path) | ||
| return FileIOStream(path, this) | ||
| } | ||
|
|
||
| class FileIOStream(override val path: Path) : IOStream { | ||
| class FileIOStream(private val pathObject: Path, override val osSystem: DefaultIOSystem) : IOStream { | ||
|
|
||
| override val path: String | ||
| get() = pathObject.toString() | ||
|
|
||
| override fun read() = FileInputStream(path.toFile()) | ||
| override fun read() = FileInputStream(file) | ||
|
|
||
| override fun reader() = BufferedReader(FileReader(path.toFile())) | ||
| override fun reader() = BufferedReader(FileReader(file)) | ||
|
|
||
| override val filename: String | ||
| get() = path.fileName.toString() | ||
| get() = pathObject.fileName.toString() | ||
|
|
||
| override val parentPath = pathObject.parent.toAbsolutePath().toString() | ||
|
|
||
| override val length: Long | ||
| get() = file.length() | ||
|
|
||
| override fun readBytes(): ByteBuffer { | ||
| RandomAccessFile(file, "r").channel.use {fileChannel -> | ||
| return fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, fileChannel.size()).order(ByteOrder.nativeOrder()) | ||
| } | ||
| } | ||
|
|
||
| override fun parentPath() = path.parent.toAbsolutePath().toString() | ||
| val file: File | ||
| get() = pathObject.toFile() | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.