Bug 716 : loadStrings(".") should not list directory contents
Last modified: 2008-06-14 13:19




Status:
RESOLVED
Resolution:
FIXED -
Priority:
P2
Severity:
normal

 

Reporter:
l33tminion
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2008-01-26 15:01
(With Processing 0135 Beta running under Windows XP)

I wanted to get all a list of filenames of the files in my sketch's data
directory, so I tried the following:
String[] filenames = loadStrings(".");

This didn't produce an exception, and it did produce a list of filenames.
However, it didn't list the files in the data directory, instead listing
all the Temporary*.class files for the sketch I was working with.

Incidentally, trying to load a directory within the data directory in this
manner simply fails:
String[] filenames = loadStrings("images"); // where images is in data dir
of sketch
println(filenames); // prints null

The following code works, but points to the root directory of Processing,
not the data directory of the sketch:
import java.io.File;
File foo = new File('.');
String[] filenames = foo.list();

Anyways, the strange behavior of loadStrings(".") should be fixed (replaced
with either sensible behavior or proper error handling). Furthermore,
there should be an easy way within Processing to list the contents of the
data directory (and subdirectories of that directory), whether or not
loadStrings is the right method for that task.
Additional Comment #1 From fry 2008-01-28 17:28
that's odd, i haven't a clue offhand why it would be listing directory
contents. that's absolutely not the correct behavior.

see the discourse board for information about listing files in the data
directory and elsewhere. you need to use File.list(). see also the
troubleshooting page for more about the data directory and how it works
with jar files (which should explain why we won't be adding a method to
list the data folder).
Additional Comment #2 From fry 2008-06-14 13:19
fixed for 0142.