CFLib.org – Common Function Library Project

makeUriFromPath(path)

Last updated September 23, 2004

author

Samuel Neff

Version: 1 | Requires: CF5 | Library: FileSysLib

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:

<cfoutput>#makeUriFromPath(expandPath("test.xml"))#</cfoutput>

Parameters:

Name Description Required
path Path to translate. Yes

Full UDF Source:

/**
 * 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;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson