Skip to content
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

Closed

Conversation

neikeq
Copy link
Contributor

@neikeq neikeq commented Jul 27, 2020

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.

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;
Copy link
Member

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?

Copy link
Contributor Author

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.");
Copy link
Member

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.

Copy link
Contributor Author

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.

@akien-mga
Copy link
Member

@neikeq Should probably revisit this at some point :)
For now moving to next milestone but if you want to finish this for 4.0 feel free to change it back.

@akien-mga akien-mga modified the milestones: 4.0, 4.x Jul 28, 2022
@akien-mga
Copy link
Member

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.

@akien-mga akien-mga closed this May 3, 2024
@akien-mga akien-mga removed this from the 4.x milestone May 3, 2024
@raulsntos
Copy link
Member

Yep, I have this rebased in a local branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants