1HFSSH(1)                    General Commands Manual                   HFSSH(1)
2
3
4

NAME

6       hfssh - Tcl interpreter with HFS extensions
7

SYNOPSIS

9       hfssh [script]
10

DESCRIPTION

12       hfssh  is a Tcl interpreter like tclsh(1) but which also implements the
13       following extensions to support manipulation of Macintosh HFS media:
14
15       hfs mount path [partno]
16              Mounts the indicated HFS partition from the given path.  An  HFS
17              volume  handle is returned, which may be used for further volume
18              commands described below.
19
20       hfs zero path nparts
21              The given path is overwritten with a Macintosh partition  struc‐
22              ture which can accommodate up to nparts partitions. All space on
23              the medium is initially allocated to an  empty  partition,  from
24              which  new partitions can be created using hfs mkpart.  The num‐
25              ber of blocks in this empty space available for partitioning  is
26              returned.
27
28       hfs mkpart path nblocks
29              A  new HFS partition is created from the available free space on
30              the specified Macintosh-partitioned  medium.  The  partition  is
31              created  with a size of nblocks.  Any remaining free blocks left
32              in the empty partition space can be further allocated  to  other
33              new  partitions,  as  long  as  there are enough partition slots
34              remaining.
35
36              N.B. When the last remaining partition slot is used, all remain‐
37              ing  free space must be allocated to it. It is therefore best to
38              consider this when initially creating the total number of parti‐
39              tion slots with hfs zero.
40
41       hfs nparts path
42              This command returns the number of HFS partitions which exist on
43              the Macintosh-formatted medium specified by path.  If path  does
44              not  appear  to  have  a Macintosh partition map, or if an error
45              occurs, this command will return -1. Otherwise, it will return a
46              number greater than or equal to 0.
47
48       hfs format path partno vname [bblist]
49              This  command  creates  a new HFS volume by formatting the given
50              path and partition partno and giving it a volume label vname.
51
52              If it is desired to "spare" some blocks from being used  by  the
53              volume,  a list of "bad block" numbers can be given, relative to
54              the beginning of the partition. The given blocks will be  mapped
55              out  of  use  (if possible) and the size of the resulting volume
56              will be decreased.
57
58       hfs flushall
59              All pending changes to all open volumes are flushed immediately.
60              This  is  useful  to do periodically to avoid accidental loss of
61              data when volumes are open for long periods of time.
62
63       hfs chartrans fromset toset string
64              This command translates the given string from the fromset  char‐
65              acter set to the toset set. Both fromset and toset can be one of
66              latin1 (ISO 8859-1) or macroman (MacOS Standard Roman).   A  new
67              (translated) string is returned.
68
69              The  translation  is  not  necessarily reversible, since the two
70              character sets do not have a complete one-to-one mapping.
71
72       hfs version
73              The current running version of hfsutils is returned.
74
75       hfs copyright
76              A copyright notice is returned.
77
78       hfs author
79              The name  and  email  address  of  the  author  of  hfsutils  is
80              returned.
81
82       hfs license
83              A license statement for hfsutils is returned.
84
85       vol vname
86              The  volume  name  of  the given vol handle is returned. This is
87              also the name of the volume's root  directory,  needed  to  con‐
88              struct absolute pathnames on the volume.
89
90       vol size
91              A  list  of two numbers is returned; the first is the total size
92              of the given vol (in bytes), and the second  is  the  number  of
93              free bytes that are currently available.
94
95       vol crdate
96              The  creation  date of the given vol is returned, expressed as a
97              number of seconds since 00:00:00 01-Jan-1970 UTC.
98
99       vol mddate
100              The last  modification  date  of  the  given  vol  is  returned,
101              expressed as a number of seconds since 00:00:00 01-Jan-1970 UTC.
102
103       vol islocked
104              A  boolean value (either 1 or 0) is returned, indicating whether
105              the given vol handle is locked for read-only access. It  may  be
106              locked because the medium is physically locked through hardware,
107              or because the medium was opened read-only for  special  reasons
108              (such as another process also has the medium open).
109
110       vol umount
111              The indicated vol is unmounted, flushing any unsaved data to the
112              volume and closing the access path to the medium. The vol handle
113              subsequently becomes invalid for further use.
114
115       vol cwd
116              A  numeric  value  is  returned  indicating  the catalog node ID
117              (CNID) of the current working directory on the given vol.   This
118              value can be passed to vol dirinfo to learn the directory's name
119              and parent CNID.
120
121       vol path
122              A list of directory names is returned, representing the  hierar‐
123              chy  between the root and the current directory. These names can
124              be joined with vol sepchar characters (:) to construct an  abso‐
125              lute pathname to the current directory.
126
127              The  same  information  can  be acquired by traversing the CNIDs
128              from the current directory to the root using vol dirinfo.   (The
129              root directory always has a CNID of 2.)
130
131       vol dir [path]
132              A  list  is returned describing the contents of the given direc‐
133              tory path (defaulting to the current  directory)  on  the  given
134              vol.  Each element of the list describes one entry, and contains
135              a set of attribute/value  pairs  represented  as  another  list,
136              suitable for assignment to a Tcl array using array set.
137
138       vol flush
139              All pending changes to the given volume are flushed immediately.
140
141       vol sepchar
142              The HFS path separator character ":" is returned.
143
144       vol cd path
145       vol chdir path
146              The  current working directory on the given volume is changed to
147              path, which may be either an absolute or relative path.
148
149       vol dirinfo cnid
150              A two-element list describing the  directory  having  the  given
151              cnid  on  the  given vol is returned. The first element contains
152              the name of the directory, while the second element contains the
153              CNID of the directory's parent. Two CNID values are special: the
154              root directory of the volume has CNID 2, and the "parent" of the
155              root directory is returned with CNID 1.
156
157       vol open path
158              The  file  on  vol  having the given path is opened. An HFS file
159              handle is returned, which may be used for further file  commands
160              described below.
161
162       vol stat path
163              Information about the file or directory having the given path is
164              returned in much the same way as vol dir except  that  only  the
165              single argument is described (not its contents).
166
167       vol mkdir path
168              A  new directory on vol having the given path is created. All of
169              the parent directories leading to path must already  exist,  but
170              path itself must not.
171
172       vol rmdir path
173              The  directory on vol with the given path is removed. The direc‐
174              tory must be empty.
175
176       vol delete path
177              The file on vol with the given path is  removed.  Both  resource
178              and data forks of the file are deleted.
179
180       vol touch path
181              The  modification  time  for  the file or directory specified by
182              path on the given vol is updated to the current time.
183
184       vol glob pattern
185              The given pattern is treated as a  list  of  globbing  patterns,
186              each  of which may be expanded to the names of files or directo‐
187              ries on the given vol according to the globbing rules  described
188              in  the  hfsutils(1) documentation.  The resulting pathnames are
189              returned in a (possibly longer) list.  If  a  pattern  does  not
190              match  any file or directory name, it is returned in the result‐
191              ing list unchanged.
192
193       vol bless path
194              The folder named by the given path is  "blessed"  as  the  MacOS
195              System Folder.  For this to be useful, the folder should contain
196              valid Macintosh System and Finder files.
197
198       vol rename oldpath newpath
199              The existing oldpath on the given vol  is  renamed  to  newpath,
200              possibly  changing  its  location  at  the same time. If newpath
201              already exists, it must be a directory, and the item will simply
202              be  moved  into  it  keeping the same name. (In the latter case,
203              there must not be another file or  directory  already  with  the
204              same  name;  in  no case will another file or directory be over‐
205              written.)
206
207       vol create path type creator
208              A new, empty file is created on vol having the given  path,  and
209              an  HFS  file handle is returned in the same manner as vol open.
210              The file is given the specified MacOS type  and  creator  codes,
211              which must be 4 character strings.
212
213       vol copy srcpath dstvol dstpath
214              The  given  file  srcpath  located  on  vol is copied to dstpath
215              located on dstvol (which may be the same as vol).  The file  and
216              its attributes are copied verbatim; no translation is performed.
217
218       vol copyin mode srcpath dstpath
219              The  specified local (UNIX) srcpath is copied into the given vol
220              as a file having the specified  (HFS)  dstpath.   A  translation
221              mode must be given as one of macbinary, binhex, text, or raw.
222
223       vol copyout mode srcpath dstpath
224              The  specified (HFS) srcpath on the given vol is copied out as a
225              local file having the specified (UNIX) dstpath.   A  translation
226              mode must be given as one of macbinary, binhex, text, or raw.
227
228       file close
229              The  indicated  file  is closed, all pending changes to the file
230              are flushed, and the file handle becomes invalid for any  subse‐
231              quent operation.
232
233       file tell
234              A  numeric  index  is returned indicating the character position
235              within file at which the  next  read  or  write  operation  will
236              occur.
237
238       file stat
239              Information  about  the  given file is returned in much the same
240              way as vol stat.
241
242       file getfork
243              If the given file is currently performing I/O on its data  fork,
244              the  string "data" is returned.  Otherwise, the string "rsrc" is
245              returned. When files are opened, they will default to read/write
246              on  their  data  fork. The current fork may be changed with file
247              setfork.
248
249       file setfork fork
250              The current fork of the given file is set to fork (which must be
251              one  of  data  or  rsrc), and the current read/write position is
252              reset to the beginning of the file.
253
254       file seek pos [from]
255              The character position for the next read or  write  on  file  is
256              changed  to  pos, relative to the indicated from position, which
257              must be one of start, current, or end.  The default is to  posi‐
258              tion relative to the start of the file.
259
260       file read length
261              length  bytes  are  read from the current read/write position in
262              file, and these bytes are returned as a string. This string  may
263              be  shorter  than  length  in some circumstances, or may even be
264              empty, indicating the end of the file has been reached.
265
266       file write string
267              The given string is written to file at  the  current  read/write
268              position.  The  number  of bytes actually written to the file is
269              returned, and may be less than  the  length  of  the  string  in
270              unusual circumstances (such as when the volume is full).
271

SEE ALSO

273       hfsutils(1), hfs(1), tclsh(1)
274

NOTES

276       Precautions  are taken to ensure all open files and mounted volumes are
277       cleanly closed and unmounted before exiting the shell, however abnormal
278       termination (e.g. CTRL-C) can circumvent this, potentially leaving vol‐
279       umes in an inconsistent state. Judicious use of hfs flushall  may  help
280       reduce this risk.
281

BUGS

283       Tcl  does  not  provide  a  mechanism for manipulating arbitrary binary
284       data.  Therefore caution should be used when reading or  writing  files
285       containing anything other than plain text.
286

AUTHOR

288       Robert Leslie <rob@mars.org>
289
290
291
292HFSUTILS                          19-Feb-1998                         HFSSH(1)
Impressum