[fpc-pascal]re: question about FileGetAttr

Yet Another Geek yetanothergeek at yahoo.com
Thu Jul 11 10:33:34 CEST 2002


>Hello, Everyone
> under /usr/local/, I have a file of information:
> -rw-r--r-- root root aaa.dat
>  so the file belongs to root, and can be read by any
user.
> Then I try to test the file use another user:
milimeter as following
> writeln('File Attr: ',FileGetAttr('aaa.dat'));
> then I get 32, it means it is writable. 
> But actually, it's readonly 

// I think something like this would be better for
Unix-type filesystems:
program permtest;
uses 
  linux;

const
  theFile = '/usr/local/aaa.dat';
begin
  if access(TheFile, R_OK) 
  then WriteLn('You can read this file.')
  else WriteLn('Read permission denied.');

  if access(TheFile, W_OK) 
  then WriteLn('You can modify this file.')
  else WriteLn('Write permission denied.');

  if access(TheFile, X_OK)
  then WriteLn('You can execute this file')
  else WriteLn('Execute permission denied.');

  if access(dirname(TheFile), F_OK) 
  then WriteLn('You can browse this directory')
  else WriteLn('Browsing of ', dirname(TheFile) , ' is
not allowed.');

end.


You can also check out the "linfiles.pas" unit in the
CurlPas project.
It has wrappers around the Linux file-access and
file-type routines,
to make them a little easier to use (at least for me)
http://www.houston.quik.com/jkp/curlpas

Hope this helps...  
 - Jeff


__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com




More information about the fpc-pascal mailing list