Comunidad Gambas-es
Extendiendo la clase File - Stat - Versión para impresión

+- Comunidad Gambas-es (https://gambas-es.org)
+-- Foro: Gambas (https://gambas-es.org/forumdisplay.php?fid=3)
+--- Foro: Controles/Librerías/Componentes (https://gambas-es.org/forumdisplay.php?fid=7)
+--- Tema: Extendiendo la clase File - Stat (/showthread.php?tid=335)



Extendiendo la clase File - Stat - tincho - 15-04-2021

Hola a todos.
De forma análoga al tema titulado Extendiendo la clase String aprovechare para compartir con ustedes algunas funciones que he ido haciendo y que a mi me resultaron útiles. He aquí la primera de ellas:
GAMBAS
  1. Library "libc:6"
  2.  
  3.   st_dev As Long
  4.   st_ino As Long
  5.   st_nlink As Long
  6.   st_mode As Integer
  7.   st_uid As Integer
  8.   st_gid As Integer
  9.   __pad0 As Integer
  10.   st_rdev As Long
  11.   st_size As Long
  12.   st_blksize As Long
  13.   st_blocks As Long
  14.   st_atime As Long
  15.   st_atimensec As Long
  16.   st_mtime As Long
  17.   st_mtimensec As Long
  18.   st_ctime As Long
  19.   st_ctimensec As Long
  20.   __glibc_reserved[3] As Long
  21.  
  22. Private Const _STAT_VER_LINUX As Integer = 1
  23. Private Extern __xstat(_STAT_VER As Integer, __path As String, __statbuf As Stat_) As Integer
  24.  
  25. '' <b>RAD Extension.</b><br>
  26. '' Create a file parameters list using the GNU coreutils program stat. Note: the tags for access to the information are:<br>
  27. '' Dev, Ino, Path, Link, Mode, SetUID, SetGID, Rdev, Size, BlkSize, Blocks, LastAccess, LastModified, LastChange<br>
  28. '' Original <https://www.gambas-it.org/wiki/index.php?title=Stat_()>
  29.  
  30.  
  31.   Dim st As New Stat_
  32.  
  33.   i = __xstat(_STAT_VER_LINUX, f, st)
  34.   If i < 0 Then Error.Raise("Function error '__xstat()' !")
  35.  
  36.   With st
  37.     inf.Add(.st_dev, "Dev")
  38.     inf.Add(.st_ino, "Ino")
  39.     inf.Add(f, "Path")
  40.     inf.Add(.st_nlink, "Link")
  41.     inf.Add(.st_mode, "Mode")
  42.     inf.Add(.st_uid, "SetUID")
  43.     inf.Add(.st_gid, "SetGID")
  44.     inf.Add(.st_rdev, "Rdev")
  45.     inf.Add(.st_size, "Size")
  46.     inf.Add(.st_blksize, "BlkSize")
  47.     inf.Add(.st_blocks, "Blocks")
  48.     inf.Add(.st_atime, "LastAccess")
  49.     inf.Add(.st_mtime, "LastModified")
  50.     inf.Add(.st_ctime, "LastChange")
  51.  
  52.   Return inf
  53.  


Nota: Esta función no hubiese sido posible sin el articulo que Vuott publico en la wiki el foro italiano.
Saludos.