fn check_file_url(url: &Url, ctx: &CheckContext) -> Result<(), CheckError> {
    let path = url.to_file_path().unwrap();

    // determine the full path by looking if the path points to a directory,
    // and if so append `index.html`, this is needed as we'll try to read
    // the file, so `expanded_path` should point to a file not a directory
    let index_html;
    let expanded_path = if path.is_file() {
        &path
    } else if path.is_dir() && path.join("index.html").is_file() {
        index_html = path.join("index.html");
        &index_html
    } else {
        debug!("Linked file at path {} does not exist!", path.display());
        return Err(CheckError::File(path));
    };

    if !ctx.check_fragments {
        return Ok(());
    }

    // The URL might contain a fragment. In that case we need a full GET
    // request to check if the fragment exists.
    match url.fragment() {
        Some(fragment) => check_file_fragment(&path, expanded_path, fragment),
        None => Ok(()),
    }
}
/// Check a URL with the "file" scheme for availability. Returns `false` if it is unavailable.
Check a URL with the "file" scheme for availability. Returns `false` if it is unavailable.
Check a URL with the " file " scheme for availability . Returns ` false ` if it is unavailable .
fn check_file_url(url: &Url, ctx: &CheckContext) -> Result<(), CheckError> {
    let path = url.to_file_path().unwrap();
    // determine the full path by looking if the path points to a directory,
    // and if so append `index.html`, this is needed as we'll try to read
    // the file, so `expanded_path` should point to a file not a directory
    let index_html;
    let expanded_path = if path.is_file() {
        &path
    } else if path.is_dir() && path.join("index.html").is_file() {
        index_html = path.join("index.html");
        &index_html
    } else {
        debug!("Linked file at path {} does not exist!", path.display());
        return Err(CheckError::File(path));
    };
    if !ctx.check_fragments {
        return Ok(());
    }
    // The URL might contain a fragment. In that case we need a full GET
    // request to check if the fragment exists.
    match url.fragment() {
        Some(fragment) => check_file_fragment(&path, expanded_path, fragment),
        None => Ok(()),
    }
}
fn check_file_url ( url : & Url , ctx : & CheckContext ) -> Result < ( ) , CheckError > { let path = url . to_file_path ( ) . unwrap ( ) ; // determine the full path by looking if the path points to a directory, // and if so append `index.html`, this is needed as we'll try to read // the file, so `expanded_path` should point to a file not a directory let index_html ; let expanded_path = if path . is_file ( ) { & path } else if path . is_dir ( ) && path . join ( " " ) . is_file ( ) { index_html = path . join ( " " ) ; & index_html } else { debug ! ( " " path display ( ) ) ; return Err ( CheckError :: File ( path ) ) ; } ; if ! ctx . check_fragments { return Ok ( ( ) ) ; } // The URL might contain a fragment. In that case we need a full GET // request to check if the fragment exists. match url . fragment ( ) { Some ( fragment ) => check_file_fragment ( & path , expanded_path , fragment ) , None => Ok ( ( ) ) , } }
Check a URL with the "file" scheme for availability.
Check a URL with the " file " scheme for availability .
url
&Url
ctx
&CheckContext
url
&Url
ctx
&CheckContext