I'd say that any application that allows file paths to come from the
URL is wrong, no matter the code.  Second, any application that allows
mixed relative and absolute paths for the same file is asking for
trouble.  And third, make sure you check for a leading "/" as well, or
you code will puke on *nix.

Now as for the coding style, the former is definitely better, though
the whole block should be in a CFTRY..CFCATCH.  In the second example,
you need a CFTRY around the second CFFILE, and having multiple nested
CFTRY..CFCATCH blocks gets too nasty to quick.  Chances are good that
if that scenario arises, you'd be better off doing some abstraction
with either includes, UDFs, or a CFC.  But again, I think it's
unlikely you would ever be in this scenario with a well designed
application.

Also, don't use CONTAINS as your operator, use mid(url.dir, 2, 1) and
see if it's a colon.

cheers,
barneyb

On Thu, 27 Jan 2005 23:43:25 -0400, Johnny Le <[EMAIL PROTECTED]> wrote:
> Which method of programming do you consider is better?
> 
> This one:
> <cfif url.dir contains "E:">
>    <cffile action="write" file="#url.dir#/#url.inputfile#" output="">
> <cfelse>
>   <cffile action="write" file="#ExpandPath(url.dir)#/#url.inputfile#" 
> output="">
> </cfif>
> 
> or this one:
> 
> <cftry>
>    <cffile action="write" file="#url.dir#/#url.inputfile#" output="">
>    <cfcatch>
>      <cffile action="write" file="#ExpandPath(url.dir)#/#url.inputfile#" 
> output="">
>    </cfcatch>
> </cftry>
> 
> I know that the first one is most people use, but the second one is more 
> interesting.  It seems to use the power of CF more. So let me know what you 
> think.
> 
> Johnny
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192061
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to