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
  7c0f7456_9ca1_1330_3e17_61fbdbc32f16["file_name()"]
  5a63fc5c_8a1d_dad2_626b_d01b587f0205["pathutil.rs"]
  7c0f7456_9ca1_1330_3e17_61fbdbc32f16 -->|defined in| 5a63fc5c_8a1d_dad2_626b_d01b587f0205
  b85ff626_d65d_98a6_0e45_290b0c5ebfec["is_hidden()"]
  b85ff626_d65d_98a6_0e45_290b0c5ebfec -->|calls| 7c0f7456_9ca1_1330_3e17_61fbdbc32f16
  style 7c0f7456_9ca1_1330_3e17_61fbdbc32f16 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