0

Is there a way to find out if the OS is case sensitive without much overhead (no write-read operation) and without having to know that a specific mixed-case file exists somewhere on the server?

The background: I want to write an autoloader that behaves differently for case-sensitive operating systems.

DudeOnRock
  • 3,685
  • 3
  • 27
  • 58
  • what about checking what the OS is directly –  May 24 '13 at 03:02
  • @Dagon: I was hoping I didn't have to open that can of worms: http://stackoverflow.com/questions/738823/possible-values-for-php-os – DudeOnRock May 24 '13 at 03:05
  • 1
    It may not be OS-specific. On OS X, it depends on the type of filesystem. HFS+ is case-insensitive (but I think you can mount it with a case-sensitive option), but UFS is case-sensitive – Barmar May 24 '13 at 03:30
  • Why not just assume case sensitive and build. What reservations do you have to make for a case insensitive system? – Orangepill May 24 '13 at 03:38

1 Answers1

1

With the restriction of not being able to write to the file system i.e.

write A.txt to a known location then try to read a.txt

I do not believe there is a way. Because even with OS sniffing (hacky at best and likely to give incorrect results) that is only referring to the OS... different filesystems on the os can behave differently (ie linux is case sensitive but the cifs share I have mounted is not)

I would say if knowlege of the case sensitivity of an os's filesystem it should be declared in code or config.

Or better build assuming case sensitivity but don't do anything that would break in a case insensitive environment, because anything that works on a case sensitive system will work on a case insensitive system (assuming you don't rely on the behavior of A.php and a.php being two different things which case sensitive or not is just dumb.)

Orangepill
  • 24,500
  • 3
  • 42
  • 63