Chapter 21. Files
This chapter explains how to use REALbasic to work with files on disk. You can access the filing system itself, in order to learn or set such things as the type or date of a file, or to copy, delete, or create a file; and you can read or write the data that a file contains.
Getting a FolderItem
Every reference to a file on disk is performed by way of an instance
of the FolderItem class. Conversely, every
non-nil
FolderItem instance points to some file on
disk; the file in question need not actually exist (otherwise, it
would be impossible to create a file, since you could not refer to
the file you wanted to create!), but in that case its containing
folder must exist.
There are five ways to obtain a FolderItem instance, as described in the following sections.
GetFolderItem and GetTrueFolderItem
The first way to obtain a FolderItem instance is to generate it from
a standard
pathname
string. Pathname strings are colon-delimited on Macintosh; for
example, if one of my hard disks is called
Power, then
"Power:Applications"
is a legal pathname. On
Windows, a backslash is the delimiter; for example,
"C:\Program files"
.
The procedure here is to hand the string as parameter to the GetFolderItem function or the GetTrueFolderItem function; a FolderItem is returned. The difference between the two functions is that if the item described by the pathname exists and is an alias, GetFolderItem points to the original, while GetTrueFolderItem points to the alias. And let’s please ...
Get REALBasic: TDG, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.