Name

SPVM::File::Basename - Parsing File Path into Directory and Base Name

Description

File::Basename class in SPVM has methods to parse a file path into a directory part and a base name.

Usage

use File::Basename;

my $path = "dir/a.txt";

# fileparse
{
  my $ret = File::Basename->fileparse($path);
  
  # a.txt
  my $base_name = $ret->[0];
  
  # dir/
  my $dir_name = $ret->[1];
}

# basename
{
  # a.txt
  my $base_name = File::Basename->basename($path);
}

# dirname
{
  # dir
  my $dir_name = File::Basename->dirname($path);
}

Class Methods

fileparse

static method fileparse : string[] ($path : string);

Divides a file path into its directory part and base name and returns them as an array.

The index 0 of the returned array is a base name.

The index 1 of the returned array is a directory part.

See "fileparse" in File::Basename for details.

basename

static method basename : string ($path : string);

Returns the base name of the path $path.

See "basename" in File::Basename for details.

dirname

static method dirname : string ($path : string);

Returns the directory part of the path $path.

See "dirname" in File::Basename for details.

See Also

Porting

SPVM::File::Basename is a Perl's File::Basename porting to SPVM.

Repository

SPVM::File::Basename - Github

Author

Yuki Kimoto [email protected]

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License