std/private/osdirs (original) (raw)

proc copyDir(source, dest: string; skipSpecial = false) {....gcsafe, extern: "nos$1", tags: [ReadDirEffect, WriteIOEffect, ReadIOEffect], gcsafe, raises: [OSError, IOError], forbids: [].}

Copies a directory from source to dest.

On non-Windows OSes, symlinks are copied as symlinks. On Windows, symlinks are skipped.

If skipSpecial is true, then (besides all directories) only regular files (without special "file" objects like FIFOs, device files, etc) will be copied on Unix.

If this fails, OSError is raised.

On the Windows platform this proc will copy the attributes from source into dest.

On other platforms created files and directories will inherit the default permissions of a newly created file/directory for the user. Use copyDirWithPermissions proc to preserve attributes recursively on these platforms.

See also:

proc copyDirWithPermissions(source, dest: string; ignorePermissionErrors = true; skipSpecial = false) {....gcsafe, extern: "nos$1", tags: [ReadDirEffect, WriteIOEffect, ReadIOEffect], gcsafe, raises: [OSError, IOError, Exception], forbids: [].}

Copies a directory from source to dest preserving file permissions.

On non-Windows OSes, symlinks are copied as symlinks. On Windows, symlinks are skipped.

If skipSpecial is true, then (besides all directories) only regular files (without special "file" objects like FIFOs, device files, etc) will be copied on Unix.

If this fails, OSError is raised. This is a wrapper proc around copyDir and osfiles: copyFileWithPermissions procs on non-Windows platforms.

On Windows this proc is just a wrapper for copyDir proc since that proc already copies attributes.

On non-Windows systems permissions are copied after the file or directory itself has been copied, which won't happen atomically and could lead to a race condition. If ignorePermissionErrors is true (default), errors while reading/setting file attributes will be ignored, otherwise will raise OSError.

See also:

proc createDir(dir: string) {....gcsafe, extern: "nos$1", tags: [WriteDirEffect, ReadDirEffect], raises: [OSError, IOError], forbids: [].}

Creates the directory dir.

The directory may contain several subdirectories that do not exist yet. The full path is created. If this fails, OSError is raised.

It does not fail if the directory already exists because for most usages this does not indicate an error.

See also:

proc existsOrCreateDir(dir: string): bool {....gcsafe, extern: "nos$1", tags: [WriteDirEffect, ReadDirEffect], raises: [OSError, IOError], forbids: [].}

Checks if a directory dir exists, and creates it otherwise.

Does not create parent directories (raises OSError if parent directories do not exist). Returns true if the directory already exists, and false otherwise.

See also: