Portable Yet Operating System Specific

Most ColdFusion code that you write should be fully portable (assuming you pay attention to things like case-sensitivity in file names and paths). But what if you need to write operating system specific code (perhaps to use COM, or to execute different statements on Windows and Linux)? Is it possible to write one application that will run everywhere? Actually, yes, it is. The trick is to inspect the SERVER.OS.Name variable which will let you know the name of the operating system in use. You can check this variable (in a or a perhaps) so that any non-portable (or operating system specific) code is only executed where appropriate. (You can also write code for specific OS versions, just inspect SERVER.OS.Version). (Applies to: ColdFusion 4 (or later))

Leave a Reply