Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!blars!blarson From: blarson@blars Newsgroups: comp.os.os9 Subject: Re: Need help w/directories under C Message-ID: <146@blars> Date: 17 Dec 90 06:41:17 GMT References: <0bOkkiu00WB6QLT0M4@andrew.cmu.edu> Sender: news@usc Lines: 25 Nntp-Posting-Host: dianne.usc.edu Originator: blarson@dianne.usc.edu In article <0bOkkiu00WB6QLT0M4@andrew.cmu.edu> rh2y+@andrew.cmu.edu (Russell E. Hoffman, II) writes: >I am writing a utility program in C, and part of it requires grabbing >the directory stuff for a particular file (i.e. the size of the file, >date of creation, etc.) > >I am presently using the opendir() and readdir() routines to read in the >filenames, and then i do an open() on an individual file to get a path >to it, then a _gs_gfd() to get its file descriptor. This works fine, >unless the particular file happens to itself be a directory. When the open(file, 0) fails, do an open(file, S_IFDIR) . Then do the _gs_gfd() as normal. Alternatibly, if you run by the superuser (or your program is setuid superuser) you could open the raw disk and read the file descriptor directly. This would be less overhead, but very os9 specific. -- blarson@usc.edu C news and rn for os9/68k! -- Bob Larson (blars) blarson@usc.edu usc!blarson Hiding differences does not make them go away. Accepting differences makes them unimportant.