-
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
Conversation
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
some todos about importers not working from memory Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
|
Why does XFileImporter check if the file exists before opening, while BlenderLoader does not? I see blender is disabled, but would still like the coding to be consistent. My personal opinon on this is that we should not be checking if the file exists since the open function appears to check if the file exists itself. Also, the exists function in DefaultIOStream compated to Files.exists(path) should be addressed. Both exist in the code and it leads to a little more fragmentation I feel could be unified. |
Sylvyrfysh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove the checks if files exist myself as open will throw a IOException otherwise, and a stacktrace will be sufficient to see which model opening failed.
|
|
||
| // Check whether we can read from the file | ||
| if (!file.canRead()) | ||
| if (!ioSystem.exists(file)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but we again check here
| // with positions that match each other or not? | ||
| // If I move duplicate back here I need to also adjust the byte order here | ||
| // Then I no longer need to change it in MemoryIOSystem.open | ||
| override fun readBytes(): ByteBuffer = buffer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call duplicate here, then remove all other duplicates in the code while making sure the internal buffer is not used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are right. This way there should also be only this one place where we need to call duplicate which means that we only have to call order(ByteOrder.nativeOrder()) once. For some reason duplicate resets the byteOrder to BIG_ENDIAN.
|
|
||
| // Read file into memory | ||
| this.file = file//File(file) | ||
| if (!ioSystem.exists(file)) throw IOException("Failed to open file $file.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not your change, but we check if exists here. Change?
|
|
||
| // Check whether we can read from the file | ||
| if (!file.canRead()) throw IOException("Failed to open PLY file $file.") | ||
| if (!ioSystem.exists(file)) throw IOException("Failed to open PLY file $file.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checking if exists
|
|
||
| // Check whether we can read from the file | ||
| if (!file.canRead()) throw IOException("Failed to open STL file $pFile.") | ||
| if (!ioSystem.exists(file)) throw IOException("Failed to open STL file $file.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checking if file exists
|
I agree with you I think. I did not yet take the time to make sure all the different importers are consistent in the way the do things. I noticed of cause that they are. For some reason one of them is using a pointer to a ByteArray instead of a Buffer for example. The places where it's still using Something else to consider is the filename for memory files, especially in memoryIOSystems with multiple files. They can't all be called |
ObjImporter now loads multi file objects Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
…with a different test name) Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
…versions Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
| Q3Shader.loadShader(fill, "$path../../../scripts/$filename.shader") | ||
| // TODO read from memory: how do we resolve ../../.. | ||
| if (!Q3Shader.loadShader(fill, "$path../../../scripts/$modelFile.shader", ioSystem)) | ||
| Q3Shader.loadShader(fill, "$path../../../scripts/$filename.shader", ioSystem) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure what to do here. I could implement a fully functioning path system but I'm not sure if that is not a bit overkill. The other option would be, that if you want to load relative paths like this from memory that you need to specify those in the name. So you actually name a file "somePath/../../../scripts/moduleName.shader".
This would work right now. Don't think it's a good solution though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't find a solution now, we can postpone the decision until someone needs this and find together a solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I see 3 solutions:
- leave it as it is, there is a simple workaround I used in the test
- modify the ioSystem so that it resolves ".." in a way that it removes the last directory
- change the ioSystem so it uses
java.nio.file.Pathinstead ofStringsto represent a file. That way resolving paths would be trivial, but implementingPathandFileSystem/FileSystemProvidertakes a lot of effort and I don't think it's worth it.
I think for now we can leave it and maybe implement option 2 later.
I created an issue for it: #17
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
|
So long as I have not missed anything, I think this should be all 😉 Would be nice if you guys could look over it again. |
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
|
For me is fine, as soon as @Sylvyrfysh gives me the green light I can publish it |
| } | ||
|
|
||
|
|
||
| // TODO this is pretty much a copy past from gli.read(...) and should be added there |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elect86 You are working on gli right? Can you add a readFromMemory there or should I just sent a PR there myself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sent you an invite for the organization, so that you can automatically work on that without me having to invite for each single repo (I did the same for @Sylvyrfysh)
|
Looks good! |
|
I was trying to run the "build" gradle task but the tests seems not perceived Also, trying to run a single test, such as Does it work on your machines, guys? Edit: looking more carefully the html reports shows most of the tests failing because of |
|
Are you running own windows? It's the only platform I have not tested. All tests run fine on my mac and the travis build is on linux I think. I'll load the project up on my windows computer tomorrow and see if I get the same problem. |
|
Also if you look at the path it's trying to load, it seems to be invalid. |
|
Confirmed. Will try to fix
…On Thu, Sep 6, 2018, 16:36 Burkhard Mittelbach ***@***.***> wrote:
Also if you look at the path it's trying to load, it seems to be invalid.
It starts with "/C:/". But there should not be a / at the start. I guess
it is trying to resolve it as a relative path which is not allowed to
contain colons. I have no idea though why it would create this path.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#16 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AOafQJ8gPZW69_W0IPOUwzJG30yKU9_9ks5uYZVvgaJpZM4WX5hZ>
.
|
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
|
I can't reproduce the bug @elect86 described. I just tested the project on my windows pc as well. I found another small bug though. I hate that windows is using \ instead of / as a separator..... |
|
Whatever change you made, worked. Windows works again for me |
|
Strange, my change should only effect MD3 loading. |
|
I use both window and linux, although I was on windows 10 x64 when I tested that. Problem persist, I'll try to debug. Windows is indeed more tedious in this regard.. However I wonder why the test result interface changed in Idea, I recall in the past all the test, passed and not, were listed, now no more. Do you have any tips about that? |
|
So, I managed to fix it on my machine. I'd like now a feedback from you :) Ps: I notice that I can have the test interface I meant if I run a test singularly |
|
thoroughly off topic but still relevant: should we create a slack or something so we can communicate easier on this |
|
did the windows fix get merged here? |
|
Our traffic is quite low in average, therefore I'd suggest to use lwjgl or kotlin slack Actually I messed up, I thought to pull his modifications, but I was working on the master, now I reverted my mistaken push.. in this regards, how can I pull a push request? Ps: thanks @Wasabi375 for your push :) Edit: it seems there is still no viable gui option, https://stackoverflow.com/questions/40217494/how-to-review-a-pull-request-in-intellij-idea |
|
Do you still want to un-pull? |
|
No, it's fine, thanks |
Followup to PR #16 (read from memory)
I'm still working on it but I thought I might as well create the pr now, so that this is visible.
There are still a few tests failing. I'm not sure if this is due to the fact that some tests fail on master or that some of the Importers are still trying to access files on the drive directly as I have not yet looked at those tests.