[comp.sys.mac.programmer] Think C Unix library missing stat call

local%cirrusl@oliveb.ATC.olivetti.com (local user(me)) (02/15/91)

I was recently trying to port a Unix program ('patch', actually)
to Think C, and discovered then that the Unix library doesn't emulate either
the 'stat' routine or the 'access' routine, both of which are extremely
 common in Unix programs. I realize that there are ways of doing these things
with Mac system calls, but if I wanted to rewrite the whole program I wouldn't
be using the ANSI/unix libraries anyway. Does anyone know of a more complete 
set of emulated Unix calls for Think C?

Failing that, has anyone seen anything like Larry Wall's 'patch' program 
for the Mac? For those who don't know, it reads difference files and
merges the differences in the original programs.

-- Brian
--
Brian Feinberg <brian%cirrusl@oliveb.ATC.olivetti.com>
UUCP:  oliveb!cirrusl!brian

beard@ux5.lbl.gov (Patrick C Beard) (04/24/91)

In article <2949@cirrusl.UUCP> local%cirrusl@oliveb.ATC.olivetti.com (local user(me)) writes:
#I was recently trying to port a Unix program ('patch', actually)
#to Think C, and discovered then that the Unix library doesn't emulate either
#the 'stat' routine or the 'access' routine, both of which are extremely
# common in Unix programs. I realize that there are ways of doing these things
#with Mac system calls, but if I wanted to rewrite the whole program I wouldn't
#be using the ANSI/unix libraries anyway. Does anyone know of a more complete 
#set of emulated Unix calls for Think C?

I've encountered this when porting unix code myself.  See what is needed
in the stat call.  In almost every case the information sought after has been
the logical length of the file.  This is something you can get with lseek
(which is  a unix call).  I'm not sure what else stat returns, but it shouldn't
be hard to write your own version of the call that uses lseek to get the size,
and some other call to fill in the rest.

--
//  Patrick C. Beard, Software Engineer, Berkeley Systems, Inc.
//                    "Heroes of technology."
//   beard@lbl.gov, d0346@applelink.apple.com (ATTN: Patrick)