Path functions

Path functions get and manipulate the paths to various files and folders on a user’s hard disk. These functions determine the path to the root of the site in which the current document resides, convert relative paths to absolute URLs, and more.

dreamweaver.absoluteURLToDocRelative()

Availability

Dreamweaver 2.

Description

Given an absolute URL and the path to a document, this function converts the absolute URL to a document-relative path.

Arguments

docPathURL, siteRootURL, absoluteURL

  • The docPathURL argument is the path to a document on the computer of the user (for example, the current document), expressed as a file://URL.

  • The siteRootURL argument is the path to the site root, expressed as a file://URL.

  • The absoluteURL argument is the file://URL to convert to a document-relative path.

Returns

A string representing the path to the document at absoluteURL, expressed relative to the document at docPathURL.

Example

In the following example, if the values of docPathURL and siteRootURL are file://C:/sites/cherrystreet/archives/october.shtml and file://C:/sites/cherrystreet/ respectively, then the return value is "../includes/header.html". Use this value to reference /includes/header.html from /archives/october.shtml.

var docPathURL = dw.getDocumentDOM().URL; 
var siteRootURL = dw.getSiteRoot(); 
var absoluteURL= dw.relativeToAbsoluteURL(docPathURL, siteRootURL, "/includes/header.html"); 
var docRelPath = dw.absoluteURLToDocRelative(docPathURL, siteRootURL, absoluteURL);

dreamweaver.getConfigurationPath()

Availability

Dreamweaver 2.

Description

Gets the path to the Dreamweaver Configuration folder, which is expressed as a file:// URL.

For information on how Dreamweaver accesses Configuration folders on a multiuser platform, see “C-Level Extensibility” in Extending Dreamweaver Help.

Arguments

None.

Returns

The path to the application configurations.

Example

The following function is useful when referencing other extension files, which are stored in the Configuration folder in the Dreamweaver application folder:

 var sortCmd = dreamweaver.getConfigurationPath() + ¬ 
"/Commands/Sort Table.htm" 
var sortDOM = dreamweaver.getDocumentDOM(sortCmd);

dreamweaver.getDocumentPath()

Availability

Dreamweaver 1.2.

Description

Gets the path of the specified document, which is expressed as a file:// URL. This function is equivalent to calling dreamweaver.getDocumentDOM() and reading the URL property of the return value.

Arguments

sourceDoc

  • The value of the sourceDoc argument must be "document", "parent", "parent.frames[number]", or "parent.frames['frameName']". The "document" value specifies the document that has the focus and contains the current selection. The "parent" value specifies the parent frameset (if the currently selected document is in a frame), and the "parent.frames[number]" and "parent.frames['frameName']" values specify a document that is in a particular frame within the frameset that contains the current document.

Returns

Either a string that contains the URL of the specified document if the file was saved or an empty string if the file was not saved.

dreamweaver.getSiteRoot()

Availability

Dreamweaver 1.2.

Description

Gets the local root folder (as specified in the Site Definition dialog box) for the site that is associated with the currently selected document, which is expressed as a file:// URL.

Arguments

None.

Returns

Either a string that contains the URL of the local root folder of the site where the file is saved or an empty string if the file is not associated with a site.

dreamweaver.getTempFolderPath()

Availability

Dreamweaver MX.

Description

Gets the full path to a temporary folder where you can store temporary or transient files. This function looks for a Temp folder inside the Dreamweaver Configuration folder. If the system supports multiple users, it looks in the user’s Configuration folder. If a Temp folder does not exist, the function creates it. Shared files that are not transient should be stored in the Configuration/Shared folder.

Arguments

None.

Returns

The full path to the folder, which is expressed as a file:// URL.

Example

The following line of code returns the full path for the specified file. The dw.getTempFolderPath() function does not return a slash (/) at the end of the path, as do other Dreamweaver functions (such as dreamweaver.getSiteRoot()):

 var myTempfile = dw.getTempFolderPath() + "/myTempFile.txt";

dreamweaver.relativeToAbsoluteURL()

Availability

Dreamweaver 2.

Description

Given a relative URL and a point of reference (either the path to the current document or the site root), this function converts the relative URL to an absolute file:// URL.

Arguments

docPath, siteRoot, relURL

  • The docPath argument is the path to a document on the user’s computer (for example, the current document), which is expressed as a file:// URL or an empty string if relURL is a root-relative URL.

  • The siteRoot argument is the path to the site root, which is expressed as a file:// URL or an empty string if relURL is a document-relative URL.

  • The relURL argument is the URL to convert.

