Login  Register

Extra "/" addet in FileInfo.directory when using drag and drop?

Posted by GeraldT on Jun 10, 2010; 7:21pm
URL: http://imagej.273.s1.nabble.com/Extra-addet-in-FileInfo-directory-when-using-drag-and-drop-tp3687943.html

Hello everybody,

I have tried to google the problem, but did not fine an answer. I am using the FileInfo class i ImageJ
to get the directory and the file name of the graphic file my plugin is working on. If I drag files (single files,
or a group of selected files in a directonary everything works ok (output from sample plugin):
Directory: C:\Program Files\ImageJ\plugins\Geralds\test\
test.tif

If I instead choose to drag an entire catalog (subcatalog test) with all the pictures inside the same sample plugin shows this output:
Directory: C:\Program Files\ImageJ\plugins\Geralds\test/\
test.tif

It is not dificoult to remove this '/' but I am afraid this may couse problems on other OS than Windows (I use XP).

Any idea why FileInfo behaves like that?

Kind regards
Gerald

Sample plugin:

import java.awt.*;
import java.io.*;
import ij.plugin.frame.*;
import ij.*;
import ij.process.*;
import ij.gui.*;
import ij.ImagePlus;
import ij.io .*;

public class FileInfoTest extends PlugInFrame {

        ImagePlus imp;
        ImageProcessor imPro;
        Frame instance;

        String resultFileName = "Testfile.txt";
                       
        public FileInfoTest() {
                super("FileInfoTest");
                if (instance!=null) {
                        instance.toFront();
                        return;
                }
               
                instance = this;
                imp = WindowManager.getCurrentImage();
                if (imp==null) {
                        IJ.beep();
                        IJ.noImage();
                        return;
                }
               
                imPro = imp.getProcessor();
               
                FileInfo fi = imp.getOriginalFileInfo();
                IJ.log("Directory: " + fi.directory);
                IJ.log("File name: " + fi.fileName);
               
               
        }

}