coldfusion admin mappings and expandpath

Add comments

A very simple thing but we only just introduced this in our systems. To help with portability between servers which could be configured with different drive letters or possibly different directory structures, we have removed all the direct references to file paths and now refer to a CF mapping within the expandPath() function.

So while developing on our local machines we may have c:\output\stuff, on staging this becomes e:\systema\output\stuff.

So now these are cfadmin mappings to /output and we can set a variable as

<cfset outPath = expandPath("/output")/>

No change from dev to production and if we migrate to a server where the drive letter changes it can just be changed at the mapping level in one place.

You are probably already doing this but made me happy :-)

1 response to “coldfusion admin mappings and expandpath”

  1. Joanna ( coldfusion australian ) Says:
    thanks michael, simple but handy tip. If we don't have access to adding a CF mapping we usually do GetDirectoryFromPath(GetCurrentTemplatePath()) to walk down from the current template or if we need to go up we just a relative path like expandPath('../../').

    Cheers, Jo.

Leave a Reply





Powered by Mango Blog. Design and Icons by N.Design Studio