Returns

An absolute URL string. The return value is generated, as described in the following list:

  • If relURL is an absolute URL, no conversion occurs, and the return value is the same as relURL.

  • If relURL is a document-relative URL, the return value is the combination of docPath and relURL.

  • If relURL is a root-relative URL, the return value is the combination of siteRoot and relURL.

DWUri.isValidURI()

Availability

Dreamweaver CS5.

Description

Determines if the URI object is valid or not. The URI object is not valid until it is constructed or initialized with the valid URI.

Arguments

None.

Returns

A Boolean value: true if the URI is valid.

DWUri.isAbsolute()

Availability

Dreamweaver CS5.

Description

Determines if the URI object is a fully qualified URI. The URI object is not valid until it is constructed or initialized with the valid URI.

Arguments

None.

Returns

A Boolean value: true if the URI is fully qualified.

DWUri.isRelative()

Availability

Dreamweaver CS5.

Description

Determines if the URI object is a relative URI. The URI object is not valid until it is constructed or initialized with the valid URI.

Arguments

None.

Returns

A Boolean value: true if the URI is relative.

DWUri.isDirectory()

Availability

Dreamweaver CS5.

Description

Determines if the URI object is a directory. The URI object is not valid until it is constructed or initialized with the valid URI.

Arguments

None.

Returns

A Boolean value: true if the URI is a directory.

DWUri.isHierarchical()

Availability

Dreamweaver CS5.

Description

Determines if the URI object is hierarchical. The URI object is not valid until it is constructed or initialized with the valid URI.

Hierarchical URI objects point to a resource that has a hierarchical structure and whose hierarchy can be traversed such as “http://somedomain/parts/orders/index.html”. Non-heirarchical URI objects cannot be traversed such as “mailto:joe@yahoo.com” or “about:blank”.

Arguments

None.

Returns

A Boolean value: true if the URI is hierarchical.

DWUri.isOfType()

Availability

Dreamweaver CS5.

Description

Determines if the URI object has the specified service type scheme. The URI object is not valid until it is constructed or initialized with the valid URI.

Examples of service type schemes are “http”, “file”, and “ftp”. For the URI “http://www.adobe.com”, “http” is the service type scheme.

Arguments

type

The type argument specifies the service type scheme to test.

Returns

A Boolean value: true if the URI is of the specified service type scheme.

DWUri.isOfFileType()

Availability

Dreamweaver CS5.

Description

Determines if the URI object points to a resource of the specified file type. The URI object is not valid until it is constructed or initialized with the valid URI.

For the URI “http://www.adobe.com/index.html”, “html” is the file type.

Arguments

type

The type argument specifies the service type scheme to test.

Returns

A Boolean value: true if the URI points to a resource of the specified file type.

DWUri.getScheme()

Availability

Dreamweaver CS5.

Description

Retrieves the service type scheme. The URI object is not valid until it is constructed or initialized with the valid URI.

For the URI “http://www.adobe.com/index.html”, “http” is the service type scheme.

Arguments

None.

Returns

A String containing the URI object’s service type scheme.

DWUri.getAuthority()

Availability

Dreamweaver CS5.

Description

Retrieves the domain authority. The URI object is not valid until it is constructed or initialized with the valid URI.

For the URI “http://www.adobe.com/index.html”, “www.adobe.com” is the authority.

Arguments

None.

Returns

A String containing the URI object’s domain authority.

DWUri.getUsername()

Availability

Dreamweaver CS5.

Description

Retrieves the user name. The URI object is not valid until it is constructed or initialized with the valid URI.

For the URI “ftp://jon@adobe.com”, “jon” is the user name.

Arguments

None.

Returns

A String containing the URI object’s user name.

DWUri.getPassword()

Availability

Dreamweaver CS5.

Description

Retrieves the password. The URI object is not valid until it is constructed or initialized with the valid URI.

For the URI “ftp://jon:xxx@adobe.com”, “xxx” is the password.

Arguments

None.

Returns

A String containing the URI object’s password.

DWUri.getServerPort()

Availability

Dreamweaver CS5.

Description

Retrieves the server port. The URI object is not valid until it is constructed or initialized with the valid URI.

For the URI “http://www.adobe.com:8080”, “8080” is the port.

Arguments

None.

Returns

A String containing the URI object’s server port.

DWUri.getPath()

Availability

