Module FSDB::PathUtilities
In: lib/fsdb/util.rb
Module: FSDB

Extends FSDB:Databases to have methods for validating and normalizing paths, path globbing, directory traversal, making links, ...

Methods
canonical    canonical?    directory?    glob    valid?    validate   
Classes and Modules
Class FSDB::PathUtilities::InvalidPathError
Public Instance methods
canonical(path)

Attempts to convert a path to a canonical form so that '/foo/bar', 'foo/bar', 'foo//bar', and 'foo/zap/../bar' all result in the same path. The canonical form is the simplest.

Doesn't remove trailing '/', which indicates directory.

This is not necessary for database access, it's just for display purposes and for validation.

canonical?(path)

Is the path in the simplest, canonical representation?

valid?(path)

Does the path refer to an object within the database? This doesn't check for links.

validate(path)

Raises InvalidPathError if canonical(path) still has embedded '..', which means the path would refer to a file not below the database directory. Returns the canonical path, otherwise.

glob(str)

Dir globbing. (Not protected. Use inside of 'browse dir'.) Excludes '.' and all '..*' files. Returns sorted array of strings to help avoid deadlock when doing nested transactions.

directory?(path)

Use this to check whether a path yielded by an iterator is a directory.