$include (..\lib\compStch.ext) /* *============================================================================ * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE * * Permission to use for any purpose, modify, copy, and make enhancements * and derivative works of the software is granted if attribution is given to * R.M. Gillmore, dba the ACME Software Deli, as the author * * While the ACME Software Deli does not work for money, there is nonetheless * a significant amount of work involved. The ACME Software Deli maintains the * rights to all code written, though it may be used and distributed as long as * the following conditions are maintained. * * 1. The copyright statement at the top of each code block is maintained in * your distribution. * 2. You do not identify yourself as the ACME Software Deli * 3. Any changes made to the software are sent to the ACME Software Deli *============================================================================ */ fileTreeModule: do; $include (..\lib\comnDefs.ext) $if not noID declare IDString (*) byte data ( '@(#)fileTree.p86 $Author: rmgillmore $ $Date:: 2025-05-04 19:35:39#$:', 0 ); $endif $set ( fileTreeSource ) $include (..\lib\fileTree.ext) $include (..\lib\mem.ext) $include (..\lib\dirFunct.ext) $include (..\lib\sysCalls.ext) $include (..\lib\errCode.ext) $include (..\lib\curDir.ext) declare fileTreeObject literally ' structure ( managedDirArray pointer, recursionOn boolean, baseDirectoryName ( MAX_PATH ) char, returnToDirName ( MAX_PATH ) char )'; /* Constructors */ $subtitle ( 'openDirTree() - the Constructor' ) $eject /* ***************************************************************************** * openDirTree() accepts the name of a directory (fully-qualified is NOT * necessary), creates a fileTree "object", stores the fully-qualified name * there, gets the first entry in the directory (storing it as the first * entry), then returns the address of the fileTree "object" ***************************************************************************** */ openDirTree: procedure ( baseDir, fileMask, walkDirTree ) pointer public; declare baseDir pointer, /* the name of the directory */ fileMask pointer, walkDirTree boolean; /* when True, recurse the tree */ declare dirName based baseDir (*) char, fileMaskStr based fileMask (*) char, treeObjectPtr pointer, /* the directory information */ treeObject based treeObjectPtr fileTreeObject, fileTree fileTreeDir; /* * create the treeOject, then capture the current location so that it * can be restored at the end */ treeObjectPtr = malloc( size( treeObject ) ); if ( NULL <> treeObjectPtr ) then do; call getcwd( @treeObject.returnToDirName ); end; return ( treeObjectPtr ); end openDirTree; $subtitle ( 'closeDirTree() - the Destructor' ) $eject /* ***************************************************************************** * closeDirTree() closes all of the records related to the directory noted, * and returns ZERO if all worked well, and NON-ZERO if there was an error ***************************************************************************** */ closeDirTree: procedure ( treeObjectPtr ) integer public; declare treeObjectPtr pointer, /* directory information */ treeObject based treeObjectPtr fileTreeObject, returnCode integer; returnCode = signed( chdir( @treeObject.returnToDirName ) ); returnCode = free( treeObjectPtr ); return ( returnCode ); end closeDirTree; /* Accesssors */ $subtitle ( 'nextDirTreeEntry() - get the next element' ) $eject /* ***************************************************************************** * nextDirTreeEntry() uses the information in the fileTree "object" to * retrieve the next directory entry. It is the information related to that * entry that is returned. If the last entry was already returned, a "no * more entries" notion is returned ***************************************************************************** */ nextDirTreeEntry: procedure ( treeObjectPtr ) pointer public; declare treeObjectPtr pointer, /* directory information */ entryInfoPtr pointer; /* file name, size, attr, etc */ return ( entryInfoPtr ); end nextDirTreeEntry; end fileTreeModule;