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
  1c89d254_7a7f_fbaf_2e3f_015c88a7e473["file_name()"]
  14fdbab7_73ef_0246_2884_5f8133abec90["pathutil.rs"]
  1c89d254_7a7f_fbaf_2e3f_015c88a7e473 -->|defined in| 14fdbab7_73ef_0246_2884_5f8133abec90
  d95152d5_1c4a_b00d_3a87_34d23e42e99c["is_hidden()"]
  d95152d5_1c4a_b00d_3a87_34d23e42e99c -->|calls| 1c89d254_7a7f_fbaf_2e3f_015c88a7e473
  style 1c89d254_7a7f_fbaf_2e3f_015c88a7e473 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, defined in crates/ignore/src/pathutil.rs.
Where is file_name() defined?
file_name() is defined in crates/ignore/src/pathutil.rs at line 116.
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