FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Bugs
   Software Bugs
(Moderator: fry)
   case sensitivity on file names (Windows)
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: case sensitivity on file names (Windows)  (Read 3607 times)
metaphorz


case sensitivity on file names (Windows)
« on: Sep 30th, 2004, 3:47am »

We just had a class of about 50 use Processing
on a project, and the TA spent some time with
students on one particular issue, which I thought
should be posted. I am including the key part of
his post to the class here for reference:
 
......
 
For those of you who have the applet not running problem even though  
it works within processing and no problem exporting.
 
The problem that I have found out was that you have mis-named one or  
more of your resource file ie. image, sound, etc. For instance, if  
you are using an image file "myImage.JPG" and within your code, you  
specified to load "myImage.jpg" (Note the different cases of  
extension), processing will not complain when you try to run it  
simply because it uses Window file access system which is case-
insensitive to access the image file. However, when you try to  
export the program, processing uses the jar command provided by the  
Java JDK to pack your resources and Voila! it could not find  
the "myImage.jpg" file since it is case-sensitive and therefore the  
file does not exist in the .jar archive. The bad thing was that the  
export command does not complain about this incident and thus make  
it seems like everything is just fine. Then, when you try to run  
your applet, it couldn't find the image in the jar archive, and  
there you have a frozen program. One other thing that I have noticed  
is that the applet will give you an error message for not being able  
to find a sound file (ie .wav file) whereas for the image file  
(ie .jpg file), it just freezes itself without saying a word. This  
indeed is particularly hard to debug.
 
So the rule of thumb is to always stick with case-sensitive. Make  
sure you can see all of your file extension (uncheck the "Hide  
extension for known file types" in Window Explorer Tools>Folder  
Option>View) and use the whole file name exactly as it appears.
 
 
fry


WWW
Re: case sensitivity on file names (Windows)
« Reply #1 on: Sep 30th, 2004, 4:49am »

ouch, this is a tough one.. windows doesn't even think that two differently named files are different, so it's gonna be difficult to check.  
 
basically, we'd have to scan the code for loadImage calls, then have p5 list the contents of the 'data' folder at the time of compile (or export) and make sure that the two match. however, this won't work for anything that's in a variable or dynamically made, ie:
loadImage("blah" + index + ".jpg");
 
but i can understand how that's a tough one to debug.. i wonder if we can think of a clever way to test/fix.
 
cello

marcello3d WWW
Re: case sensitivity on file names (Windows)
« Reply #2 on: Sep 30th, 2004, 5:45am »

Well, you could force all files lowercase, then make the load commands convert input to lowercase.
 
But I'm not sure how keen I am on something like that, personally.
 
Maybe there should be a processing debug mode or something that runs when in the IDE that does checks like that at runtime (suggests alternative case/spelling matching for file load errors?)...
 
Or maybe it's possible to somehow force a file case check on windows, so it always gets an error... the only way I can think of at the moment is to get a directory listing (which should have correct cases), or maybe when you create a File object, getName() returns the actual name?
 
Ok, I did a quick test...
 
Code:

  File f = new File("bezier.java");
   
  try {
   System.out.println("f.getName() ="+f.getName());
   System.out.println("f.getAbsolutePath() ="+f.getAbsolutePath());
   System.out.println("f.getCanonicalPath() ="+f.getCanonicalPath());
   System.out.println("f.getCanonicalFile().getName() ="+f.getCanonicalFile().getName());
  } catch (Exception ex) {
   ex.printStackTrace();
  }

Outputs:
Code:

f.getName() =bezier.java
f.getAbsolutePath() =C:\marcello\java\bezier.java
f.getCanonicalPath() =C:\marcello\java\Bezier.java
f.getCanonicalFile().getName() =Bezier.java

 
Marcello
« Last Edit: Sep 30th, 2004, 5:53am by cello »  
fry


WWW
Re: case sensitivity on file names (Windows)
« Reply #3 on: Oct 1st, 2004, 12:05am »

is the original file named Bezier.java in your example? if so, that's nicer than having to do File.list() and comparing things so maybe that's the beginning of a possibility.
 
cello

marcello3d WWW
Re: case sensitivity on file names (Windows)
« Reply #4 on: Oct 1st, 2004, 1:29am »

Yes, the original file is Bezier.java.
 
I guess it was probably a bad example to choose something that only starts with capital letter.
 
But just to make sure, I renamed it to Bezier.JAVA,
and it gives me:
f.getName() =bezier.java
f.getAbsolutePath() =C:\marcello\java\bezier.java
f.getCanonicalPath() =C:\marcello\java\Bezier.JAVA
f.getCanonicalFile().getName() =Bezier.JAVA
 
So basically one could check for case changing with...
Code:

File f = new File(whatever);
boolean caseChanged = false;
try {
  caseChanged = !f.getName().equals(g.getCanonicalFile().getName());
} catch (IOException ex) {  
  // if file doesn't exist  
}

 
This might also complain if the file is a symbolic link or something, but I'm on windows so I cannot check that.  (Plus symbolic links shouldn't be used with processing in the first place...)
 
Marcello
 
fry


WWW
Re: case sensitivity on file names (Windows)
« Reply #5 on: Oct 1st, 2004, 4:58am »

k, lemme see if i can try and track that somehow.. i have some ideas about how we might be able to make it a warning when running inside the p5 environment at least.
 
fry


WWW
Re: case sensitivity on file names (Windows)
« Reply #6 on: Apr 14th, 2005, 5:30am »

now implemented in (un-released) revision 83, and will be available in beta.
 
Pages: 1 

« Previous topic | Next topic »