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

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

Methods

Classes and Modules

Class FSDB::PathUtilities::InvalidPathError

Public Instance methods

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.

Is the path in the simplest, canonical representation?

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

Dir globbing. Excludes ’.’ and all ’..*’ files (but includes ’..*/*’, if included in the match). Returns sorted array of strings to help avoid deadlock when doing nested transactions. Does not yield to block (as Dir.glob does) because glob operates under Thread.exclusive, because it uses Dir.chdir, which is not threadsafe.

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

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.

[Validate]