/// <summary>Changes the virtual working directory for the current script.</summary>
/// <param name="ctx">Runtime context.</param>
/// <param name="directory">Absolute or relative path to the new working directory.</param>
/// <returns>Returns <c>true</c> on success or <c>false</c> on failure.</returns>
/// <exception cref="PhpException">If the specified directory does not exist.</exception>
public static bool chdir(Context ctx, string directory)
{
if (directory != null)
{
string newPath = PhpPath.AbsolutePath(ctx, directory);
if (System.IO.Directory.Exists(newPath))
{
// Note: open_basedir not applied here, URL will not pass through
ctx.WorkingDirectory = newPath;
return(true);
}
}
PhpException.Throw(PhpError.Warning, string.Format(Resources.LibResources.directory_not_found, directory));
return(false);
}