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

[solved]saving an information file to parent directory?

Started by CreeperGoBoom, 06 May 2014 - 03:06 AM
CreeperGoBoom #1
Posted 06 May 2014 - 05:06 AM
ok, i am thinking of writing a few programs which will act as server pcs allowing for easy internetwork communication between the computers added to said network, would even allow me to install a particular program just by choosing a particular network name, only thing is ive hit a hurdle

this is on a multiplayer server, a close friend of mines

i created a test,txt file, then attempted to get the parent directory of the file i just created, attempting to use the fs.getDir("test.txt") (this is the exact file name

instead i got attempt to call nil, the wiki page isnt much help on this, how would i return the directory of path when path is unknown??

Function fs.getDir
Returns the parent directory of path. This is the directory a file/folder is in.

if anyone has any ideas that would be appreciated, seems im trying to use the wrong method

also ive only just started reading Programming in Lua, i'm reasonably new to lua, but i can learn quick off code examples :)/>

edit: i want to know how to get the parent directory above the id folder of the computer (eg: saves/computer/ not saves/computer/<id>)
Edited on 06 May 2014 - 03:44 AM
CometWolf #2
Posted 06 May 2014 - 05:23 AM
fs.getDir was added in 1.6, and in the case of a file in the root folder, it would probably just return "/". It simply removes the last file name from the given path. There is no way to acess anything above the root folder from in-game.
CreeperGoBoom #3
Posted 06 May 2014 - 05:44 AM
ok thanks :)/> looks like i was trying to do the whole server thing wrong