DudeOnRock
DudeOnRock

Reputation: 3831

Low overhead methodology to determine case sensitivity of OS

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.

Upvotes: 0

Views: 59

Answers (1)

Orangepill
Orangepill

Reputation: 24655

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.)

Upvotes: 1

Related Questions