New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadXML and loadString are case sensitive. #3235

Closed
HorizonShadow opened this Issue May 1, 2015 · 6 comments

Comments

Projects
None yet
5 participants
@HorizonShadow

HorizonShadow commented May 1, 2015

File names in both are case sensitive.

For example, a file called tEST.xml in the data folder will not be loaded with loadXML("test.xml"). Instead, and error is thrown.

Couldn't create a reader for test.xml
java.lang.NullPointerException
    at processing.data.XML$1.read(XML.java:193)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.arrangeCapacity(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipString(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at processing.data.XML.<init>(XML.java:190)
    at processing.core.PApplet.loadXML(PApplet.java:6356)
    at processing.core.PApplet.loadXML(PApplet.java:6346)
    at sketch_150501e.setup(sketch_150501e.java:19)
    at processing.core.PApplet.handleDraw(PApplet.java:2365)
    at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:245)
    at processing.core.PApplet.run(PApplet.java:2260)
    at java.lang.Thread.run(Unknown Source)

Went rooting through the source, and at least loadXML seems to be trying to check case. https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java#L6185

@federicobond

This comment has been minimized.

Show comment
Hide comment
@federicobond

federicobond May 1, 2015

Contributor

Not all file systems are case insensitive. For example, the most common file systems in Linux are not. It is perfectly understandable for Processing to enforce case sensitivity to guarantee the same behavior across platforms.

It would be better to throw a FileNotFoundException in this case though.

Contributor

federicobond commented May 1, 2015

Not all file systems are case insensitive. For example, the most common file systems in Linux are not. It is perfectly understandable for Processing to enforce case sensitivity to guarantee the same behavior across platforms.

It would be better to throw a FileNotFoundException in this case though.

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry May 1, 2015

Member

@HorizonShadow That's so that your sketch still runs when it's put on someone else's machine that's case sensitive. It was originally there for sketches posted online, so while less relevant now, it's good practice to keep the names straight.

If it didn't show an error saying "This file is named tEST.xml not test.xml. Rename the file or change your code." then that's a bug.

Member

benfry commented May 1, 2015

@HorizonShadow That's so that your sketch still runs when it's put on someone else's machine that's case sensitive. It was originally there for sketches posted online, so while less relevant now, it's good practice to keep the names straight.

If it didn't show an error saying "This file is named tEST.xml not test.xml. Rename the file or change your code." then that's a bug.

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry May 1, 2015

Member

Indeed it wasn't reporting the error correctly, so that's now fixed for 3.0a8.

Member

benfry commented May 1, 2015

Indeed it wasn't reporting the error correctly, so that's now fixed for 3.0a8.

@benfry benfry closed this May 1, 2015

@Akarshit

This comment has been minimized.

Show comment
Hide comment
@Akarshit

Akarshit May 1, 2015

Member

@benfry This issue still exists on Ubuntu. The problem is that file.exists() on https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java#L6176 will return false while searching for a file named "tEST.txt" if the name of the file is "test.txt" on Ubuntu's File system so we cannot diaplay a message like "This file is named tEST.txt not test.txt. Rename the file or change your code." as for that we would have to check all upper and lower case combination of the requested filename.

So instead of this message the FileNotFoundException can be thrown but that would make the behavior different across different platforms.
Any suggestion ?

Member

Akarshit commented May 1, 2015

@benfry This issue still exists on Ubuntu. The problem is that file.exists() on https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java#L6176 will return false while searching for a file named "tEST.txt" if the name of the file is "test.txt" on Ubuntu's File system so we cannot diaplay a message like "This file is named tEST.txt not test.txt. Rename the file or change your code." as for that we would have to check all upper and lower case combination of the requested filename.

So instead of this message the FileNotFoundException can be thrown but that would make the behavior different across different platforms.
Any suggestion ?

@glasscanvas

This comment has been minimized.

Show comment
Hide comment
@glasscanvas

glasscanvas May 1, 2015

Hi,

In my opinion it should be case sensitive. You have to type it correctly.

I work with several platforms (OSs).
Linux, Unix and Macintosh files are case sensitive. If I get the case wrong on these systems, I expect to get a file not found and then I fix the fileName case. MyFile.txt is a different file from myfile.txt.

Windows is not case sensitive. In Windows, either case would be treated as the same file and found. This is the behavior I expect for windows but I have always wished it was case sensitive. It's sloppy IMHO because you can't be sure you typed the file case correctly.

If you follow Unix/Linux/conventions then it works in all platforms because you have to get the case correct.

Carlos

Sent from my iPad

On May 1, 2015, at 4:11 PM, Akarshit notifications@github.com wrote:

@benfry This issue still exists on Ubuntu. The problem is that file.exists() on https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java#L6176 will return false while searching for a file named "tEST.txt" if the name of the file is "test.txt" on Ubuntu's File system so we cannot diaplay a message like "This file is named tEST.txt not test.txt. Rename the file or change your code." as for that we would have to check all upper and lower case combination of the requested filename.

So instead of this message the FileNotFoundException can be thrown but that would make the behavior different across different platforms.
Any suggestion ?


Reply to this email directly or view it on GitHub.

glasscanvas commented May 1, 2015

Hi,

In my opinion it should be case sensitive. You have to type it correctly.

I work with several platforms (OSs).
Linux, Unix and Macintosh files are case sensitive. If I get the case wrong on these systems, I expect to get a file not found and then I fix the fileName case. MyFile.txt is a different file from myfile.txt.

Windows is not case sensitive. In Windows, either case would be treated as the same file and found. This is the behavior I expect for windows but I have always wished it was case sensitive. It's sloppy IMHO because you can't be sure you typed the file case correctly.

If you follow Unix/Linux/conventions then it works in all platforms because you have to get the case correct.

Carlos

Sent from my iPad

On May 1, 2015, at 4:11 PM, Akarshit notifications@github.com wrote:

@benfry This issue still exists on Ubuntu. The problem is that file.exists() on https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java#L6176 will return false while searching for a file named "tEST.txt" if the name of the file is "test.txt" on Ubuntu's File system so we cannot diaplay a message like "This file is named tEST.txt not test.txt. Rename the file or change your code." as for that we would have to check all upper and lower case combination of the requested filename.

So instead of this message the FileNotFoundException can be thrown but that would make the behavior different across different platforms.
Any suggestion ?


Reply to this email directly or view it on GitHub.

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry May 1, 2015

Member

@Akarshit On Linux, folks should be familiar with the fact that they have a case sensitive file system. We can't possibly chase after that.

We cannot simply throw FileNotFoundException because it would be the first piece for Processing API that uses any exception that must be caught. It would also change the method signature of the code.

Folks, we're spending too much time on this issue. The main problem here is fixed. There are 211 more issues for us to fix, please focus on those.

Member

benfry commented May 1, 2015

@Akarshit On Linux, folks should be familiar with the fact that they have a case sensitive file system. We can't possibly chase after that.

We cannot simply throw FileNotFoundException because it would be the first piece for Processing API that uses any exception that must be caught. It would also change the method signature of the code.

Folks, we're spending too much time on this issue. The main problem here is fixed. There are 211 more issues for us to fix, please focus on those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment