mojo
mojo copied to clipboard
[Feature Request] Basic Filesystem Module
Review Mojo's priorities
- [X] I have read the roadmap and priorities and I believe this request falls within the priorities.
What is your request?
Right now there are several cases where having the filesystem would be useful.
This is particularly the case for any kind of parsing (and people in the community are playing with formats like Arrow or CSV right now).
I don't think there is a need for robust I/O right now, but having the following would be nice:
- Path + PathRef (similar to String)
- Directory
- does not actually need to expose the pointer, just need a way to get cwd and children
- File
- preferably with a `read_to_string` and `read_to_dyanmic_vector[UI8]`
Eventually there should be async versions of all of these operations, but that's more a long term goal.
What is your motivation for this change?
Right now any notebooks that plays around with parsing binary data or working with text files requires pasting the data directly into a cell and storing it in a variable.
Uploading and reading a file directly can often be preferable (especially in the binary case).
Any other details?
No response
Most likely depends on a trait/protocol system, same with any other std libraries. There's also the option that std libraries are not part of the mojo system, rather included via open source.
I think we can start a basic IO/fs module without traits. It's mostly non-parametric code. fyi @abduld
Oh interesting, I assume there would be (default) traits for Read, Write, Open, and sub-traits like how to read buffers, bytes and so on....
@ksandvik those are all things that are important long term, but the major ask here is just a method (something like):
fn read_path_to_string(path: StringRef) -> String
Which should simplify some experiments in the playground.
We need to order this correctly. The first step before this is to enhance the String type to support UTF encoding first. So, we want to tackle that before starting work on file system
Hey, I have an initial implementation of kind of "libc" in mojo. Still working on it, will see if I can upload it over the weekend. It basically allow you to use sockets, and read files, etc. I need to finish the FileSystem struct implementation and will upload to my github.
Feature added in 0.4.0