This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ds84182's profile picture

CC: 1.6 | Unable to delete files prefixed by "."

Started by ds84182, 28 March 2014 - 07:21 PM
ds84182 #1
Posted 28 March 2014 - 08:21 PM
I was testing out some stuff in CC 1.6, and see what exactly I can pull off now that it's stable. So I made a program to do [redacted], and store it's configuration in a file prefixed with a ".", so it would become invisible by the user. The problem is, when I was updating that file, my code suffered a crash, thus clearing the file. So I attempted to regenerate the configuration by deleting the file. I tried rm .s_cfg, but I got an access denied. So I went into lua and attempted to fs.delete the file, but again: Access Denied. Is this a new feature in ComputerCraft? Because if it is, this isn't a bug :)/>
CometWolf #2
Posted 28 March 2014 - 08:25 PM
This is what happens if you fs.open a file without later closing it. This has always happened and will probably countinue to happen, just reboot your computer.
ds84182 #3
Posted 28 March 2014 - 08:37 PM
That's weird, because I made sure I closed file handles, but after restarting both the Computer and pocket computer, it would let me delete it.
EDIT: Maybe CC has some weird file handle bug.
Edited on 28 March 2014 - 07:37 PM
apemanzilla #4
Posted 28 March 2014 - 08:39 PM
Another option is to use local variables for file handles. When the program crashes, the pointer to the variable is removed, and the variable itself is garbage collected; automatically closing the file.
Edited on 28 March 2014 - 07:39 PM
ds84182 #5
Posted 28 March 2014 - 08:43 PM
I am using local variables for my file handles, I don't think CC closes file handles on garbage collection anyways
apemanzilla #6
Posted 28 March 2014 - 08:45 PM
I am using local variables for my file handles, I don't think CC closes file handles on garbage collection anyways
Hmm, well it should in plain Lua, might be a LuaJ bug or just not in this version of Lua. Or it may just be that in plain Lua you usually use io.open :P/>
Edited on 28 March 2014 - 07:45 PM
CometWolf #7
Posted 28 March 2014 - 08:45 PM
That's weird, because I made sure I closed file handles
And the part where you close the file is prior to the code where the program crashed?
ds84182 #8
Posted 28 March 2014 - 08:54 PM
That's weird, because I made sure I closed file handles
And the part where you close the file is prior to the code where the program crashed?
Yeaaaaaah, that was my problem, but it still looks like CC doesn't clean up after itself, which is still kinda a bug
EDIT: And this bug kinda affects Pocket Computers and disks, so you could play on a server and create a large file on someone elses pocket computer… and they wouldn't be able to delete it unless the server restarted, or they found the computer that had it open
Edited on 28 March 2014 - 07:57 PM
CometWolf #9
Posted 28 March 2014 - 09:02 PM
you could play on a server and create a large file on someone elses pocket computer… and they wouldn't be able to delete it unless the server restarted, or they found the computer that had it open
lol wat, i haven't used the pocket computer, but it's not linked to a regular computer is it? You can't delete a file from a computer without actually using the computer obviously…
Bomb Bloke #10
Posted 28 March 2014 - 11:52 PM
If I understand correctly, he's saying that if you put a pocket computer in a disk drive of a regular computer, then have the regular computer open a file on the pocket computer, simply removing the pocket computer from the disk drive will not clear the file handle - the pocket computer would have no way to close the handle itself.

I've not checked to see if this is the case.
dan200 #11
Posted 03 April 2014 - 02:29 PM
You can delete "." files fine, closing.