////////////////////////////////////////////////////////// // Name: MiscFileFunctions.cpp // // // // Description: Contains miscalanious functions for // // dealing with files. // // // // AUTHOR: Lucas Scharf // // Feb 5, 1998 // // // // REVISIONS: None // // // // VERSION: 1.00 // ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// // Compiler Directives // ////////////////////////////////////////////////////////// //-- Standard Libraries -- #include ////////////////////////////////////////////////////////// // FileExists // // // // Description: Checks for the existance of a file // // // // Algorithm: Attempts to open the file // // // // CALLED BY: WebAddressChecker // // // // Parameters: FileName: Data in - An array of chars // // containing the path/filename of the // // file to check for. // // Returns: Nothing // // // // By: Dwight Barentte. Commented and made to fit form // // by Luke Scharf // // // // REVISIONS: None // ////////////////////////////////////////////////////////// bool FileExists(const char FileName[]){ //-- Variable Declarations -- int Failed; ifstream InFile; //-- Check for existance of file InFile.open(FileName,ios::nocreate); //Open file Failed = InFile.fail() ; //Check to see if open was successfull InFile.close() ; //Close file //-- Return Value -- return (!Failed); // }//End FileExists ////////////////////////////////////////////////////////// // ChangeFilenameExtension // // // // Description: Changes the extension of a filename, // // stored in null-terminated string FileName, to // // NewExtension // // // // Algorithm: Step forewards and backwards through // // FileName[]. Copy in NewExtension[]. // // // // CALLED BY: WebAddressChecker // // // // Parameters: FileName[]: Data in & out - A string // // containing the filename whos // // extension will be changed. // // NewExtension[]: Data in - A string // // containing the new extension for // // FileName[]. // // // // REVISIONS: None // ////////////////////////////////////////////////////////// void ChangeFilenameExtension(char FileName[], const char NewExtension[]){ //-- Declare Variables -- int FNIndex=0, //Current position in FileName NEIndex=0; //Current position in NewExtension //-- Move foreward to end of FileName -- while (FileName[FNIndex]) FNIndex++; //-- Move backward to '.' -- while (FileName[FNIndex]!='.') FNIndex--; //-- Copy Chars -- while (NewExtension[NEIndex]){ FileName[FNIndex+NEIndex]=NewExtension[NEIndex]; NEIndex++; }//end while }//End ChangeFilenameExtension