Copyright ã1994 by NeXT Computer, Inc.  All Rights Reserved.

NSWorkspace

Inherits From:	NSObject

Conforms To:	NSObject (NSObject)

Declared In:	AppKit/NSWorkspace.h

Class Description

An NSWorkspace object responds to application requests to perform a variety of services:

·	opening, manipulating, and obtaining information about files and devices

·	tracking changes to the file system, devices, and the user database

·	launching applications

·	miscellaneous services such as animating an image and requesting additional time before power off

An NSWorkspace object is made available through the sharedWorkspace method. For example, the following statement uses an NSWorkspace object to request that a file be opened in the Edit application:

[[NSWorkspace sharedWorkspace] openFile:"/Myfiles/README" withApplication:"Edit"];

Creating a Workspace

+ (NSWorkspace *)sharedWorkspace	Returns a shared workspace.

Opening Files

- (BOOL)openFile:(NSString *)fullPath	Instructs Workspace Manager to open the file specified by fullPath using the default application for its type; returns YES if file was successfully opened and NO otherwise.

- (BOOL)openFile:(NSString *)fullPath	Instructs Workspace Manager to open the file specified by
fromImage:(NSImage *)anImage		fullPath using the default application for its type. To
at:(NSPoint)point		provide animation prior to the open, anImage should
inView:(NSView *)aView		contain the file's icon, and its image should be displayed at point, using aView's coordinates. Returns YES if file was successfully opened and NO otherwise.

- (BOOL)openFile:(NSString *)fullPath	Instructs Workspace Manager to open the file specified by
withApplication:(NSString *)appName		fullPath using the appName application; returns YES if file was successfully opened and NO otherwise.

- (BOOL)openFile:(NSString *)fullPath	Instructs Workspace Manager to open the file specified by
withApplication:(NSString *)appName		fullPath using the appName application where flag
andDeactivate:(BOOL)flag		indicates if sending application should be deactivated before the request is sent; returns YES if file was successfully opened and NO otherwise.

- (BOOL)openTempFile:(NSString *)fullPath	Instructs Workspace Manager to open the temporary file specified by fullPath using the default application for its type; returns YES if file was successfully opened and NO otherwise.

Manipulating Files	

- (BOOL)performFileOperation:(NSString *)operation 
source:(NSString *)source	Requests the Workspace Manager to perform a file
destination:(NSString *)destination		operation on a set of files in the source directory
files:(NSArray *)files		specifying the destination directory if needed using tag
tag:(int *)tag		as an identifier for asynchronous operations; returns YES if operation succeeded and NO otherwise.

- (BOOL)selectFile:(NSString *)fullPath 
inFileViewerRootedAtPath:(NSString *)rootFullpath
	Instructs Workspace Manager to select the file specified by fullPath opening a new file viewer if a path is specified by rootFullpath; returns YES if file was successfully selected and NO otherwise.

Requesting Information about Files

- (NSString *)fullPathForApplication:(NSString *)appName
	Returns the full path for the application appName.

- (BOOL)getFileSystemInfoForPath:(NSString *)fullPath 
isRemovable:(BOOL *)removableFlag	Describes the file system at fullPath in description and
isWritable:(BOOL *)writableFlag		fileSystemType, sets the Flags appropriately, and returns
isUnmountable:(BOOL *)unmountableFlag		YES if fullPath is a file system mount point, or NO if it
description:(NSString **)description		isn't.
type:(NSString **)fileSystemType

- (BOOL)getInfoForFile:(NSString *)fullPath	Retrieves information about the file specified by fullPath,
application:(NSString **)appName		sets appName to the application the Workspace
type:(NSString **)type		Manager would use to open fullPath, sets type to a value or file name extension indicating the file's type, and returns YES upon success and NO otherwise.

- (NSImage *)iconForFile:(NSString *)fullPath	Returns an NSImage with the icon for the single file specified by fullPath.

- (NSImage *)iconForFiles:(NSArray *)pathArray	Returns an NSImage with the icon for the files specified in pathArray, an array of NSStrings. If pathArray specifies one file, its icon is returned. If pathArray specifies more than one file, an icon representing the multiple selection is returned.

- (NSImage *)iconForFileType:(NSString *)fileType	Returns an NSImage the icon for the file type specified by fileType.

Tracking Changes to the File System

- (BOOL)fileSystemChanged	Returns whether a change to the file system has been registered with a noteFileSystemChanged message since the last fileSystemChanged message.

- (void)noteFileSystemChanged	Informs Workspace Manager that the file system has changed.

Updating Registered Services and File Types

- (void)findApplications	Instructs Workspace Manager to examine all applications in the normal places and update its records of registered services and file types.

Launching and Manipulating Applications	

- (void)hideOtherApplications	Hides all applications other than the sender.

- (BOOL)launchApplication:(NSString *)appName	Instructs Workspace Manager to launch the application appName and returns YES if application was successfully launched and NO otherwise.

- (BOOL)launchApplication:(NSString *)appName	Instructs Workspace Manager to launch the application
showIcon:(BOOL)showIcon		appName displaying the application's icon if showIcon
autolaunch:(BOOL)autolaunch		is YES and using the dock autolaunching defaults if autolaunch is YES; returns YES if application was successfully launched and NO otherwise.

Unmounting a Device	

- (BOOL)unmountAndEjectDeviceAtPath:(NSString *)path
	Unmounts and ejects the device at path and returns YES if unmount succeeded and NO otherwise.

Tracking Status Changes for Devices

- (void)checkForRemovableMedia	Causes the Workspace Manager to poll the system's drives for any disks that have been inserted but not yet mounted. Asks the Workspace Manager to mount the disk asynchronously and returns immediately.

- (NSArray *)mountNewRemovableMedia	Causes the Workspace Manager to poll the system's drives for any disks that have been inserted but not yet mounted, waits until the new disks have been mounted, and returns a list of full pathnames to all newly mounted disks.

- (NSArray *)mountedRemovableMedia	Returns a list of the pathnames of all currently mounted removable disks.

Notification Center

- (NSNotificationCenter *)notificationCenter	Returns the notification center for WorkSpace notifications.

Tracking Changes to the User Defaults Database

- (void)noteUserDefaultsChanged	Informs Workspace Manager that the defaults database has changed.

- (BOOL)userDefaultsChanged	Returns whether a change to the defaults database has been registered with a noteUserDefaultsChanged message since the last userDefaultsChanged message.

Animating an Image	

- (void)slideImage:(NSImage *)image	Instructs Workspace Manager to animate a sliding image of
from:(NSPoint)fromPoint		image from fromPoint to toPoint, specified in screen
to:(NSPoint)toPoint		coordinates.

Requesting Additional Time before Power Off or Logout

- (int)extendPowerOffBy:(int)requested	Requests more time before the power goes off or the user logs out; returns the granted number of additional milliseconds.