SealSkin
Server Reference

fsutil

Small filesystem helpers shared by the launch logic and the file manager.

attributelogger
= logging.getLogger(__name__)
funcresolve_within(base, path) -> str

Return the real path of path after checking that it lies inside base.

Both paths are resolved with os.path.realpath, so neither .. segments nor symlinks can be used to escape base. Trailing components that do not exist yet are allowed, which makes the helper usable for paths about to be created.

parambasestr

Trusted directory the result must stay inside.

parampathstr

Candidate path, usually built from client-supplied names.

Returns

str

The resolved absolute path.

funcsafe_join(base, *parts) -> str

Join parts onto base and return the resolved path inside base.

parambasestr

Trusted directory.

parampartsstr
= ()

Returns

str

The resolved absolute path.

funcsafe_copytree(src, dst, symlinks=True) -> None

Copy a directory tree, tolerating dangling symlinks.

paramsrcstr

Source directory.

paramdststr

Destination directory (must not exist).

paramsymlinksbool
= True

Copy symlinks as symlinks instead of following them.

Returns

None
funcsafe_rmtree(path) -> None

Remove a directory tree, translating permission errors to HTTP 403.

parampathstr

Directory to remove.

Returns

None
funcunique_filename(directory, filename) -> str

Return filename or a name-N.ext variant that does not exist yet.

paramdirectorystr

Directory the file will be placed in.

paramfilenamestr

Desired file name.

Returns

str

A file name that is free inside directory.

funcsanitize_for_filename(name) -> str

Turn an arbitrary display name into a safe directory name.

paramnamestr

Display name such as an application name.

Returns

str

Lower-case ASCII letters, digits and dashes, at most 50 characters,