Sunday, October 7, 2007

ExpandPath()

I recently happened upon a cool CF function that returns the absolute path of a directory on your server after being passed a relative path: ExpandPath()
This function is especially helpful when something requires an absolute path-- which is usually the case for file management tags (cffile, cfdirectory, cfftp), system functions (fileExists(), directoryExists(), getFileFromPath(), GetProfileString()) and some others (cfexecute, cfdocument.)
For those of us working on shared servers, this tag is especially useful because: 1. Sometimes you don't know the absolute path and 2. Even if you did, there is no guarantee that it won't change someday. Speaking of things changing someday, this tag is extremely helpful when writing portable or compartmentalized code--which we should be doing anyways to save us from future headaches ("...damnit, I changed my webroot location and now I have to fix all my absolute references! Oh the horror...")

1 comments:

April O'Neil said...

So how's the blog thing going for you, eh?