Click or drag to resize

IVirtualFileSystemCombine Method

Determine the canonically correct script path.

Namespace: WinWrap.Basic.Server
Assembly: WinWrap.Basic.Server (in WinWrap.Basic.Server.dll)
Syntax
string Combine(
	string baseScriptPath,
	string name
)

Parameters

baseScriptPath  String
The base script path for relative names. May be an empty string, in which case the host application should use a reasonable default base script path.
name  String
The name of the script which may be relative to the base script path. If both baseScriptPath and name are empty strings return the root directory (return an empty string for unrestricted file access)."

Return Value

String
The canonically complete script path after combining the base script path with any relative path information in the name.
Remarks
Implement this method to remove relative path information. A script path returned by Combine must be the same exact value for the same script regardless of the original relative path information. This guarentees that a script's path is not affected by the varying details of the relative paths used.

A script path must also meet same requirements as a Windows file path:

  • use \ as the path separator (e.g. "a\b\c")
  • not contain any of the following characters: / * ? " | < >
  • an absolute path begins with \\ or contains : (e.g. "\\share...", "z:...")
  • case insensitive (e.g. "abc" is the same as "ABC")

Special instructions for restricting files to a root directory and all of its sub-directories:

  • Combine("", ""): return the root directory's path
  • other Combine calls: return the file or sub-directory path without the root directory prefix (path must start with '\')

Example
IVirtualFileSystem implementation which uses the normal file system.
public string Combine(string baseScriptPath, string name)
{
    if (string.IsNullOrEmpty(baseScriptPath))
        baseScriptPath = Directory.GetCurrentDirectory();
    else
        baseScriptPath = Path.GetDirectoryName(baseScriptPath);

    return Path.GetFullPath(Path.Combine(baseScriptPath, name));
}
See Also