Working out which OS ColdFusion is running on

We have a mixed development enviroment at the office, some folks on Linux (ubuntu) some on Macs and some on PCs so it is crittical that we make sure that we code properly for all platforms and the one thing that always catches us out is the path seperator.

In the hunt for the perfect solution we knew we had to go to Java to ask it which platform it is running on. A quick search in google finds Luis Majano’s post on the subject and this great little code snippet.

//Get a reference to the System class
objSystem = createObject("java", "java.lang.System");
//Get the property desired, in this case, the file separator
fileSeparator = objSystem.getProperty("file.separator");

A nice little thing to add to our application.cfc and cache for later

Advertisements
This entry was posted in General.