tincho 13-03-2024, 23:53
Hola amigos.
Le comparto una función que sirve para averiguar cuando ocupa un directorio, o mejor dicho cuanto es la suma de todos los archivos que contiene.
En realidad son dos funciones una que lista todos los archivos (ScanFiles) y otra que los contabiliza (DirSize).

El primer argumento es obligatorio pues es el directorio a analizar y el segundo, que es booleano indica si se contabilizaran los enlaces simbólicos
Código:
'' <b>RAD Extension.</b><br>
'' Return the directory size in bytes. The first argument is mandatory because it is the directory to be analyzed and the second, which is boolean, indicates whether symbolic links will be counted.
Public Function DirSize(sDir As String, bSymbolic As Boolean) As Long
  Dim a As String[]
  Dim f As String
  Dim z As Long
  a = ScanFiles(sDir,,,, True) 'Esta es la otra función
  For Each f In a
    z = z + Stat2(f)["size"]
  Next
  Return z
End

Código:
'' <b>RAD Extension.</b><br>
'' Return a files list nested in a directory using a find command
Public Function ScanFiles(sPath As String, Optional ext As String[], Optional maxdepth As Integer, Optional sFilter As String, Optional bSymbolic As Boolean) As String[]

  Dim out As New String[]
  Dim t As String
  Dim ex As String
  Dim sTmp As String
  Dim aOut As New String[]
  Dim sType As String
  Dim sMax As String

  If maxdepth > 0 Then
    sMax = " -maxdepth " & CStr(maxdepth)
  Endif

  If bSymbolic Then
    sType = " -type f,l"
  Else
    sType = " -type f"
  Endif

  If Exist(sPath) Then
    If ext Then
      Select ext.Count
          'Case 0
          '  Shell "find '" & sPath & "'" & sMax & sType & " -printf '%p\n' 2>&1" To t
        Case 1
          Shell "find '" & sPath & "'" & sMax & sType & " -name '*.'" & ext[0] & " -printf '%p\n' 2>&1" To t
        Case Else
          ex = "\\( -name \"*."
          ex &= ext.Join("\" -o -name \"*.")
          ex &= "\" \\)"
          Shell "find '" & sPath & "'" & sMax & sType & ex & " -printf '%p\n' 2>&1" To t
      End Select
    Else
      Shell "find '" & sPath & "'" & sMax & sType & " -printf '%p\n' 2>&1" To t
    Endif

    out = Split(t, "\n")

    If out.Count > 0 Then
      If out[out.Max] = "" Then
        out.Remove(out.Max, 1)
      Endif
    Endif

  Endif

  If sFilter <> "" Then
    For Each sTmp In out
      If InStr(sTmp, sFilter) > 0 Then
        aOut.Add(sTmp)
      Endif
    Next
  Else
    aOut = out.Copy()
  Endif

  Return aOut

End
Shordi 13-03-2024, 19:19
... anuncio mi retirada y vuelvo al poco tiempo. La primera vez fue cuando me jubilé y tuve que volver porque sin programar la vida no era vida. La segunda fue cuando me compré una moto un poco harto de hacer programas que a nadie interesaban, ni siquiera a mí mismo.... pero ahora vuelvo otra vez.
¿Por qué?:
Porque necesito programar
Porque no sólo de montar en moto vive un jubilado
Porque veo mensajes en el foro (sí, lo he seguido visitando de vez en cuando) a los que creo que puedo ayudar
Y porque os echaba de menos.

O sea, que héteme aquí otra vez. No prometo gran asiduidad, pero sí constancia... hasta que me vuelva a retirar pa siempre.

Una cervecita para todos
Shell 10-03-2024, 00:57
Buenas!.

Me he dado cuenta de que siendo el mismo tamaño de fuente usado en el editor, si se usa QT o GTK3.
Se vas más grande las letras usando Gtk3 y eso que es la misma tipografía.

Usando Gambas 3.19
Ejemplo:

Con QT5:

[Imagen: ihppBu6.png]

Con Gtk3:

[Imagen: hUdjeXH.png]



Por cierto. ¿ El editor de Gambas no tiene Zoom ?.  Es una característica que posee muchos editores.

Saludos
Páginas (560):    1 96 97 98 99 100 560   
Bienvenido, Invitado
Tienes que registrarte para poder participar en nuestro foro.
Recordarme?
Miembros: 288
Último miembro: shoUsho
Temas del foro: 1,729
Mensajes del foro: 8,985
Últimos temas
Paren...WAIT !!!
Foro: Aplicaciones/Fragmentos de Código
Último mensaje por: guizans, 25-08-2025, 14:49
Respuestas: 3 - Vistas: 397
GambOS
Foro: General
Último mensaje por: guizans, 20-08-2025, 13:58
Respuestas: 0 - Vistas: 268
Gambas y Wayland
Foro: General
Último mensaje por: guizans, 20-08-2025, 13:56
Respuestas: 6 - Vistas: 542
Odio a gb.Report
Foro: General
Último mensaje por: guizans, 19-08-2025, 10:40
Respuestas: 8 - Vistas: 901
Powered By MyBB, © 2002-2025 MyBB Group.
Made with by Curves UI.