CFLib.org – Common Function Library Project

makeUriFromPath(path)

Last updated September 23, 2004

Version: 1 | Requires: ColdFusion 5 | Library: FileSysLib

 
Rated 0 time(s). Average Rating: 0

Description:
Accepts an aboluste path as input and returns a full URI as output. For example, "C:\Temp\Test.xml" returns "file:///C:/Temp/Test.xml".

Return Values:
Returns a URI.

Example:

view plain print about
<cfoutput>#makeUriFromPath(expandPath("test.xml"))#</cfoutput>

Parameters:

Name Description Required
path Path to translate. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Creates a URI from an absolute path.
 * 
 * @param path      Path to translate. (Required)
 * @return Returns a URI. 
 * @author Samuel Neff (sam@blinex.com) 
 * @version 1, September 23, 2004 
 */

function makeUriFromPath(path) {
   var uri = path;
     
   // make all backslashes into slashes
   uri = replace(uri, "\""/""all");
   if (left(uri,1) is "/"{
      uri = right(uri, len(uri) - 1);
    }
     
   uri = "file:///" & uri;
    
   return uri;
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Robby Lansaw Robby Lansaw added
getComponentProp...
3 day(s) ago

Dave Anderson Dave Anderson added
iniToStruct
25 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
25 day(s) ago

Richard Richard added
dice
27 day(s) ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson