Home / Function/ file_name() — tailwindcss Function Reference

file_name() — tailwindcss Function Reference

Architecture documentation for the file_name() function in pathutil.rs from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  6f269ee0_d2cd_f23e_32af_175a3f512c09["file_name()"]
  7edbda91_dd4e_3021_c6fa_edda73e523e1["is_hidden()"]
  7edbda91_dd4e_3021_c6fa_edda73e523e1 -->|calls| 6f269ee0_d2cd_f23e_32af_175a3f512c09
  style 6f269ee0_d2cd_f23e_32af_175a3f512c09 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

crates/ignore/src/pathutil.rs lines 116–132

pub(crate) fn file_name<'a, P: AsRef<Path> + ?Sized>(path: &'a P) -> Option<&'a OsStr> {
    use memchr::memrchr;
    use std::os::unix::ffi::OsStrExt;

    let path = path.as_ref().as_os_str().as_bytes();
    if path.is_empty() {
        return None;
    } else if path.len() == 1 && path[0] == b'.' {
        return None;
    } else if path.last() == Some(&b'.') {
        return None;
    } else if path.len() >= 2 && &path[path.len() - 2..] == &b".."[..] {
        return None;
    }
    let last_slash = memrchr(b'/', path).map(|i| i + 1).unwrap_or(0);
    Some(OsStr::from_bytes(&path[last_slash..]))
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does file_name() do?
file_name() is a function in the tailwindcss codebase.
What calls file_name()?
file_name() is called by 1 function(s): is_hidden.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free