back to io 

wxDirTraverser

generated from ../src/mod_io/dirtrav.cpp

wxDirTraverser can be used to traverse into directories to retrieve filenames and subdirectories.

See also wxDir

The following example counts all subdirectories of the temporary directory. Counting the direct subdirectories of temp is possible by returning IGNORE in onDir.


  var dir = new wxDir("c:\\temp");
  var trav = new wxDirTraverser();
  subdir = 0; // Don't use var, it doesn't seem to work with closures
  
  trav.onDir = function(filename)
  {
    subdir = subdir + 1;
    return wxDirTraverser.CONTINUE;
  }
 
  dir.traverse(trav);

  wxMessageBox("Number of subdirectories: " + subdir);
  

Constants

wxDirTraverseResult

Name Description
IGNORE
STOP
CONTINUE

Constructor

wxDirTraverser

wxDirTraverser()
 

Constructs a new wxDirTraverser object.

Properties

Name Type Description
onDir Function Function which will be called for each directory. The function gets a directoryname and should return a constant wxDirTraverseResult. It may return STOP to abort traversing completely, IGNORE to skip this directory but continue with others or CONTINUE to enumerate all files and subdirectories in this directory. When no function is set, it will return CONTINUE. This makes it possible to enumerate all files.
onFile Function Function which will be called for each file. The function gets a filename and should return a constant wxDirTraverseResult except for IGNORE. When no function is set, it will return CONTINUE. This makes it possible to enumerate the subdirectories.


SourceForge.net Logo Support This Project

Table of Contents

Constructor

wxDirTraverser

Properties

onDir
onFile


Design downloaded from Zeroweb.org: Free website templates, layouts, and tools.