Secciones de la página

Funciones de directorios dir. tol

Funciones

Real DirUsage()

Set DirAll()

Set DirExtAll()

Set DirFiles()

Text DirReadFiles()

Tol

Artículos del sitio

Presentación de Tol

Todos los programas

Simuladores visuales

Sitios que me gustan

Por categorías

Algoritmia

Búsqueda y ordenación

Computación fisiológica

Editorial y edición

Gráficos de datos

Herramientas y utilidades

Hipertexto

Informática forense

Lectura óptica de datos

Metaprogramación

No determinista

Ofimática

Recursión e iteración

Reglas y restricciones

Series y estadística









Funciones de directorios dir.tol

Funciones de manejo de directorios declaradas en ficheros de nombre dir.tol.

Las funciones de esta página están ordenadas de forma alfabética por las diferentes gramáticas del lenguaje Tol ( Text, Set, Serie, Anything, Code, Date, Real,...) y, dentro de cada gramática, por el nombre de la función. Pueden encontrarse 2 o más funciones con idéntico nombre, pero con distintas maneras de programarse o con diferentes comentarios en diferentes idiomas, estas funciones aparecerán unas a continuación de las otras.

Real DirUsage() de Ink.Watercolor

//////////////////////////////////////////////////////////////////////////////
Real DirUsage(Text dir,        // Directory path
              Text filPattern, // File names pattern
              Real casSen)     // If true case sensitive in file names
//////////////////////////////////////////////////////////////////////////////
{
  Set  filSet = DirAll(dir, filPattern, FALSE, casSen);
  If(EQ(Card(filSet),0), 0, SetSum(EvalSet(filSet, FileBytes)))
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns the sum in bytes of the size of the set of files inside dir and all
of its subdirectories that theirs names match with filPattern.
Example, usage in bytes of all gif files inside a web directory at any level:
  Real gifSiz = DirUsage(<web>,<*.gif>, FALSE);",
DirUsage);
//////////////////////////////////////////////////////////////////////////////

Set DirAll() de Ink.Watercolor

//////////////////////////////////////////////////////////////////////////////
Set DirAll(Text dir,        // Directory path
           Text filPattern, // File names pattern
           Real toLower,    // If true all names to lower case
           Real casSen)     // If true case sensitive in file names
//////////////////////////////////////////////////////////////////////////////
{
  If(Not(DirExist(dir)), Empty,
  {
    Set  getDir = GetDir(dir);
    Set  filSet = getDir[1];
    Set  dirSet = getDir[2];

    Set  filFnd = EvalSet(filSet, Text(Text fil)
    {
      If(TextMatch(fil,filPattern,casSen),
         If(toLower, ToLower(dir+"/"+fil), dir+"/"+fil),
         "")
    });

    Set filSel = Select(filFnd, Real(Text fil) { fil!="" });

    Set  dirFnd = EvalSet(dirSet, Set(Text subDir)
      { DirAll(dir+"/"+subDir, filPattern, toLower, casSen) });

    Real dirCar   = Card(dirFnd);
    If(EQ(dirCar,0), filSel,
    If(EQ(dirCar,1), filSel<<dirFnd[1],
                     filSel<<BinGroup("+",dirFnd)))
  })
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a set of files paths with all the files inside dir and all of its
subdirectories that theirs names match with file pattern filPattern.
If toLower is true all names are change to lower case.
If casSen is true then the match is case sensitive.
The power of pattern matching is the same than TOL funcion TextMatch().",
DirAll);
//////////////////////////////////////////////////////////////////////////////

Set DirExtAll() de ChRules.Iterative

//////////////////////////////////////////////////////////////////////////////
Set DirExtAll(Text dirPth, // Directory path
              Text chkExt, // File extension
              Real toLowe, // If true all paths are changed to lower case
              Real casSen) // If true the extension match is case sensitive
//////////////////////////////////////////////////////////////////////////////
{
  If(Not(DirExist(dirPth)), Empty,
  {
    Set  getDir = GetDir(dirPth);
    Set  filSet = getDir[1];
    Set  dirSet = getDir[2];

    Set  filFnd = EvalSet(filSet, Text(Text filNam)
    {
      If(!FilCheckExtension(filNam, chkExt, casSen), "",
         If(toLowe, ToLower(dirPth+"/"+filNam), dirPth+"/"+filNam))
    });

    Set filSel = Select(filFnd, Real(Text filNam) { filNam != "" });

    Set  dirFnd = EvalSet(dirSet, Set(Text subDir)
      { DirExtAll(dirPth+"/"+subDir, chkExt, toLowe, casSen) });

    Real dirCar = Card(dirFnd);
    
    If(EQ(dirCar,0), filSel,
    If(EQ(dirCar,1), filSel << dirFnd[1],
                     filSel << BinGroup("+", dirFnd)))
  })
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a set of relative paths of files with the extension chkExt that
are inside the directory dirPth and inside all of its directories.
If toLowe then all names are changed to lower case.
If casSen then are case sensitive in the extension match.
Is a version of DirAll() function that only check extensions and not uses
TextMatch() that writes warnings at Tol 2.0.1.",
DirExtAll);
//////////////////////////////////////////////////////////////////////////////

Set DirFiles() de Ink.Watercolor

//////////////////////////////////////////////////////////////////////////////
Set DirFiles(Text dir,        // Directory path
             Text filPattern, // File names pattern
             Real toLower,    // If true all names to lower case
             Real casSen)     // If true case sensitive in file names
//////////////////////////////////////////////////////////////////////////////
{
  If(Not(DirExist(dir)), Empty,
  {
    Set  getDir = GetDir(dir);
    Set  filSet = getDir[1];

    Set  filFnd = EvalSet(filSet, Text(Text fil)
    {
      If(TextMatch(fil,filPattern,casSen),
         If(toLower, ToLower(dir+"/"+fil), dir+"/"+fil),
         "")
    });

    Set filSel = Select(filFnd, Real(Text fil) { fil!="" });

    filSel
  })
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a set of files paths with all the files inside dir (not in its
subdirectories) that theirs names match with file pattern filPattern.
If toLower is true all names are change to lower case.
If casSen is true then the match is case sensitive.
The power of pattern matching is the same than TOL funcion TextMatch().",
DirFiles);
//////////////////////////////////////////////////////////////////////////////

Text DirReadFiles() de Ediciones.aContracorriente

//////////////////////////////////////////////////////////////////////////////
Text DirReadFiles(Text dirPth, // Directory path
                  Text chkExt, // File extension
                  Text filSep) // File separator
//////////////////////////////////////////////////////////////////////////////
{
  Set pthSet = DirExtAll(dirPth, chkExt, FALSE, TRUE);
  Set txtSet = EvalSet(pthSet, Text(Text filPth) { ReadFile(filPth) });
  Set2Txt(txtSet, "", "", filSep, filSep, "", "", "", "")
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns as a text the contents of all files in dirPth that theirs file names
match with file pattern filPat.
In this text, the contenst of each file will be separated with filSep.",
DirReadFiles);
//////////////////////////////////////////////////////////////////////////////

2015 asolver.com | Aviso legal | XHTML | Δ Θ Ξ | Creative Commons | Mapa y funciones del sitio

Tol