-
Notifications
You must be signed in to change notification settings - Fork 192
system: delete_file
#966
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
system: delete_file
#966
Conversation
Hi @perazz thanks for this PR!
Regarding the naming, I think it will depend indeed on the functionality. If deleting folders is also included then it could be delete
otherwise delete_file
is better to remain explicit.
Another possibility would be to leave this procedure for deleting only single files and then add another procedure for deleting a whole folder tree
I think that it makes sense to leave it in the system
module as it is an OS related feature.
I agree with your opinion: all OSes have a similar differentiation between 3 options basically:
- delete files only (maybe with globbing)
- delete directories (empty only)
- delete entire directory trees (recursive)
So I think it makes sense to have a delete_file
, and then delete_dir
or delete_directory
later. Note that we have is_directory
, so maybe delete_directory
would be more consistent with the naming.
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.
Thank you @perazz . LGTM. I only have a minor question regarding its behaviour. I wonder if it should raise a warning, instead of an error, if the file does not exist.
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.
LGTM @perazz Thanks for this nice addition!
Uh oh!
There was an error while loading. Please reload this page.
This PR is spun off #904 for clarity.
The
delete_file
subroutine removes a file from the filesystem.The function ensures the file exists and is not a directory before attempting deletion.
If deletion fails due to permissions, being a directory, or other issues, an error is raised.
Some questions to discuss:
delete
,delete_file
, or another name?stdlib_system
orstdlib_io
, or elsewhere?cc: @jvdp1 @jalvesz