Ask a Jedi: Moving to UNIX, but didn't plan for it. Now what?

Sandeep asks:

i have been doing my development on windows machine but now i decided to move to linux .. but when i was writing my code i did not think i would be moving to linux anytime so i was not very careful when i did my includes ... is there any tool that you know of can help me fix cf code... i know i can use dreamweaver replace in a particular folder but still it might be too time consuming.

I can’t think of a tool out there that will just ‘magic wand’ this away, but here are some things to consider: First, you probably want to lowercase all your file names except for your Application.cfc/cfm files. I assumed there was probably a way to do this at the command line, and there was, from Speaking Unix (http://www.ibm.com/developerworks/aix/library/au-speakingunix7.html):

rename 'y/A-Z/a-z/' *

I don’t have a UNIX system handy right now so your mileage may very. (Mac OSX doesn’t have rename as a command as is case insensitive for filenames.) You could easily do it in CFML with cfdirectory and cffile. The point is to get all your files (again, excepting the special Application.cfc/cfm file and onRequestEnd.cfm) into lowercase first.

Now for the code. You actually have two ‘areas’ of code to worry about. One is the simple html, so for example, covering cases like so:

<img src="Foo.jpg">

You could probably handle this with a URL Rewrite, but that’s only hiding the problem.

Your next area of concern is CFML. You have more to worry about than cfinclude. Anything that touches the file system would need to be updated, including fileExists, cffile, cfdirectory, etc. You could use the manual method for this - as you suggest with Dreamweaver, but it will be sluggish.

Lastly, you have the database side to worry about as well. Consider code that loads a preferred image. If you stored that image filename, then a Dreamweaver code search won’t help. For example, it isn’t immediately obvious that this can be a problem:

<body background="#session.mybackground#">

As a rule of thumb, I’ve always tried to use lowercase files everywhere in my code. It just makes it easier to read I think.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments