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

feat: added the create function to the fs module #1777

Closed

Conversation

hankertrix
Copy link
Contributor

It is mostly based on the create_do function.

Closes #1709.

It is mostly based on the create_do function.

Closes sxyazi#1709
@sxyazi
Copy link
Owner

sxyazi commented Oct 14, 2024

Sorry, I'm afraid I can't accept this PR because the current implementation is too specific to a single feature and lacks broader usability.

Creating files/directories is a bit complex and requires some design at the API level. I haven't had the time to dive into it yet, but I do have some rough ideas:

  • For directory creation, the default behavior should be non-recursive, with an option for recursive creation.
  • There shouldn't be a dedicated API for creating files. Instead, files should be opened, returning a handle that can be used for chained operations like writing, flushing, etc.
  • When opening a file, it should be possible to specify the mode (read/write, append, truncate, etc.). Rust's OpenOptions is a good reference: https://doc.rust-lang.org/std/fs/struct.OpenOptions.html.
  • The file handle should interoperate with other APIs, such as opening a process via the Command API and redirecting the process's stdout to the file handle — we can tackle this part later.

Would you like to give this a try in this PR? I can provide some guidance if needed. Or feel free to close this PR, and I'll try to implement it after the 0.4 release, once I get some time.

@hankertrix
Copy link
Contributor Author

Ah I see, no worries. I can try to tackle the first 3 points you mentioned, but it'll take me a lot more time, which I currently don't have much of until about 2 months later.

I'll convert this pull request to a draft.

@hankertrix hankertrix closed this Nov 2, 2024
@hankertrix hankertrix deleted the add-create-function-to-fs-module branch November 2, 2024 10:50
@hankertrix hankertrix restored the add-create-function-to-fs-module branch November 2, 2024 10:50
@hankertrix hankertrix deleted the add-create-function-to-fs-module branch November 2, 2024 10:52
@hankertrix
Copy link
Contributor Author

hankertrix commented Nov 2, 2024

Closing this pull request for now, I’ll create another pull request when I implement the API.

The reason is to not pollute the branch with merge commits.

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

Successfully merging this pull request may close these issues.

Expose file and directory creation to plugin developers as part of fs
2 participants