-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
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
[WIP] More C# friendly API for Godot file access #40775
Conversation
This is still Work-In-Progress. For now the basic idea is to provide a Stream class and imitations of the System.IO.File and System.IO.Directory static classes wrapping the Godot file system API. There are a few things still missing, most of them because of lack of support in the Godot fs API itself. There are no documentation comments yet. That will likely be the last step before merging.
return true; | ||
default: | ||
e = new Exception(msg); | ||
return true; |
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.
Considering all paths after the first if
statement return true
, maybe these should be break
and then we can return true
at the bottom to make this clear?
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.
Will do!
long length = stream.Length; | ||
|
||
if (length > int.MaxValue) | ||
throw new IOException("The file is too long. Only files less than 2 GBs in size are supported."); |
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.
What is preventing us from supporting 64-bit file access? I think we should. IIRC Godot will support this in core in 4.0.
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.
Array max length is int.MaxValue
(~2 GB). The purpose of this method is to mimic System.IO.File.ReadAllBytes
which returns a byte[]
, so we're limited to that.
It's not a good idea to read that much at once any way. Better read in chunks, even for much smaller files.
@neikeq Should probably revisit this at some point :) |
Closing as this is an old draft that is no longer actionable. CC @godotengine/dotnet in case some of the work here would still be relevant to redo. |
Yep, I have this rebased in a local branch. |
This is still Work-In-Progress.
For now the basic idea is to provide a Stream class and imitations of the System.IO.File and System.IO.Directory static classes wrapping the Godot file system API.
There are a few things still missing, most of them because of lack of support in the Godot fs API itself.
There are no documentation comments yet. That will likely be the last step before merging.