diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-09 11:17:08 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-09 11:17:08 +0900 |
| commit | e3e8806aec771e482899ed3470e920f7b291fa95 (patch) | |
| tree | 786fac56e96978220131ffeaff807b732a377bfe /crates/shirabe-external-packages/src/symfony/finder/spl_file_info.rs | |
| parent | 64e02ef08f0f479937fc194f79eac997327a79dd (diff) | |
| download | php-shirabe-e3e8806aec771e482899ed3470e920f7b291fa95.tar.gz php-shirabe-e3e8806aec771e482899ed3470e920f7b291fa95.tar.zst php-shirabe-e3e8806aec771e482899ed3470e920f7b291fa95.zip | |
refactor(symfony-finder): extract symfony/finder into the shirabe-symfony-finder crate
Move `Symfony\Component\Finder` out of shirabe-external-packages and into
its own crate, so the path is `shirabe_symfony_finder::Finder` instead of
`shirabe_external_packages::symfony::finder::Finder`.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-external-packages/src/symfony/finder/spl_file_info.rs')
| -rw-r--r-- | crates/shirabe-external-packages/src/symfony/finder/spl_file_info.rs | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/finder/spl_file_info.rs b/crates/shirabe-external-packages/src/symfony/finder/spl_file_info.rs deleted file mode 100644 index 6f03fe14..00000000 --- a/crates/shirabe-external-packages/src/symfony/finder/spl_file_info.rs +++ /dev/null @@ -1,84 +0,0 @@ -//! ref: composer/vendor/symfony/finder/SplFileInfo.php - -#[derive(Debug)] -pub struct SplFileInfo { - // The path passed to the underlying \SplFileInfo constructor. - pathname: String, - relative_path: String, - relative_pathname: String, -} - -impl std::fmt::Display for SplFileInfo { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.get_pathname()) - } -} - -impl SplFileInfo { - pub fn new(file: &str, relative_path: &str, relative_pathname: &str) -> Self { - Self { - pathname: file.to_string(), - relative_path: relative_path.to_string(), - relative_pathname: relative_pathname.to_string(), - } - } - - pub fn get_pathname(&self) -> String { - self.pathname.clone() - } - - pub fn get_path(&self) -> String { - shirabe_php_shim::dirname(&self.pathname) - } - - pub fn get_filename(&self) -> String { - shirabe_php_shim::basename(&self.pathname) - } - - pub fn get_basename(&self, suffix: Option<&str>) -> String { - match suffix { - Some(suffix) => shirabe_php_shim::basename_with_suffix(&self.pathname, suffix), - None => shirabe_php_shim::basename(&self.pathname), - } - } - - pub fn get_extension(&self) -> String { - // \SplFileInfo::getExtension() returns the extension (without the dot), or "" if none. - let base = shirabe_php_shim::basename(&self.pathname); - match base.rfind('.') { - Some(index) => base[index + 1..].to_string(), - None => String::new(), - } - } - - pub fn get_relative_path_name(&self) -> String { - self.relative_pathname.clone() - } - - pub fn get_relative_path(&self) -> String { - self.relative_path.clone() - } - - pub fn is_dir(&self) -> bool { - shirabe_php_shim::is_dir(&self.pathname) - } - - pub fn is_file(&self) -> bool { - shirabe_php_shim::is_file(&self.pathname) - } - - pub fn is_link(&self) -> bool { - shirabe_php_shim::is_link(&self.pathname) - } - - pub fn get_real_path(&self) -> Option<String> { - // \SplFileInfo::getRealPath() returns the canonicalized absolute path, or false on failure. - shirabe_php_shim::realpath(&self.pathname) - } - - pub fn get_size(&self) -> i64 { - // \SplFileInfo::getSize() returns the file size in bytes (throws on failure). - // TODO(phase-c): PHP throws a \RuntimeException on stat failure; this returns 0 instead. - shirabe_php_shim::filesize(&self.pathname).unwrap_or(0) - } -} |
