Instance Method

performFileOperation(_:source:destination:files:tag:)

Performs a file operation on a set of files in a particular directory.

Declaration

func performFileOperation(_ operation: NSWorkspace.FileOperationName, source: String, destination: String, files: [Any], tag: UnsafeMutablePointer<Int>?) -> Bool

Parameters

operation

The file operation to perform. The possible values for this parameter are described in File Operations.

source

The full path to the directory containing the files on which to operate.

destination

The full path to the destination directory of the operation.

files

An array of NSString objects specifying the names of the files and directories to be manipulated. Each string must not contain any path information other than the name of the file or directory. In other words, all of the files and directories must be located in the source directory and not in one if its subdirectories.

tag

On input, a integer variable; on return, this variable contains a negative integer if the operation fails, 0 if the operation was performed synchronously and succeeded, or a positive integer if the operation was performed asynchronously. If the value is a positive integer, the value is a tag that identifies the requested file operation.

Return Value

true if the operation succeeded; otherwise, false.

Discussion

Some operations—such as moving, copying, and linking files—require a destination directory to be specified. If not, destination should be the empty string (@""). Before this method returns, it posts an didPerformFileOperationNotification to the NSWorkspace object's notification center.

It is safe to call this method from any thread of your app.

See Also

Methods

func openFile(String) -> Bool

Opens the specified file specified using the default app associated with its type.

Deprecated
func openFile(String, withApplication: String?) -> Bool

Opens a file using the specified app.

Deprecated
func openFile(String, withApplication: String?, andDeactivate: Bool) -> Bool

Opens the specified file and optionally deactivates the sending app.

Deprecated
func openFile(String, from: NSImage?, at: NSPoint, in: NSView?) -> Bool

Opens a file using the default app for its type and animates the action using a custom icon.

Deprecated
func launchApplication(String) -> Bool

Launches the specified app.

Deprecated
func launchApplication(String, showIcon: Bool, autolaunch: Bool) -> Bool

Launches the specified app using additional options.

Deprecated
func fullPath(forApplication: String) -> String?

Returns the full path for the specified app.

Deprecated
func absolutePathForApplication(withBundleIdentifier: String) -> String?

Returns the absolute file system path of an app bundle.

Deprecated
func mountedRemovableMedia() -> [Any]?

Returns the full pathnames of all currently mounted removable disks.

Deprecated
func mountedLocalVolumePaths() -> [Any]?

Returns the mount points of all local volumes, not just the removable ones returned by mountedRemovableMedia().

Deprecated
func activeApplication() -> [AnyHashable : Any]?

Returns a dictionary with information about the current active app.

Deprecated