Friday 21 September 2012

expandPath() weirdness

G'day
I had an odd one today.

I was getting some weirdness with this code:

dir            = expandPath(".");
baseDir     = expandPath("/");
relativeDir    = replace(replace(dir, baseDir, ""), "\", "/", "ALL");
cfcPath = replace(relativeDir, "/", ".", "ALL");



This is part of a MXUnit test runner file I have, which needs to work out the relative path and the dotted path to the CFCs within the directory.

It was failing on one of my CF instances because the replace() bits in the relativeDir line were having case-sensitivity issues.  It was fixed by making those replaceNoCase(), but this was the weird thing.  Check this code out:

<cfoutput>
#expandPath(".")#<br />    <!--- for me outputs D:\websites\www.scribble.local\junk --->
#expandPath("/")#<br />    <!--- for me outputs d:\websites\www.scribble.local\ Note the difference in capitalisation of the drive letter --->
</cfoutput>

Note the difference in the casing of the drive letter: that's what was causing the replace() call to fail.

But what's going on here?  Why is one call to expandPath() returning the path one way, and another expandPath() call which is referring to the same base directory structure returning it a different way?

This was on CF9.0.1, btw, running on Windows 7  and whatever version of IIS comes with Windows 7 (IIS8?).  I sound vague because it's my work PC and I am not an administrator of it, and cannot get into stuff like IIS.  This hamstrung my investigations a bit.  I put a quick Twitter message out there, and @animexcom, @neokoenig, @richardherbert, @cfuser and @busches all came back with various findings (as I said on Twitter: thanks guys, it was helpful to get your feedback, and I appreciate your efforts), with Scott (@busches) being the only one who saw the same thing I did.  Scott was on CF 9 & IIS6.

I've just got home from work and set up an IIS (7) website on my Vista machine, and I could not replicate it here.  I tried using a mix of casing of the drive letters in various CF and IIS paths that might contribute to path resolution, but the paths were always coming out with a capital C for C: drive.


I could not replicate this on CF9.0.2 on the JWS web server, not CF10 with the Tomcat web server.  Nor on Railo (4).  I did not expect to though.

It's no major problem and the immediate issue was easily fixed, but I do like understanding these idiosyncrasies.

Anyone have any idea what's going on, or any suggested investigatory avenues?

I'll talk to one of the admins at work when I get back in on Tuesday and see if they can give me temporary IIS Admin access so I can poke around.  I need to time it before work or lunchtime etc as it's not work-related though, and they've got better things to do that horse around on my machine (or let me horse around on my machine!).

If I do find out what the story is, I will be sure to report back.

Oh, hey, here's an idea (albeit it a stupid one), as the guys at my work know... if I put these sort of questions out there and someone comes up with the answer, I buy a pint for them.  This is easy at work because we all work in the same room and the pub's across the road, but I'll buy a pint (etc) for the first person who solves this or gives me a good pointer in the right direction.  Obviously it might take a while to be in a position to buy you said pint, but still: the offer's there.

Cheers.

--
Adam