| 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, …
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.
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.
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.