Manlio Perillo | 14 Jan 15:00
Favicon

about System.Posix.Files.fileAccess

Hi.

This is of course a personal opinion, but I think the interface of:
fileAccess :: FilePath -> Bool -> Bool -> Bool -> IO Bool
http://haskell.org/ghc/docs/latest/html/libraries/unix/System-Posix-Files.html#v:fileAccess

is not very good.

Is it possible to design (in theory) a better interface?

Thanks  Manlio Perillo
Don Stewart | 14 Jan 22:47
Gravatar

Re: about System.Posix.Files.fileAccess

manlio_perillo:
> Hi.
> 
> This is of course a personal opinion, but I think the interface of:
> fileAccess :: FilePath -> Bool -> Bool -> Bool -> IO Bool
> http://haskell.org/ghc/docs/latest/html/libraries/unix/System-Posix-Files.html#v:fileAccess
> 
> is not very good.
> 
> Is it possible to design (in theory) a better interface?
> 

It is possible (in theory) to design a better interface. :)

--   Don
Favicon

Re: about System.Posix.Files.fileAccess

On 2009 Jan 14, at 9:02, Manlio Perillo wrote:
> This is of course a personal opinion, but I think the interface of:
> fileAccess :: FilePath -> Bool -> Bool -> Bool -> IO Bool
> http://haskell.org/ghc/docs/latest/html/libraries/unix/System-Posix-Files.html#v 
> :fileAccess
>
> is not very good.

The underlying system call access() is strongly disrecommended, so  
it's not really worth a better interface.

--

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery <at> kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery <at> ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH
Manlio Perillo | 15 Jan 11:57
Favicon

Re: about System.Posix.Files.fileAccess

Brandon S. Allbery KF8NH ha scritto:
> On 2009 Jan 14, at 9:02, Manlio Perillo wrote:
>> This is of course a personal opinion, but I think the interface of:
>> fileAccess :: FilePath -> Bool -> Bool -> Bool -> IO Bool
>>
http://haskell.org/ghc/docs/latest/html/libraries/unix/System-Posix-Files.html#v:fileAccess 
>>
>>
>> is not very good.
> 
> 
> The underlying system call access() is strongly disrecommended, so it's 
> not really worth a better interface.
> 

I can't see problems with access function.

Of course it is a problem if used incorrectly:

if (access("foo", F_OK) {
     fd = open("foo", ...)
}

Manlio Perillo
Favicon

Re: about System.Posix.Files.fileAccess

On 2009 Jan 15, at 5:57, Manlio Perillo wrote:
> Brandon S. Allbery KF8NH ha scritto:
>> On 2009 Jan 14, at 9:02, Manlio Perillo wrote:
>>> This is of course a personal opinion, but I think the interface of:
>>> fileAccess :: FilePath -> Bool -> Bool -> Bool -> IO Bool
>>> http://haskell.org/ghc/docs/latest/html/libraries/unix/System-Posix-Files.html#v 
>>> :fileAccess
>>>
>>> is not very good.
>> The underlying system call access() is strongly disrecommended, so  
>> it's not really worth a better interface.
>
> I can't see problems with access function.
>
> Of course it is a problem if used incorrectly:
>
> if (access("foo", F_OK) {
>    fd = open("foo", ...)
> }

The problem is there are very few uses of access() which are safe and  
not already covered better by stat() (getFileStatus).

--

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery <at> kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery <at> ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH

Gmane