Home » U++ Library support » FileSel&FileList, Path » FEATURE REQUEST: File listing utility
FEATURE REQUEST: File listing utility [message #43034] |
Fri, 25 April 2014 00:30 |
omari
Messages: 266 Registered: March 2010
|
Experienced Member |
|
|
Hi,
the use of FindFile is heavy, it is convenient to obtain the list of files with a single line of code.
I like to have a function such as:
Vector<String> FindFiles(String path, String mask = "*", bool subfolders = true);
Vector<String> FindFolders(String path, String mask);
and a variant that call a callback for each found file:
void FindFiles(String path, Callback1<String> found, String mask = "*", bool subfolders = true);
her an attemps of implimentation of this three functions:
void FindFiles(String path, Callback1<String> found, String mask, bool subfolders)
{
FindFile ff (path + "/*");
if(ff)
do
{
path = ff.GetPath();
if(ff.IsFolder() && subfolders)
{
FindFiles(path, found, mask, subfolders);
}
else
if(ff.IsFile() && PatternMatch(mask, path))
{
found(path);
}
}while (ff.Next());
}
Vector<String> FindFiles(String path, String mask, bool subfolders)
{
Vector<String> ret;
FindFile ff (path + "/*");
if(ff)
do
{
path = ff.GetPath();
if(ff.IsFolder() && subfolders)
{
Vector<String> tmp = FindFiles(path, mask, true);
ret.Append(tmp) ;
}
else
if(ff.IsFile() && PatternMatch(mask, path))
{
ret.Add() = path;
}
}while (ff.Next());
return ret;
}
Vector<String> FindFolders(String path, String mask)
{
Vector<String> ret;
FindFile ff (path + "/*");
if(ff)
do
{
path = ff.GetPath();
if(ff.IsFolder() && PatternMatch(mask, path))
{
ret.Add() = path;
}
}while (ff.Next());
return ret;
}
regards
omari.
regards
omari.
|
|
|
Goto Forum:
Current Time: Mon Jun 17 07:30:29 CEST 2024
Total time taken to generate the page: 0.02177 seconds
|