Making your web applications platform independant

I was looking for some information the other day about line separators across Windows/MAC/Linux etc when I stumbled upon 3 great articles from Christian Cantrell.

Although the articles are quite old they were very informative for me so I thought I’d share them in case others didn’t know this already.

Making Your ColdFusion Applications More Platform Independent (Part I)
Basically about case sensitive filenames which is very important on *nix, but also included the following which I’ve never heard and to be honest would like to test:

Additionally, make sure you use all lowercase when naming your components. ColdFusion MX will automatically lower-case your component names, which you would never notice on Windows, however on Unix, it will become apparent very quickly when you start getting errors that your components do not exist.

Making Your ColdFusion Applications More Platform Independent (Part II)
Shows an automatic way (via Java) to get the current servers file path separator (either a ‘/’ or ‘\’), OS dependant.

Making Your ColdFusion Applications More Platform Independent (Part III)
I’ve been annoyed many times with the whole chr(10)chr(13) on Windows vs chr(10) on a Mac etc, another automated way to get the server OS ‘line separator’ via Java.

Here are the line and file separators as functions which I’ve also added to my Utils.cfc

	<cffunction name="getFileSeparator" access="public" output="false" returntype="string" hint="Returns the system file path separator">

		<cfscript>

			return createObject("java", "java.io.File").separator;

		</cfscript>

	</cffunction>

	<cffunction name="getLineSeparator" access="public" output="false" returntype="string" hint="Returns the system line separator">

		<cfscript>

			return createObject("java", "java.lang.System").getProperty("line.separator");

		</cfscript>

	</cffunction>
Post a Comment or Leave a Trackback

6 Comments

  1. November 2, 2007 at 12:46 pm | Permalink

    Very good stuff! I can remember ages ago I was struggling with this stuff trying to build a new site for Red Storm. I was on Windows – they hosted on Unix. And I was doing it all in Fusebox 1.0 :) Too bad it never saw the light of day :(

  2. November 3, 2007 at 9:48 am | Permalink

    nice one sharmo, nifty functions!

  3. November 3, 2007 at 9:52 am | Permalink

    re: utils.cfc, when you are returnType=void, the is redundant (unless you’ve heard otherwise and care to share? :p )

  4. November 3, 2007 at 9:52 am | Permalink

    it filtered out my cfreturn tag in the last post

  5. November 3, 2007 at 11:41 am | Permalink

    Yeah putting in <cfreturn> is redundant when you have a “returnType=void” but I like to have it for completeness.

    Obviously whenever the parser hits the “return” it will exit the function so there is no actual benefit to adding it in these scenarios, but when browsing code I find it easier to see the methods exit point.

  6. May 1, 2008 at 1:37 pm | Permalink

    thanked post

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*