chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Lstat problems


From: Ed Watkeys
Subject: Re: [Chicken-users] Lstat problems
Date: Wed, 20 Apr 2005 13:23:15 -0400

Matt,

Try this:

(define file-ltype
  (foreign-lambda* int ((c-string filename)) "
    struct stat sb;
    if(lstat(filename, &sb) == -1)
      return (-1);
    else
      return (sb.st_mode & S_IFMT);"))

Lstat does not allocate memory, so you need to allocate the struct -- on the stack, in this case. I also changed your code to return -1 if there's an error and removed the unnecessary variables.

Regards,
Ed





reply via email to

[Prev in Thread] Current Thread [Next in Thread]