Dreamweaver CS5.

Description

Retrieves the path part or the file name. The URI object is not valid until it is constructed or initialized with the valid URI.

For the URI “http://www.adobe.com/Dreamweaver/CS5/index.htm”, “/Dreamweaver/CS5/” is the path part.

Arguments

None.

Returns

A String containing the URI object’s path part.

DWUri.getQuery()

Availability

Dreamweaver CS5.

Description

Retrieves the query string. The URI object is not valid until it is constructed or initialized with the valid URI.

For the URI “http://www.adobe.com/Dreamweaver/CS5/index.htm?q=1502”, “q=1502” is the query string.

Arguments

None.

Returns

A String containing the URI object’s query string.

DWUri.getFragment

Availability

Dreamweaver CS5.

Description

Retrieves the URI anchor fragment. The URI object is not valid until it is constructed or initialized with the valid URI.

For the URI “http://www.adobe.com/Dreamweaver/CS5/index.htm#toc”, “toc” is the anchor fragment.

Arguments

None.

Returns

A String containing the URI object’s anchor fragment string.

DWUri.getNonHierarchical()

Availability

Dreamweaver CS5.

Description

Retrieves the non-hierarchical URI string. The URI object is not valid until it is constructed or initialized with the valid URI.

For the URI “mailto:jon@adobe.com”, “don@adobe.com” is the non-hierarchical part.

Arguments

None.

Returns

A String containing the URI object’s non-hierarchical string.

DWUri.setScheme()

Availability

Dreamweaver CS5.

Description

Sets the service type scheme for the URI.

The service type scheme can be any string value but cannot contain special characters such as “:”, “/”, or ”\”.

Arguments

scheme

The scheme argument specifies the service type scheme.

Returns

None.

DWUri.setAuthority()

Availability

Dreamweaver CS5.

Description

Sets the domain authority for the URI.

The domain authority can be any string value but cannot contain special characters such as “:”, “/”, or ”\”.

Arguments

authority

The authority argument specifies the domain authority name or the IP address.

Returns

None.

DWUri.setUsername()

Availability

Dreamweaver CS5.

Description

Sets the user name of the URI.

Typically, user names are used only for the FTP service type schemes.

Arguments

username

The argument specifies the user name.

Returns

None.

DWUri.setPassword()

Availability

Dreamweaver CS5.

Description

Sets the password of the URI.

Typically, passwords are used only for the FTP service type schemes.

Arguments

password

The argument specifies the password.

Returns

None.

DWUri.setPath()

Availability

Dreamweaver CS5.

Description

Sets the path part of the URI filename.

You can set the path to an empty string or “/” to change the path to the root.

Arguments

path

The argument specifies the path part of the filename.

Returns

None.

DWUri.setServerPort()

Availability

Dreamweaver CS5.

Description

Sets the port of the URI object.

Each service type scheme has a default port specified by the IETF standards. Use this function to add a non-standard port to the URI. The port must be a numeric value between 1 and 65535.

Arguments

port

The argument specifies the server port.

Returns

None.

DWUri.setQuery()

Availability

Dreamweaver CS5.

Description

Sets the query string of the URI object.

Use the DWUri.setQueryValue() function to change the value of just one parameter.

Arguments

query

The argument specifies the query string.

Returns

None.

DWUri.setFragment()

Availability

Dreamweaver CS5.

Description

Sets the anchor fragment string of the URI object.

Arguments

anchor

The argument specifies the anchor name.

Returns

None.

DWUri.setNonHierarchical()

Availability

Dreamweaver CS5.

Description

Sets the non-hierarchical string of the URI object. Invoking this function will clear the hierarchical attributes of the URI.

Arguments

nonHierarchical

The argument specifies the non-hierarchical string.

Returns

None.

DWUri.getQueryValue()

Availability

Dreamweaver CS5.

Description

Retrieves the value associated with the URI name passed as an argument.

For the URI “http://www.adobe.com/Dreamweaver/CS5/index.htm?q=1502”, getQuery(“q”) will return “1502”. Requesting a value for name that does not exist will return an empty string.

Arguments

name

The argument specifies the name in the query.

Returns

A string value representing the value of the name in the query.

DWUri.setQueryValue()

Availability

Dreamweaver CS5.

Description

Sets the name and value associated with the query string of the URI. Setting an empty string as value will remove the name from the query string.

Arguments

name

The argument specifies the name in the query.

value

The argument specifies the value of the name in the query.

Returns

None.

DWUri.getQueryByObject()

Availability

Dreamweaver CS5.

Description

Retrieves the query property object of the URI object.

Changes to the property map are not reflected in the URI object until you invoke the DWUri.setQueryByObject() function.

Arguments

None.

Returns

Object

The property map of the URI.

DWUri.setQueryByObject()

Availability

Dreamweaver CS5.

Description

Replaces the entire property map of the URI object with the specified map.

For example,

function main{ 
    var referrer = new Object; 
    referrer.page = "index.html"; 
    referrer.user = "jon"; 
    DWUri uri = new DWUri; 
    uri.setQueryByObject ( referrer ); 
}

Arguments

objectMap

The property map of the URI.

Returns

None.

DWUri.getRelation()

Availability

Dreamweaver CS5.

Description

Determines the relationship between 2 URIs.

Arguments

other

The URI to compare against. Specify a valid string or a DWUri object.

Returns

Integer that specifies the manifest value constant. The possible constants are:

  • DWUri.NOT_REALTED

  • DWUri.CHILD

  • DWUri.EQUAL

  • DWUri.PARENT

DWUri.getCommonParent()

Availability

Dreamweaver CS5.

Description

Determines the common parent between the 2 URIs.

If there is not a common parent, this function will return an empty DWUri object that should be validated by invoking the DWUri.isValidURI() function.

Arguments

other

The URI to compare against. Specify a valid string or a DWUri object.

Returns

Object

A DWUri object that represents the common parent.

DWUri.makeAbsolute()

Availability

Dreamweaver CS5.

Description

Constructs a fully qualified URI by taking the URI passed as an argument.

Arguments

other

Specify a valid string or a DWUri object.

Returns

A Boolean: true if the operation succeeds.

DWUri.makeRelative()

Availability

Dreamweaver CS5.

Description

Constructs a relative URI by finding the common parent from the URI passed as an argument.

Arguments

other

Specify a valid string or a DWUri object.

Returns

A Boolean: true if the operation succeeds.

DWUri.chDir()

Availability

Dreamweaver CS5.

Description

Changes to the specified directory. The string “..” is used to change to the parent directory.

Arguments

dir

Specify a valid string as a directory.

Returns

A Boolean: true if the operation succeeds.

DWUri.getFileName()

Availability

Dreamweaver CS5.

Description

Retrieves the filename from the URI object.

Arguments

stripExtension

A Boolean: true to remove the extension from the result. Specify false to return with extension. The default behavior is to return with the extension. This argument is optional.

Returns

A string that specifies the filename.

DWUri.getExtension()

Availability

Dreamweaver CS5.

Description

Retrieves the extension from the URI object.

Arguments

stripDot

A Boolean: true to remove the leading dot from the result. Specify false to return the leading dot. The default behavior is to return with the leading dot. This argument is optional.

Returns

A string that specifies the extension.

DWUri.getLastPathComponent()

Availability

Dreamweaver CS5.

Description

Retrieves the last part of the path component of the filename.

Arguments

None.

Returns

A string that specifies the last path part.

For the URI “http://www.adobe.com/Dreamweaver/CS5/index.htm”, getLastPathComponent() will return “CS5”.

DWUri.removeLastPathComponent()

Availability

Dreamweaver CS5.

Description

Removes the last part of the path component of the filename.

For the URI “http://www.adobe.com/Dreamweaver/CS5/index.htm”, removeLastPathComponent() will return “CS5” and will remove that string from the URI.

Arguments

None.

Returns

A string that specifies the last path part.

DWUri.isUnderDirectory()

Availability

Dreamweaver CS5.

Description

Determines if the URI is under a specified parent URI.

Note that the directory name comparisons are always case sensitive.

Arguments

A string that represents the parent URI.

Returns

A Boolean: true if the URI is under the specified parent URI.

DWUri.toLocalPath()

Availability

Dreamweaver CS5.

Description

Converts a URI with a service type scheme of “file” to a file system compatible string.

The return value is a platform specific string. Every platform represents the filename differently.

Arguments

None.

Returns

A string that represents a file system path that can be used to open files using the system level APIs. This string can be passsed as an argument to other DWFile functions.

DWUri.localPathToURI()

Availability

Dreamweaver CS5.

Description

Converts a local file path to a URI object.

Arguments

A string specifying the local filename that needs to be encoded as a URI.

Returns

Nothing.

 Adobe

Get help faster and easier

New user?