fs.exists() will not delete unless you include a the file extension
ParlocameonTheDev opened this issue ยท 11 comments
Not sure if this is an issue, but fs.exists("startup") will not work and shows no errors if you named your file startup.lua, and while I haven't tested it, am pretty sure it applies vice versa. EDIT: Just realized it's quite possible this affects other parts of the FS api aswell.
The issue here seems to me to be that editing startup
doesn't actually create a working startup file. Perhaps add support for running startup.lua
in addition to one with no extension?
startup.lua is not startup, so it is correct, that fs.exists("startup") return false, if you only have startup.lua.
To expand on @Wilma456's point: when you type edit startup
, CraftOS will automatically add the .lua
extension, meaning you're editing startup.lua
instead. This can be seen by running ls
in the shell: you'll have startup.lua
instead of startup
.
If you want to disable this feature, run set edit.default_extension ""
in the shell.
@SquidDev I know, but this is a feature edit and not of the fs API. If you run fs.open("startup","w") it will still open startup and not startup.lua so tats now reason to change this.
This is pretty obviously working as intended in my view! Automatically adding a file extension is a feature of the edit program - not something that needs to be handled in the fs API.
@Cloudhunter Agreed, it shouldn't be handled by the fs API
@Wilma456 Okay if you use fs.open("startup", "w") and it opens startup.lua instead of startup. But what if the user actually wanted to edit startup instead of startup.lua? The FS API should remain the way it is.