Fred Drake | c817e27 | 1998-08-10 18:40:22 +0000 | [diff] [blame] | 1 | \section{\module{macostools} --- |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 2 | Convenience routines for file manipulation} |
Fred Drake | fe7f3bc | 1998-07-23 17:55:31 +0000 | [diff] [blame] | 3 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 4 | \declaremodule{standard}{macostools} |
| 5 | \platform{Mac} |
Fred Drake | fe7f3bc | 1998-07-23 17:55:31 +0000 | [diff] [blame] | 6 | \modulesynopsis{Convenience routines for file manipulation.} |
| 7 | |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 8 | |
| 9 | This module contains some convenience routines for file-manipulation |
Jack Jansen | 7aeba45 | 2003-02-12 09:58:33 +0000 | [diff] [blame] | 10 | on the Macintosh. All file parameters can be specified as |
Nicholas Bastin | cfa157d | 2004-06-06 01:17:52 +0000 | [diff] [blame] | 11 | pathnames, \class{FSRef} or \class{FSSpec} objects. This module |
| 12 | expects a filesystem which supports forked files, so it should not |
| 13 | be used on UFS partitions. |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 14 | |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 15 | The \module{macostools} module defines the following functions: |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 16 | |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 17 | |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 18 | \begin{funcdesc}{copy}{src, dst\optional{, createpath\optional{, copytimes}}} |
Jack Jansen | 7aeba45 | 2003-02-12 09:58:33 +0000 | [diff] [blame] | 19 | Copy file \var{src} to \var{dst}. If \var{createpath} is non-zero |
Jack Jansen | 4104b50 | 2002-08-06 22:14:23 +0000 | [diff] [blame] | 20 | the folders leading to \var{dst} are created if necessary. |
| 21 | The method copies data and |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 22 | resource fork and some finder information (creator, type, flags) and |
| 23 | optionally the creation, modification and backup times (default is to |
| 24 | copy them). Custom icons, comments and icon position are not copied. |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 25 | \end{funcdesc} |
| 26 | |
Fred Drake | cce1090 | 1998-03-17 06:33:25 +0000 | [diff] [blame] | 27 | \begin{funcdesc}{copytree}{src, dst} |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 28 | Recursively copy a file tree from \var{src} to \var{dst}, creating |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 29 | folders as needed. \var{src} and \var{dst} should be specified as |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 30 | pathnames. |
| 31 | \end{funcdesc} |
| 32 | |
Fred Drake | cce1090 | 1998-03-17 06:33:25 +0000 | [diff] [blame] | 33 | \begin{funcdesc}{mkalias}{src, dst} |
Jack Jansen | 7aeba45 | 2003-02-12 09:58:33 +0000 | [diff] [blame] | 34 | Create a finder alias \var{dst} pointing to \var{src}. |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 35 | \end{funcdesc} |
| 36 | |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 37 | \begin{funcdesc}{touched}{dst} |
| 38 | Tell the finder that some bits of finder-information such as creator |
| 39 | or type for file \var{dst} has changed. The file can be specified by |
Fred Drake | 8f6ca15 | 2000-10-14 04:59:12 +0000 | [diff] [blame] | 40 | pathname or fsspec. This call should tell the finder to redraw the |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 41 | files icon. |
Guido van Rossum | d59da4b | 2007-05-22 18:11:13 +0000 | [diff] [blame] | 42 | \deprecated{2.6}{The function is a no-op on OS X.} |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 43 | \end{funcdesc} |
| 44 | |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 45 | \begin{datadesc}{BUFSIZ} |
| 46 | The buffer size for \code{copy}, default 1 megabyte. |
| 47 | \end{datadesc} |
| 48 | |
| 49 | Note that the process of creating finder aliases is not specified in |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 50 | the Apple documentation. Hence, aliases created with \function{mkalias()} |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 51 | could conceivably have incompatible behaviour in some cases. |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 52 | |
Fred Drake | fe7f3bc | 1998-07-23 17:55:31 +0000 | [diff] [blame] | 53 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 54 | \section{\module{findertools} --- |
| 55 | The \program{finder}'s Apple Events interface} |
| 56 | |
| 57 | \declaremodule{standard}{findertools} |
| 58 | \platform{Mac} |
Fred Drake | fe7f3bc | 1998-07-23 17:55:31 +0000 | [diff] [blame] | 59 | \modulesynopsis{Wrappers around the \program{finder}'s Apple Events interface.} |
| 60 | |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 61 | |
| 62 | This module contains routines that give Python programs access to some |
| 63 | functionality provided by the finder. They are implemented as wrappers |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 64 | around the AppleEvent\index{AppleEvents} interface to the finder. |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 65 | |
| 66 | All file and folder parameters can be specified either as full |
Jack Jansen | 7aeba45 | 2003-02-12 09:58:33 +0000 | [diff] [blame] | 67 | pathnames, or as \class{FSRef} or \class{FSSpec} objects. |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 68 | |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 69 | The \module{findertools} module defines the following functions: |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 70 | |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 71 | |
| 72 | \begin{funcdesc}{launch}{file} |
| 73 | Tell the finder to launch \var{file}. What launching means depends on the file: |
| 74 | applications are started, folders are opened and documents are opened |
| 75 | in the correct application. |
| 76 | \end{funcdesc} |
| 77 | |
| 78 | \begin{funcdesc}{Print}{file} |
Jack Jansen | 7aeba45 | 2003-02-12 09:58:33 +0000 | [diff] [blame] | 79 | Tell the finder to print a file. The behaviour is identical to selecting the file and using |
Fred Drake | 8f6ca15 | 2000-10-14 04:59:12 +0000 | [diff] [blame] | 80 | the print command in the finder's file menu. |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 81 | \end{funcdesc} |
| 82 | |
| 83 | \begin{funcdesc}{copy}{file, destdir} |
| 84 | Tell the finder to copy a file or folder \var{file} to folder |
Jack Jansen | 7aeba45 | 2003-02-12 09:58:33 +0000 | [diff] [blame] | 85 | \var{destdir}. The function returns an \class{Alias} object pointing to |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 86 | the new file. |
| 87 | \end{funcdesc} |
| 88 | |
| 89 | \begin{funcdesc}{move}{file, destdir} |
| 90 | Tell the finder to move a file or folder \var{file} to folder |
Jack Jansen | 7aeba45 | 2003-02-12 09:58:33 +0000 | [diff] [blame] | 91 | \var{destdir}. The function returns an \class{Alias} object pointing to |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 92 | the new file. |
| 93 | \end{funcdesc} |
| 94 | |
| 95 | \begin{funcdesc}{sleep}{} |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 96 | Tell the finder to put the Macintosh to sleep, if your machine |
| 97 | supports it. |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 98 | \end{funcdesc} |
| 99 | |
| 100 | \begin{funcdesc}{restart}{} |
| 101 | Tell the finder to perform an orderly restart of the machine. |
| 102 | \end{funcdesc} |
| 103 | |
| 104 | \begin{funcdesc}{shutdown}{} |
| 105 | Tell the finder to perform an orderly shutdown of the machine. |
| 106 | \end{funcdesc} |