Important: The information in this document is obsolete and should not be used for new development.
Chapter 1 - Introduction to File Management
This chapter is a general introduction to file management on Macintosh computers. It explains the basic structure of Macintosh files and the hierarchical file system (HFS) used with Macintosh computers, and it shows how you can use the services provided by the Standard File Package, the File Manager, the Finder, and other system software components to create, open, update, and close files.You should read this chapter if your application implements the commands typically found in an application's File menu--except for printing commands and the Quit command, which are described elsewhere. This chapter describes how to
Depending on the requirements of your application, you may be able to accomplish all your file-related operations by following the instructions given in this chapter. If your application has more specialized file management needs, you'll need to read some or all of the remaining chapters in this book.
- create a new file
- open an existing file
- close a file
- save a document's data in a file
- save a document's data in a file under a new name
- revert to the last saved version of a file
- create and read a preferences file
This chapter assumes that your application is running in an environment in which the routines that accept file system specification records (defined by the
FSSpec
data type) are available. File system specification records, introduced in system software version 7.0, simplify the identification of objects in the file system. Your development environment may provide "glue" that allows you to call those routines in earlier system software versions. If such glue is not available and you want your application to run in system software versions earlier than version 7.0, you need to read the discussion of HFS file-manipulation routines in the chapter "File Manager" in this book.This chapter begins with a description of files and their organization into directories and volumes. Then it describes how to test for the presence of the routines that accept
FSSpec
records and how to use those routines to perform the file management tasks listed above. The chapter ends with descriptions of the data structures and routines used to perform these tasks. The "File Management Reference" and "Summary of File Management" sections in this chapter are subsets of the corresponding sections of the remaining chapters in this book.
Chapter Contents
- About Files
- File Forks
- File Size
- File Access Characteristics
- The Hierarchical File System
- Identifying Files and Directories
- Using Files
- Testing for File Management Routines
- Defining a Document Record
- Creating a New File
- Opening a File
- Reading File Data
- Writing File Data
- Saving a File
- Reverting to a Saved File
- Closing a File
- Opening Files at Application Startup Time
- Using a Preferences File
- Adjusting the File Menu
- File Management Reference
- Data Structures
- File System Specification Record
- Standard File Reply Records
- Application Files Records
- File Specification Routines
- File Access Routines
- Reading, Writing, and Closing Files
- Manipulating the File Mark
- Manipulating the End-of-File
- File and Directory Manipulation Routines
- Opening, Creating, and Deleting Files
- Exchanging the Data in Two Files
- Creating File System Specifications
- Volume Access Routines
- Updating Volumes
- Obtaining Volume Information
- Application Launch File Routines
- Summary of File Management
- Pascal Summary
- Constants
- Data Types
- File System Specification Record
- Standard File Reply Record
- Application Files Record
- File Specification Routines
- Opening Files
- Saving Files
- File Access Routines
- Reading, Writing, and Closing Files
- Manipulating the File Mark
- Manipulating the End-of-File
- File and Directory Manipulation Routines
- Opening, Creating, and Deleting Files
- Exchanging the Data in Two Files
- Creating File System Specifications
- Volume Access Routines
- Updating Volumes
- Obtaining Volume Information
- Application Launch File Routines
- C Summary
- Constants
- Data Types
- File System Specification Record
- Standard File Reply Record
- Application Files Record
- Standard File Type List
- Callback Routine Pointer Types
- File Specification Routines
- Opening Files
- Saving Files
- File Access Routines
- Reading, Writing, and Closing Files
- Manipulating the File Mark
- Manipulating the End-of-File
- File and Directory Manipulation Routines
- Opening, Creating, and Deleting Files
- Exchanging the Data in Two Files
- Creating File System Specifications
- Volume Access Routines
- Updating Volumes
- Obtaining Volume Information
- Application Launch File Routines
- Assembly-Language Summary
- Global Variables
- Result Codes