Trash
The System Folder and Its Related Directories
The System Folder is a directory that stores essential system software such as
the System file, the Finder, and printer drivers. Since this directory has
appeared on all Macintosh computers, it's also been a dependable place to store
and locate files-some that Apple software has installed, some that applications
have installed, and some that users have installed. But for users of earlier
versions of system software, this led to cluttered System Folders whose
contents were often difficult to decipher or maintain.
System 7.0 introduces a new organization for the System Folder, which
contains a set of new subdirectories to hold related files. The Finder uses
these subdirectories to facilitate file management for the user. For example,
by sorting and storing such files as desk accessories, control panels, fonts,
p references files, system extensions, and temporary files into separate folders
for the user, the Finder keeps the top level of the System Folder from being
cluttered with dozens, or even hundreds, of files.
The user can easily install fonts, sounds, keyboard layouts, control panels,
and system extensions by dragging their icons to the System Folder icon. The
Finder then moves them into the proper sub directory. When a control panel
icon is dragged to the System Folder icon, for example, the Finder presents a
dialog box that asks the user, “Place this control panel into the ’Control
Panels' folder?” The user accepts by clicking OK or declines by clicking
Cancel.
Note: If users drag icons to the open System Folder window instead of to
the System Folder icon, the Finder copies or moves the files into the
System Folder directory instead of copying or moving them to the proper
sub directory.
Additional related directories are located at the root directory. Notice the
Trash window. It shows the contents of the Trash directory, which is
represented to the user by the Trash icon. The Trash directory exists at the
root level of the volume. In System 7.0, a Macintosh sharing files among users
in a network environment maintains separate Trash subdirectories within a
shared, network Trash directory. That is, for every user who opens a volume
located on a Macintosh server and drags an object to the Trash icon, the server
creates a separate, uniquely named Trash subdirectory for that user. All Trash
subdirectories within a shared, network Trash directory are invisible to
users. On the desktop, the user sees only the Trash icon of his or her local
Macintosh computer. When the user double-clicks the Trash icon, a window
reveals the names of only those files that he or she has thrown away; no
distinction is made to the user as to which computers any of these files
originated from.
At the root level of the volume, the Finder also maintains a Temporary Items
folder and a Desktop Folder, both of which are invisible to the user and so do
not appear in the figure above.
This figure illustrates the folder organization typically found on single-user
systems. Of all these related directories, your application is likely to use only
the P references folder and the Temporary Items folder. However, you cannot
be certain of the location of these or any of the other system-related
directories. In the future, these system-related directories may not be located
in the System Folder or in the root directory. Therefore, you should always
use the FindFolder function to help you locate these directories. The
FindFolder function is available only in System 7.0. Use the Gestalt
function to determine if FindFolder is available to your application.
Folder Organization
Your application may freely use these two directories for storing and locating
important files:
P references, located in the System Folder, holds p references files
to record local configuration settings. Your application can store its
p references file in this directory. The active Finder P references file
is always stored in the P references folder. Do not use the P references
folder to hold information that is to be shared by users on more than
one Macintosh computer on a network. Ensure that your application can
always operate even if its p references file has been deleted.
Temporary Items, located at the root level of the volume, holds
temporary files created by applications. The Temporary Items folder is
invisible to the user. Your application can place its temporary files in
this directory. A temporary file should exist only as long as your
application needs to keep it open. As soon as your
application closes the file, your application should remove the
temporary file. You should also ensure that you are assigning a unique
name to your temporary file so that you do not write over an other
application's file.
It's important to bear in mind a few rules about storing your
application's files. First, do not store any files at the top level of the
System Folder. Use the P references directory or one of the other
directories described in the following list.
Second, use the FindFolder function described in the next section,
“Finding Directories,” to locate or put files in the right place. Do not
assume files are on the same volume as your application; they could be
on a different local volume, or on a remote volume on the network.
Third, do not store any files that multiple users may need to access,
such as dictionaries and format converters, in the P references
directory or in any of the directories located in the System Folder.
Remember that the files in the System Folder are generally accessible
only to the person who starts up from the System file in that
System Folder.
In System 7.0, there are other new directories that either the user or
the Finder uses for storing and locating important files; these
directories are described here. Generally, your application should not
store files in these directories.
Apple Menu Items, located in the System Folder, holds the standard
desk accessories plus any other desk accessories, applications, files,
folders, or aliases that the user wants to display in the Apple menu.
System 7.0 treats desk accessories like applications, not like system
resources. Desk accessories are no longer stored in a volume's System
file. (For more detail, see Desk Accessories .) Only the user and the
Installer should put things into the Apple Menu Items folder.
Control Panels, located in the System Folder, holds control panels.
The Apple Menu Items folder holds an alias to the Control Panels folder
so that the user can also reach the control panels through the Apple
menu. Only the user and the Installer should put things into the Control
Panels folder.
Desktop Folder, which is invisible to users of System 7.0, is
located at the root level of the volume. The Desktop Folder stores
information about the icons that appear on the desktop area of the
screen. The user controls the contents of the Desktop Folder by
arranging icons on the screen. What appears on the screen to the user
is the union of the contents of Desktop Folders for all mounted volumes.
Extensions, located in the System Folder, holds extensions-that is,
code that is not part of the basic system software but that provides
system-level services, such as printer drivers and system extensions.
Files of type 'INIT', previously called startup documents, and of type
'appe', also known as background-only applications, are routed by the
Finder to this folder. Files of type 'scri' (system extensions for
script systems) are also routed to this folder. Only the user and the
Installer should put things into the Extensions folder.
PrintMonitor Documents, located in the System Folder, holds
spooled documents waiting to be printed. Only the printing software
uses the PrintMonitor Documents folder.
Rescued Items from volume name, located in the Trash
directory, is a directory created by the Finder at system boot,
restart, or shutdown only when the Finder finds items in the
Temporary Items folder. Since applications should remove their
temporary files when they close them, the existence of a file in a
Temporary Items folder indicates a system crash. When the Finder
discovers a file in the Temporary Items folder, the Finder creates a
Rescued Items from volume name directory that is named for the
volume on which the Temporary Items folder exists. For example, the
Finder creates a directory called Rescued Items from Loma Prieta
when a file is discovered in the Temporary Items folder on a volume
named Loma Prieta. The Finder then moves the temporary file to that
directory so that users can examine the file in case they want to
recreate their work up to the time of the system crash. When a user
empties the Trash, all Rescued Items folders disappear. Only the
Finder should put anything into Rescued Items directories.
Startup Items, located in the System Folder, holds applications and
desk accessories (or their aliases) that the user wants started up
every time the Finder starts up. Only the user should put things into
the Startup Items folder. Note that there is a distinction between
startup applications that users put in the Startup Items folder and
system extensions of file type 'INIT' (previously called startup
documents), which are typically installed in the Extensions folder.
System file, located in the System Folder, contains the basic system
software plus some system resources, such as font and sound
resources. In System 7.0, the System file behaves as a folder in this
regard: although it looks like a suitcase icon, double-clicking it opens a
window that reveals movable resource files (such as fonts, sounds,
keyboard layouts, and script system resource collections) stored in the
System file. (Fonts, Sounds, and Other Movable Resources
describes the resources that can be moved into the System file.) Only
the user and the Installer should put resources into the System file.
Trash, located at the root level of a volume, holds items that the user
moves to the Trash icon. After opening the Trash icon, the user sees the
collection of all items that the user has moved to the Trash icon-that
is, the union of all appropriate Trash directories from all mounted
volumes. A Macintosh set up to share files among users in a network
environment maintains separate Trash subdirectories for remote users
within its shared, network Trash directory. That is, for every remote
user who opens a volume located on a Macintosh file server and drags an
object to the Trash icon, the server creates a separate, uniquely named
Trash subdirectory for that user. All Trash subdirectories and the
shared, network Trash directory are invisible to users. The Finder
for System 7.0 empties a Trash directory (or, in the case of a file
server, a Trash sub directory) only when the user of that directory
chooses the Empty Trash command.
Although the names of the visible system-related folders vary on different
international systems, the invisible directories Temporary Items and Desktop
Folder keep these names on all systems. System software assigns unique names
for invisible Trash sub directories.
Generally, you should store application-specific files in the folder with your
application, not in any of these system-related directories. Your application
may want to provide users with a mechanism to specify a directory in which to
look for auxiliary files. For example, you could design a customized version of
the open file dialog box that allows users to specify a path to locations where
files are stored. This technique may be useful for finding files that are shared
by several applications. It's also possible to track the location of files by using
the Alias Manager.
When you design your application, it's important to consider the user's view
of the tools that you provide. In most cases you'll want to build your
application so that the user deals with one icon that represents the entire set of
abilities your application provides. This scheme simplifies the user's world by
restricting the complexity of installing and maintaining your product. If you
provide optional tools-such as a dictionary and thesaurus-that have their own
icons, it's a good idea to allow these tools to work from any location in the file
system rather than relying on their storage somewhere in the System Folder.
Finding Directories
You can use the FindFolder function to get the path information you need to
gain access to the directories described in the previous section. Those you're
most likely to want to access are P references, Temporary Items, and Trash. For
example, you might wish to check for the existence of a user's configuration
file in P references, create a temporary file in Temporary Items, or-if your
application runs out of storage when trying to save a file-check how much
storage is taken by items in the Trash directory and report this to the user.
The FindFolder function is available only in System 7.0. Use the Gestalt
function with the Gestalt selector gestaltFindFolderAttr. Test the bit field
indicated by the gestaltFindFolderPresent constant in the response parameter.
If the bit is set, then the FindFolder function is present.
Your application passes the FindFolder function a target volume and a
constant that tells it which directory you're interested in. FindFolder
returns a volume reference number and a directory ID. If the specified
directory does not exist, FindFolder can create it and return the new
directory ID.
Do not assume files are on the same volume as your application; they could be
on a different local volume or on a remote volume on a network.
The system-related directories in System 7.0, the folder types of these
directories, and the constants that represent them are listed here.
Folder
Directory type Constant
Apple Menu Items 'amnu' kAppleMenuFolderType
Control Panels 'ctrl' kControlPanelFolderType
Desktop Folder 'desk' kDesktopFolderType
Extensions 'extn' kExtensionFolderType
P references 'pref' kP referencesFolderType
PrintMonitor Documents 'prnt' kPrintMonitorDocsFolderType
Shared, network Trash 'empt' kWhereToEmptyTrashFolderType
Single-user Trash 'trsh' kTrashFolderType
Startup Items 'strt' kStartupFolderType
System Folder 'macs' kSystemFolderType
Temporary Items 'temp' kTemporaryFolderType
Note: The Finder identifies the subdirectories of the
System Folder, and their folder types, in a resource of type 'fld#'
located in the System file. Do not modify or rely on the contents of the
'fld#' resource in the System file; use only the FindFolder function
and these constants to find the appropriate directories.
Use the kTrashFolderType constant to locate the current user's Trash
directory for a given volume-even one located on a file server. On a file
server, you can use the kWhereToEmptyTrashFolderType constant to locate the
parent directory of all logged-on users' Trash sub directories.
In calls to FindFolder, you can also use these three constants:
kOnSystemDisk use vRefNum for the boot disk
kCreateFolder create folder if it does not exist
kDontCreateFolder do not create folder
Call the FindFolder function to get a volume reference number and directory
ID for any of these directories.