Skip to content

Connection

A connection to a remote SMB resource.

Obtained from connect or connection.

Fields

connected @ Bool

Whether this handle is still connected. Becomes false after disconnect.

name @ Str

The local device the connection redirects, or its remote name when it redirects none.

Methods

disconnect …

Disconnects, invalidating this handle.

Disconnecting an already disconnected connection does nothing, so a connection may be disconnected explicitly inside a scoped connect block.

A persistent connection's profile entry is removed, so it is not restored at the next logon.

Parameters

NameTypeDescription
:force? Bool Disconnect even with open files or directories on the connection. Defaults to false.
:forget_credentials? Bool Remove credentials saved for the server. Defaults to removing them for a persistent connection.

Errors

Exception Condition
sys.ResourceBusyError Files or directories are open on the connection and force is not set

info() -> ConnectionInfo

Reads a fresh snapshot of the connection.

path() -> fs.Path

The connection's root: the drive root when the connection redirects a local device, and the remote name otherwise.

Example

connect \\build\artifacts local: Z: do |conn|
  fs.copy $release $conn.path()