theblindprophet
theblindprophet

Reputation: 7937

Directory does not exist, but clearly does

I am working on an old Coldfusion 11 application for my company and this error is stumping me. There is the following check inside a .cfm:

<cffunction name="init">
<cfargument name="searchDir" required="yes" default="#replace(GetDirectoryFromPath(GetCurrentTemplatePath()),'/services','')#xml/">
    <cfargument name="checkoutMode" required="no" default="protect">

    <!--- library variables initialization --->
    <cfset Variables.libBaseDir = arguments.searchDir>
    <cfset Variables.libCheckoutMode = arguments.checkoutMode>


    <cfif NOT DirectoryExists(Variables.libBaseDir)>
        <cfthrow message="The base document directory '#Variables.libBaseDir#' does not exist!">
    </cfif>
    ....
</cffunction>

Variable.libBaseDir is printed in the error message as:

/opt/app/coldfusion/coldfusion11/cfusion/wwwroot/<some-app>/xml/

But my directory is clearly as follows (used pwd):

/opt/app/coldfusion/coldfusion11/cfusion/wwwroot/<some-app>/xml

This works on a Windows server, but not Linux, my sole purpose of doing this.

Any ideas why this would throw the error, thanks.

Upvotes: 1

Views: 1475

Answers (1)

theblindprophet
theblindprophet

Reputation: 7937

Here is what I ended up using because a "/" continued to be appended to the end of the path no matter what I did.

<cfargument name="searchDir" required="yes" default="#replace(GetDirectoryFromPath(GetCurrentTemplatePath()),'services/','xml')#">

<cfset Variables.libBaseDir = Left(arguments.searchDir, Len(arguments.searchDir)-1)>

So I removed the "/" at the end of the path and that fixed it.

Thanks for the all previous suggestions.

Upvotes: 0

Related Questions