We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So I'm a bit of a newbie in linux, I'm using crunchbang (debian) and I was hoping to test out some of the sketches I made in window...
One of my sektches uses the dataPath() function to find all the jpeg images from a folder.
The thing is, I don't know how to find the data path... I know in windows you'd type the drive letter then whatever folders resulting in something like
C:/Users/Margsy/processing/mysketch
However, things seem different with linux...
I tried this command line in the terminal to find the path to my sketch
readlink -f mysketch.pde
which gave something like
/home/margsy/processing/mysketch/mysketch.pde
So I put dataPath("/home/margsy/processing/mysketch")
in my sketch but that really isn't working.
There's not any error message until the sketch tries doing something with the images- at which time it says NullPointerException
it didn't find but it's the same problem that happens when I have the data path wrong in Windows, so I'm assuming that's the problem.
Is it because I need to indicate the drive? If so, how do I find it's id? Any hints?
Answers
did you try dataPath("") without further content between "" ?
could you post your windows sketch for us?
I think you didn't understand what is the point of dataPath(). Giving it a full path has no sense. The point is to prepend the path of the data folder of the current sketch to the given argument:
dataPath("file.png") should return something like "/path/to/sketchbook/SampleSketch/data/file.png"
Seems like you're more veteran than me who uses simple-minded Ubuntu-based distros! =))
Both dataPath() & dataFile() are undocumented functions which point to sketchPath's "/data" subfolder.
They're not supposed to get some arbitrary folder from the OS's file system! [-X
For example:
String dir = dataPath("") + '/';
yieldssketchPath + "/data/"
.If you'd rather prefer some arbitrary folder, you should instantiate a File passing its full path to it: :-B
https://docs.oracle.com/javase/8/docs/api/java/io/File.html#File-java.lang.String-
Save and run this sketch as say sketch:-
PrintWriter pw = createWriter(dataPath("test.txt")); pw.print("done it!"); pw.close();
Use control 'k' to open sketch folder and there you will have it, a data folder containing 'test.txt'
Oh I'm not really a veteran, I'm just dumb and decided to start learning Linux with CrunchBang- like 3 weeks ago :') joke definitely on me.
Um this is the context of the code- working from my thumbdrive (I know bad idea but just convenience atm) on Windows...
This is initial stuff, not in any void...
Then this is in
void draw()
So what happens is that it selects a random picture from the list and then goes on editing pixels and stuff.
I had some help writing that so I honestly don't exactly know what everything does in the inital part :$ I wrote a note at the begining of my sketch saying
But the link is obselete :'( I was so proud of having documented things properly doe...
Ummmm but lemme get back to you in a moment because I just realised I wrote .jpeg and all my files are saved as .jpg..........
If crunchbang gets too hairy for you, Mint is a very popular distro for a reason. If you follow my previous answer you will find you should only put bare file name in dataPath unless you have sub-directories in the data folder of your sketch (or otherwise don't use it if you want to write out full path).
Soooooooo I don't know why my sketch works the way it does, where you indicate the full directory in
dataPath("")
but switching.jpeg
to.jpg
worked :')Still thanks for the help! Now I understand what dataPath is supposed to be for and stuff.
So um resolved! but not really cause I was, in fact, asking the wrong question :p
Placing resources inside "/data/" subfolder makes everything tidier and more compatible among OSes!
Also when the sketch is exported, those resources go along! O:-)
And as mentioned, Mint 17.1 Rebecca was officially released just 2 days ago:
But if you still wanna get your hands dirty w/ an expert distro, but w/ æsthetics, Manjaro was just released too:
Take a general look at Linux distros from this marvelous traditional site: