CreateWriter problem- permissions?
in
Integration and Hardware
•
1 month ago
Hi gang,
I've encountered a problem with createWriter and I'm sure that my workaround on Ubuntu is not the best way to solve it, especially as I now can't figure out how to imitate it on Windows (my application needs to work on both). It's probably something obvious I'm missing, but essentially when I run my sketch (which involves creating a file and then appending data to it using a PrintWriter at specified intervals) under Ubuntu, it is only capable of creating a file if I run processing with sudo. Otherwise it throws the error: "Couldn't create a writer for <directory>".
This is fine, but not ideal, since it means that all the files created are read-only and it's a hassle when I have to edit or delete them later.
What is the best way to make sure processing can write to an arbitrary directory in Ubuntu? (The directory in question is a simple Dropbox folder, e.g. "/home/el_matt/Dropbox/Data/Results/", with no special protection I'm aware of...)
Related to this, when I adapt this code to run on Windows, I point to the same Dropbox folder (with a different path, say "C:\\Users\\el_matt\\Dropbox\\Data\\Results\\") and get the same error, EVEN THOUGH processing still creates the appropriate sub-folders with no problems. It's only when it tries to open the new file that it fails.
So. What am I missing? I could post more of the source if you think it will help, but considering that it works under Ubuntu when run as super user, I think the problem is at a higher level.
EDIT: Having tested again on Ubuntu, the program does
not create the subdirectories when not run with sudo permissions- it just fails with the same error message. On Windows 7, however, it definitely creates the subdirectories and
then fails. Any ideas?
EDIT 2: Well I went through the code again and found a typo in one of my absolute paths which has fixed it for the Ubuntu version! Now to test it on Windows.
1