godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.08k stars 69 forks source link

Give C# users a way to expose files from within a .pck to be loaded using nuget packages #9500

Open Insofan opened 3 months ago

Insofan commented 3 months ago

Describe the project you are working on

A game need import bulk csv or sql string to sqlite on mobile platform.

Describe the problem or limitation you are having in your project

I wanna use nuget package's System.IO api to visit pck or ipa file. It impossible.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Provide api to let c# user visit expose files in export pck or ipa.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

        using (var reader = new StreamReader(ProjectSettings.LocalizePath("Resources/Data/People.txt")))
        using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
        {
            csv.Read();
            csv.ReadHeader();
            string[] headerRow = csv.HeaderRecord;
            Console.WriteLine(headerRow);
        }

If this enhancement will not be used often, can it be worked around with a few lines of script?

nope

Is there a reason why this should be core and not an add-on in the asset library?

Give C# users a way to expose files from within a .pck to be loaded using nuget packages. Relate Issue

raulsntos commented 1 month ago

If you just need to be able to create a Stream from a Godot path (i.e. paths that start with res:// or user://) then you should be able to implement a custom class that derives from Stream and works as a wrapper over the FileAccess APIs.

There's a PR that I plan to salvage to provide Stream-based APIs for Godot file access: