ID:435181
 
Applies to:Dream Maker
Status: Open

Issue hasn't been assigned a status value.
It would be great if there was a way to get basic file information (besides size which we can get already).

Mainly I am just interested in finding a file's path and its full name+extension.

What I am trying to accomplish at run-time is manually open a file in one folder and then automatically open (or at least find) another file within the same folder without having to manually locate it or enter the path.

If there was a proc such as "getPath(file)" I would be able to automate this. It could even return the whole path including the file name (eg "C:\file\docs\info.txt") which would eliminate the need for a second proc to get just the filename.

You can use shell() to run a command, write the output to a file, then read in that file:

shell("dir > dir.txt")
var/output = file2text(file("dir.txt"))
alert(output)

It's certainly not ideal but it may work for now.
I tried your suggestion but it doesn't seem to write the dir.txt file anywhere. Or even output anything.

Does it take the last path used or would it go by the default path for the program?

Either way, I couldn't seem to get it to work.

EDIT:
It seems from the reference that I would already need to know the path to do that:
mob/verb/dir(Path as text)
shell("dir [Path] > dir.out")
usr << file2text("dir.out")
You could try playing around with flist(). I think it only gives you the filename+extension though, not the full path. It will list files and folders so you could potentially be able to parse the file list and move into different folders to find what you're looking for.

mob/verb/files()
//./ is the current directory the game is in
var/list/F = flist("./")
for(var/f in F)
src << f