Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!decvax!ucbvax!CITHEX.CALTECH.EDU!carl From: carl@CITHEX.CALTECH.EDU.UUCP Newsgroups: mod.computers.vax Subject: Re: File attributes - binary? Message-ID: <870120220430.0a4@CitHex.Caltech.Edu> Date: Wed, 21-Jan-87 01:04:43 EST Article-I.D.: CitHex.870120220430.0a4 Posted: Wed Jan 21 01:04:43 1987 Date-Received: Wed, 21-Jan-87 18:50:52 EST Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet Lines: 28 Approved: info-vax@sri-kl.arpa The routine "stat" in the C run time library fills a structure also called "stat" that contains, among other things, the elements: stat.st_mode: the file "mode", part of which lets you tell if the file's a directory, a terminal, etc. stat.st_fab_rfm: the file's record format (e.g. fixed variable, or stream records, and indexed, relative, or sequential file organization.) stat.st_fab_rat: record attributes (what sort of carriage control is associated with the records of this file, and can records cross block boundaries? Now, "text" files tend to: 1) Not be directories; 2) Have a record format of either variable length or some sort of stream records; 3) Belong to files organized sequentially; 4) Have PRINT, FORTRAN, or IMPLIED (CARRIAGE-RETURN) carriage control attributes, and the blocks are generally allowed to cross block boundaries. Checking these fields in the stat structure will come about as close as you can come to deciding whether you're dealing with a "text" file or a binary file without resorting to something like: 1) Checking a few of the leading records of the file to discover whether they conform to the formats of, say executable, object, or library files; or 2) Running the thing through a dictionary so see if it has may recognizable words in it.