Directories functions.
Funciones
Set DirFiles(Text dir, Text filPattern, Real toLower, Real casSen)Set DirAll(Text dir, Text filPattern, Real toLower, Real casSen)Real DirUsage(Text dir, Text filPattern, Real casSen)//////////////////////////////////////////////////////////////////////////////
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);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
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);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
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);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// FILE : dir.tol
// AUTHOR : http://www.asolver.com
// PURPOSE : Directories functions.
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
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);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
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);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
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);
//////////////////////////////////////////////////////////////////////////////
Ink.Watercolor construye las páginas del sitio web inkwatercolor.com
2015 asolver.com | Aviso legal | XHTML | Δ Θ Ξ | Creative Commons | Mapa y funciones del sitio