home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / tech / report_a.txt < prev    next >
Text File  |  1987-09-05  |  14KB  |  317 lines

  1. 24-Aug-87 13:38:41-PDT,14289;000000000001
  2. Return-Path: <jww@sdcsvax.ucsd.edu>
  3. Received: from sdcsvax.UCSD.EDU by SUMEX-AIM.STANFORD.EDU with TCP; Mon, 24 Aug 87 13:37:48 PDT
  4. Received: by sdcsvax.UCSD.EDU (5.57/5.0)
  5.     id AA13723 for info-mac@sumex-aim.stanford.edu; Mon, 24 Aug 87 12:35:53 PST
  6. To: comp-sys-mac-digest
  7. Path: sdcsvax!jww
  8. From: jww@sdcsvax.ucsd.edu (Joel West)
  9. Newsgroups: comp.sys.mac.digest
  10. Subject: Remote Macintosh file representation
  11. Message-Id: <3712@sdcsvax.UCSD.EDU>
  12. Date: 24 Aug 87 20:35:51 GMT
  13. Organization: Palomar Software, Inc., Vista, CA
  14. Lines: 300
  15.  
  16.  
  17. For those of you who don't normally follow the INFO-APPLETALK newsgroup,
  18. Apple has made an important proposal that affects all Macintosh programs 
  19. in hetereogeneous computing environments.  A copy of the proposal
  20. is being included for the INFO-MAC archives.
  21.  
  22. Apple proposes two file formats, AppleSingle and AppleDouble, which
  23. represent a file on another file system (e.g. UNIX or MS-DOS) as
  24. either one file, or two files, respectively.  In the two-file mode,
  25. the data fork is in a separate file that should be locally readable.
  26.  
  27. Further comments should be sent to INFO-APPLETALK@ANDREW.CMU.EDU.
  28. If you want to be added to the mailing list, of course, send
  29. mail to INFO-APPLETALK-REQUEST@ANDREW.CMU.EDU.
  30.  
  31.     Joel West  
  32.     Palomar Software, Inc., P.O. Box 2635, Vista, CA  92083
  33.     ihnp4!crash!palomar!joel    joel@palomar.cts.com
  34.  
  35. (Dwayne: you might archive this as APPLEDOUBLE.TXT)
  36.  
  37.  
  38. From andrews@apple.UUCP Sat Aug 22 15:36:51 1987
  39. Path: sdcsvax!ames!aurora!labrea!decwrl!nsc!voder!apple!andrews
  40. From: andrews@apple.UUCP (Richard Andrews)
  41. Newsgroups: comp.protocols.appletalk
  42. Subject: Mac File Representation
  43. Message-ID: <1587@apple.UUCP>
  44. Date: 22 Aug 87 22:36:51 GMT
  45. Reply-To: andrews@apple.UUCP (Richard Andrews)
  46. Distribution: usa
  47. Organization: Apple Computer Inc., Cupertino, USA
  48. Lines: 265
  49.  
  50.  
  51. Here is our first attempt at a proposal for representing Mac files
  52. on other file systems.  Please circulate it freely.  I welcome
  53. comments and suggestions, with the following caveat:
  54.  
  55. PLEASE KEEP YOUR COMMENTS BRIEF AND CONCISE.  I EXPECT A LOT OF
  56. FEEDBACK AND I CAN'T POSSIBLY WADE THROUGH A WHOLE LOT OF MATERIAL.
  57. I CANNOT REPLY TO EVERYONE PERSONALLY.
  58.  
  59. Please send useful comments and suggestions directly to me.  Look to
  60. this bulletin board for further drafts.
  61.  
  62. --------------------------------------------------------------------
  63.  
  64.  
  65.  
  66. AppleSingle and AppleDouble formats for file representation
  67.  
  68.  
  69.  
  70. A Draft Proposal from Apple Computer, Inc.
  71.  
  72. 21 August, 1987
  73.  
  74.  
  75.  
  76. Apple Computer is proposing two standards for representing
  77. Macintosh files on non-Macintosh file systems, with the goal of
  78. preserving all attributes characteristic of Macintosh files
  79. (Finder info, icons, comments) on file systems that do not
  80. support such attributes ("foriegn" file systems).  Experience
  81. seemed to indicate that a single format could not be devised that
  82. would be adequate for all cases, but that with two
  83. closely-related formats most needs could be served.  A secondary
  84. goal in designing these formats was to make them general enough
  85. so that they could be used to represent a file from any file
  86. system on any other file system.
  87.  
  88. Note that this is a draft and is subject to change.
  89.  
  90. The two formats are called AppleSingle and AppleDouble.  In
  91. AppleSingle format, all contents and attributes of a Macintosh
  92. file are kept in a single file on the foriegn file system.  Both
  93. forks, Finder info, icons, etc. are arranged in a single file
  94. with a simple structure.  This format is intended to be used
  95. primarily as a storage format; i.e., for those cases in which the
  96. Macintosh file must be stored on a foriegn file system and later
  97. reconstructed into a true Macintosh file.  
  98.  
  99. For those applications in which the users of the foriegn file
  100. system wish to access and perhaps modify the contents of the
  101. Macintosh file, AppleDouble format would be more appropriate. 
  102. Since most Macintosh applications keep the file "data" in the
  103. data fork, AppleDouble format saves the contents of the data fork
  104. in a separate foriegn file.  All other file attributes are kept
  105. in another file.
  106.  
  107. Specifically, Apple's proposal does not rule out the possibility
  108. of building applications that wish to access and modify
  109. MacSingle-format files.  Nor does it preclude using AppleDouble
  110. format for simple storage of Macintosh files.  We merely present
  111. them as alternatives.
  112.  
  113. The only assumption we have made is that each file system on
  114. which these file formats will be supported allows the creation of
  115. a simple file; an uninterpreted stream of bytes.  We have ruled
  116. out designing a format that relied on the creation of
  117. subdirectories, since some file systems do not support them.
  118.  
  119. Before getting into the discussion of the formats, some terms
  120. will be defined.  The term home file system will be used to
  121. mean the file system for which the file's contents were created. 
  122. A Unix application could create an AppleSingle file that holds a
  123. resource and data fork in which is contained a MacWrite-formatted
  124. document.  The home file system for such a file will be Macintosh
  125. Hierarchical File System (HFS).  In most cases, where a file is
  126. created and used on the same file system, the home file system
  127. will be that system.  An AppleSingle or AppleDouble file is
  128. usually another representation of the file's contents on a
  129. foriegn file system.
  130.  
  131.  
  132. AppleSingle
  133.  
  134. An AppleSingle file contains a header followed by data.  The
  135. header is composed of several fixed fields and a list of entry
  136. descriptors, each pointing to an "entry".  Standard entries that
  137. Apple will define include:  Data Fork, Resource Fork, Real Name
  138. (name in the home file system), Comment, Icon, File Info, etc. 
  139. Each entry would be optional and may or may not appear in the
  140. file.
  141.  
  142.    Header:             Magic Number      (4 bytes)
  143.                        Version Number    (2 bytes)
  144.                        Home File System  (4 bytes, ASCII encoded)
  145.                        Number of entries (2 bytes)
  146.                    /   Entry ID          (2 bytes)
  147.    for each entry: |   Offset            (4 bytes)
  148.                    \   Length            (4 bytes)
  149.  
  150. The "Magic Number" field is modeled after the feature in Unix. 
  151. It is intended to be used in whatever way each foriegn file
  152. system desires to distinguish this file as one in AppleSingle
  153. format.  The Magic Number for AppleSingle format is $00051600 or
  154. 0x00051600.
  155.  
  156. The "Version Number" field is used to denote the version of
  157. AppleSingle format in case the format evolves (perhaps more
  158. fields would be added to the header).  The version described here
  159. is version $0001 or 0x1.
  160.  
  161. The "Home File System" is explained above.  For Macintosh files,
  162. the value of this field is 'mac ' or $6D616320 or 6D616320. 
  163. Others are shown below:
  164.  
  165.      Macintosh    'mac ' or $6D616320 or 0x6D616320
  166.      ProDOS       'pdos' or $70646F73 or 0x70646F73
  167.      MS-DOS       'mdos' or $6D646F73 or 0x6D646F73.
  168.      Unix         'unix' or $756E6978 or 0x756E6978.
  169.  
  170. We welcome suggestions for other file systems that should be
  171. included in this list.
  172.  
  173. The "Number of entries" field tells how many different entries
  174. are included in the file.  It is an unsigned 16-bit number, and
  175. may be zero.  If non-zero, then that number of entry descriptors
  176. will immediately follow this field.
  177.  
  178. For each entry, the entry descriptor indicates just what the
  179. entry is, where the entry is located in the file, and how big the
  180. entry is.  Apple will define a set of Entry IDs and their values:
  181.  
  182.      Data Fork      1 (standard Mac Data Fork)
  183.      Resource Fork  2 (standard Mac Resource Fork)
  184.      Real Name      3 (the file's name in the home file system)
  185.      Comment        4 (standard Mac comment)
  186.      Icon, B&W      5 (standard Mac Black & White Icon)
  187.      Icon, Color    6 (standard Mac color icon)
  188.      File Info      7 (file information)
  189.      Dates          8 (Create, Modification, and Backup dates)
  190.  
  191. Apple reserves the range of Entry IDs from 0 to 32767 ($7FFF or
  192. 0x7FFF) for future use.  Apple will not arbitrate the use of the
  193. rest of the range; these values can be used by other systems to
  194. define their own types of entries.
  195.  
  196. The File Info entry will be different for each home file system. 
  197. For Macintosh HFS, the entry is 32 bytes long and consists of the
  198. standard Finder Info and Extended Finder Info fields.  [To be
  199. defined:  formats for MS-DOS, Unix, and ProDOS, etc.]
  200.  
  201. Icon entries will probably not appear in most files since they
  202. are typically stored as a bundle in the application file's
  203. resource fork.
  204.  
  205. The actual data representing the entry must be in a single
  206. contiguous block.  It is pointed to by the offset field, which is
  207. an unsigned 32-bit number indicating the byte offset from the
  208. start of the file to the start of the entry.  The entry length is
  209. also an unsigned 32-bit number representing the length in bytes. 
  210. The length may be zero.
  211.  
  212. After some number of entry descriptors, the actual entry data
  213. would appear.  The entries could appear in any order, but since
  214. the data fork is the entry that would be most commonly extended,
  215. Apple strongly recommends that the data fork entry always be kept
  216. last in the file to facilitate its extension.
  217.  
  218. It is possible to have holes in the file (unused space between
  219. entries).  To find where the holes are, one must take the list of
  220. entry descriptors and sort them into increasing offset order.  If
  221. the offset field of an entry is greater that the offset plus
  222. length of the previous entry, then a hole exists between the
  223. entries.  This may be used to one's advantage; for example:  if a
  224. file's comment is 10 bytes long, one could create a hole of 190
  225. bytes after the comment field to easily allow for the comment to
  226. later expand to its maximum length of 200 bytes.  Because an
  227. AppleSingle file may contain holes, every entry must be found by
  228. getting its offset from its entry descriptor - not by assuming
  229. that it begins after the previous entry.
  230.  
  231. Byte ordering in the file will follow 68xxx convention.  This is
  232. somewhat of a religious issue, but it was decided that picking
  233. one format was better than adding a flag to the file to indicate
  234. which ordering was being used, so that applications wouldn't have
  235. to have code to handle both cases.
  236.  
  237.  
  238. AppleDouble
  239.  
  240. AppleDouble format is now easily described:  it is the same as
  241. AppleSingle format except that the data fork is kept in a
  242. separate foriegn file.  The file containing the data fork will be
  243. called the AppleDouble Data File, and the other file will be
  244. called the AppleDouble Header File.
  245.  
  246. The AppleDouble Data File consists of just the standard Macintosh
  247. Data Fork with no extra header at all.  The AppleDouble Header
  248. File has exactly the same format as the AppleSingle file, except
  249. that it does not contain a data fork entry.  The Magic Number of
  250. an AppleDouble Header File differs from that of an AppleSingle
  251. file so that applications can tell whether or not they need to
  252. look elsewhere for the data fork.  The Magic Number for
  253. AppleDouble format is $00051607 or 0x00051607.
  254.  
  255. The entries in the Header File could appear in any order, but
  256. since the resource fork (in this case) is the entry that would be
  257. most commonly extended, Apple strongly recommends that the
  258. resource fork entry always be kept last in the file to facilitate
  259. its extension.  The data fork is easily extended since it resides
  260. by itself in the Data File.
  261.  
  262. If it is possible on the foriegn file system, one could create a
  263. new type of entry that "pointed" to the AppleDouble Data File to
  264. make it easy to find.
  265.  
  266. -----------------------
  267.  
  268. AppleSingle format specifically will not include an algorithm for
  269. generating the AppleSingle file name from the "real" Macintosh
  270. name.  This was done because the foriegn file systems of interest
  271. differ quite a bit in the area of file name syntax, and since the 
  272. file's real name can be kept as an entry within the AppleSingle
  273. file.
  274.  
  275. The same is true for AppleDouble Data File names, yet we would
  276. like to propose a standard for deriving the AppleDouble Header
  277. File name from the AppleDouble Data File name.  Again, due to
  278. differing file name syntax, a standard per foriegn file system is
  279. proposed.  For example:
  280.  
  281.    On Unix systems, take the file's real name and by character
  282.    substitution, deletion, or truncation, derive an AppleDouble
  283.    Data File name that is at least one character less than the 
  284.    maximum file name length.  The AppleDouble Header File name
  285.    will be the same as the AppleDouble Data File name with a
  286.    preceding percent sign '%'.
  287.  
  288.    On ProDOS systems, take the file's real name and by character
  289.    substitution, deletion, or truncation, derive an AppleDouble
  290.    Data File name that is at least two characters less than the 
  291.    maximum file name length.  The AppleDouble Header File name
  292.    will be the same as the AppleDouble Data File name with a
  293.    preceding 'R.' (ASCII-R, period).
  294.  
  295.    On MS-DOS systems, take the file's real name and by character
  296.    substitution, deletion, or truncation, derive a name that is
  297.    at most eight characters long.  The AppleDouble Header File
  298.    name will be the derived name plus an extension of '.ADF'
  299.    (AppleDouble File).  The AppleDouble Data File name will be
  300.    the derived name plus whatever extension is most appropriate
  301.    in the MS-DOS world.  If the data fork is pure text (CR, LF)
  302.    the the Data File extension would be '.TXT'.  If the data fork
  303.    conformed to some other standard MS-DOS file format, it would
  304.    be given the appropriate extension.  This would have to be
  305.    decided by whatever application created the AppleDouble files.
  306.  
  307. And so on.  AppleDouble name derivations, to coin a term, would
  308. be defined for all the file systems of interest.  This would
  309. allow applications running on the foriegn file system (and human
  310. users as well) to easily see which files are AppleDouble pairs. 
  311. Knowledgeable users, if they know the derivation, could even
  312. rename the files in such a way so as to preserve the connection
  313. between the two.  There is no way to prevent one file of the pair
  314. from being inconsistently renamed, moved or deleted.
  315.  
  316.  
  317.