[Gambas-user] Stat class (gb)

Tobias Boege taboege at gmail.com
Fri Jun 8 12:58:10 CEST 2018


On Fri, 08 Jun 2018, Hans Lehmann wrote:
> Hello,
> 
> I have a question about the Stat class (gb).
> 
> I use:
> 
> Dim FileInfo As Stat
> 
> FileInfo = Stat(sFilePath)
> 
> Print Stat(sFilePath).Auth     --->   rwxrw-r--
> Print Stat(sFilePath) mode     --->   500
> 
> How is the result 500 to be evaluated?
> Which property of a file is characterized by .mode?
> 

It is the same as .Auth actually. Stat.Mode is the numerical value
of the file mode bits, while Stat.Auth is their human-readable form [1].
Printing Auth.Mode gives you the numerical value in decimal form (as is
always the case when you print an integer in Gambas) but you might be
more familiar with the *octal* representation of that same number:

  Print Oct(Stat(sFilePath).Mode)
  764 ' decimal 500 = octal 764

and as explained in [1], 764 stands for:

  7: read+write+execute permissions for owner  rwx
  6: read+write permissions for group          rw-
  4: read permission for others                r--

Regards,
Tobi

[1] https://en.wikipedia.org/wiki/File_system_permissions#Notation_of_traditional_Unix_permissions

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


More information about the User mailing list