Pchp.Library.PhpPath.AbsolutePath C# (CSharp) Method

AbsolutePath() static private method

Merges the path with the current working directory to get a canonicalized absolute pathname representing the same path (local files only). If the provided path is absolute (rooted local path or an URL) it is returned unchanged.
static private AbsolutePath ( string path ) : string
path string An absolute or relative path to a directory or an URL.
return string
        internal static string AbsolutePath(string path)
        {
            // Don't combine remote file paths with CWD.
            try
            {
                if (IsRemoteFile(path))
                    return path;

                // Remove the file:// schema if any.
                path = GetFilename(path);

                //// Combine the path and simplify it.
                //string combinedPath = Path.Combine(PhpDirectory.GetWorking(), path);

                //// Note: GetFullPath handles "C:" incorrectly
                //if (combinedPath[combinedPath.Length - 1] == ':') combinedPath += PathUtils.DirectorySeparator;
                //return Path.GetFullPath(combinedPath);
                throw new NotImplementedException();
            }
            catch (System.Exception)
            {
                //PhpException.Throw(PhpError.Notice, LibResources.GetString("invalid_path", FileSystemUtils.StripPassword(path)));
                //return null;
                throw;
            }
        }

Usage Example

Ejemplo n.º 1
0
 /// <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);
 }
All Usage Examples Of Pchp.Library.PhpPath::AbsolutePath