// Larry Bush April 26, 2002 // // email : bushl2@rpi.edu // Lawrence_Bush@dps.state.ny.us // // Student ID : 660 220 742 // // File Name : traverse.h // Final Proj. : Grep for Windows // Class : Operating Systems // Instructor : Susan Bonner // Language : C++ // //****************************************************************************************** //****************************************************************************************** //****************************************************************************************** //************* ************** //************* Traverse Object ************** //************* ************** //************* Header File ************** //************* ************** //****************************************************************************************** //****************************************************************************************** //****************************************************************************************** // traverse.h Declares the traverse class, which traverses all the subdirectories of a // given subdirectory. It also uses the buffer class to process each file that // it finds. It performs these tasks on a separate thread from the main program. // The traverse class manages its own thread. In other words, the thread is called // by a member function of the class. This thread is premptable. In other words // the user may stop the grep process in mid stream. The idea behind this is that // the user may have made a mistake and invoked a process that will take a very // long time or possibly have unintended (bad) consequence. The traverse class // also handles this functionality. // // traverse.h: interface for the traverse class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_TRAVERSE_H__A892AC06_6934_41DF_A784_5C8E45F6EEED__INCLUDED_) #define AFX_TRAVERSE_H__A892AC06_6934_41DF_A784_5C8E45F6EEED__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include //#include "buffer.h" // thread stuff typedef unsigned (WINAPI *PBEGINTHREADEX_THREADFUNC) ( LPVOID LPTHREADPARAMETER ); typedef unsigned *PBEGINTHREADEX_THREADID; // end thread stuff class traverse { private: char * mv_currentDirectoryPath; // declare variable to store directory path char * mv_word_to_find;// declare variable to store the word to find char * mv_replacement_word;// declare variable to store the replacement word bool stop;// = 0; // should thread stop? 1=yes public: // Declare public members // funny c++ object thread function declaration static DWORD WINAPI ThreadFunc (LPVOID param); traverse(char * currentDirectoryPath, char * word_to_find, char * replacement_word); virtual ~traverse(); // declare virtual destructor // declare search helper function int DirSearchHelper(char * currentDirectoryPath, char * word_to_find, char * replacement_word); // declare dir or file function void DirectoryOrFile( WIN32_FIND_DATA findData, char * currentDirectoryPath, char * word_to_find, char * replacement_word ); // declare the multithreaded traverse function void multithreaded_traverse(); }; #endif // !defined(AFX_TRAVERSE_H__A892AC06_6934_41DF_A784_5C8E45F6EEED__INCLUDED_)