File.makeDirectory and External Storage Devices

fiji
imagej
macro

#1

I understand that, as a safety precaution, Fiji does limit the locations that can be written to. However, I am a bit perplexed as why this particular restriction would be in place. When using the IJ1 macro language, I can save to an external HDD just fine; so long as the entire path (except for the file) already exists. If I try to use File.makeDirectory to create a non-existing directory, it silently fails. Then, when I try to save the file, that produces and error message (as it should since the directory doesn’t exist).

Is this supposed to be the case, is it a bug, or is it a detail that was simply overlooked? If it is supposed to behave this way, why? Is there a way around it? If this is not intentional, is there an immediate work around other than either pre-making all the directories or running Fiji with root privileges? By the way, I haven’t actually tried running Fiji with root privileges so I don’t know for sure that would work; I am just guessing it would.


#2

Andrew,

I don’t think that what you report is due to ImageJ or Fiji. It appears to be an OS-issue and you don’t write which OS you use.

Regards

Herbie


#3

Hello Herbie, I am using Ubuntu 14.04 at the moment. There is no message or error of any kind that gets displayed to the user when this happens; neither from Fiji nor the OS. Since you seem pretty sure this is and OS issue, I assume you have tested this and haven’t had the same problem?


#4

Andrew,

to answer your question, on macOS I encounter no problems with

path="/Volumes/Data/newDir";
File.makeDirectory(path);

where “Data” is a partition on an external drive and “newDir” is created as desired.

Regards

Herbie


#5

I see. Thanks for the information. I think I figured out what the cause was. In my case, I was trying to make several levels at once. It appears that File.makeDirectory needs to make directory trees one level at a time.


#6

Hi @Andrew_Shum,

If you’re willing to use groovy / beanshell / or java then:

new File( path ).mkdirs()

will work even if path is a hierarchy of not-existing directories.

John


#7

Thanks for the info. However, this is just a short script for my own use, not some plugin. Plus, the only one of those I have ever coded in is Java; and that was years ago.