Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 is currently offline  omari
Messages: 243
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.
Previous Topic: FileSel file names without quotes
Next Topic: Common Dialog
Goto Forum:
  


Current Time: Thu Oct 28 00:55:29 CEST 2021

Total time taken to generate the page: 0.03148 seconds