2017 © Pedro Peláez
 

library pathtype

Unix path manipulation

image

pathtype/pathtype

Unix path manipulation

  • Friday, August 30, 2013
  • by rubendg
  • Repository
  • 0 Watchers
  • 1 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PathType - Unix path manipulation

Build Status, (*1)

An OO library for Unix path manipulation. The properties of a path absolute/relative file or directory are reflected in the type and invalid operations (like appending an absolute directory path to an relative file path) are simply not possible by construction., (*2)

The library is heavily inspired by the Haskell pathtype library, but is not meant to be a port in anyway. Here is the type hierachy:, (*3)

Type hierarchy, (*4)

A quick example., (*5)

Using the factory function Path::from we can produce any of the types in the bottom of the diagram. It takes a well-formed path string and a flag indicating whether the path is a directory or a file (since this cannot actually be determined from the path in all cases)., (*6)

$path = '/etc/apache2/site-enabled';
$sitesEnabled = Path::from($path, is_dir($path));

function newApacheConfig(AbsDir $sitesEnabled, $name) {
   mkdir($sitesEnabled
   ->append('sites-enabled')
   ->append($name)
   ->get());
}

newApacheConfig($sitesEnabled);

One of the added benefits besides the path manipulation functions is that we can now use type hinting in order to express that newApacheConfig expects an absolute directory path., (*7)

Notes:, (*8)

  • The filesystem is never touched by the library.
  • No tilde (~) support. Let the OS resolve the tilde to the actual home directory before using the library.

Warning: this library is not battle tested, (*9)

Similar:, (*10)

  • http://hackage.haskell.org/package/pathtype
  • https://github.com/eloquent/pathogen

The Versions

30/08 2013

dev-master

9999999-dev https://github.com/rubendg/pathtype

Unix path manipulation

  Sources   Download

The Requires

 

The Development Requires

by Ruben de Gooijer

file filesystem directory unix filepath