Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!ucrmath!alchemy!bbs From: bbs@alchemy.UUCP (BBS Administration) Newsgroups: comp.unix.programmer Subject: File "type" Message-ID: <171@alchemy.UUCP> Date: 23 Sep 90 03:36:58 GMT Reply-To: bbs@alchemy.UUCP (BBS Administration) Organization: Alchemy Software Designs Lines: 32 Could someone explain how the command "file" works? Specifically, I am writing a program that allows users to navigate their $HOME directory and any subdirectories (they cannot leave their $HOME directory though, for security reasons) to find files that are to be read into a text editor. Some text editor forks this program, and when the user selects a file to read, it writes the pathname to a temporary file which the editor reads and then loads into its' buffer. I wrote this "navigator" program as a separate entity, so that either my line based editor (non-curses) or my full screen editor (subset of curses) can call upon it and use its facilities (the navigator does lots of other things too) without giving the user shell access directly. Anyhow, once they select a file for reading, I'd like to be able to determine if the file is "ascii text" as the program "file" reports when this is true, and if not, inform the user that the contents are NOT ascii text and that they may want to reconsider. Should I make a pass through the contents and make sure that each character has the high bit OFF (so it's 7-bit data) or what? I don't need to determine what kind of file it is, just whether or not it's something the editors will "like." Thanks in advance! -- John John Donahue, Senior Partner | UUCP: ucrmath!alchemy!{bbs, gumby} | The Future Alchemy Software Designs | INET: {bbs, gumby}@alchemy.UUCP | Begins Now -------------------+---------+-------------------------------------+----------- Communique On-line | +1-714-243-7150 {3, 12, 24, 96HST} Bps. 8-N-1 | Next Wave: Information System | Alchemy Software Designs Support System | Communique