#include "fileops.h" #include #include #include //CheckNumReviews // //This function tests the value of the Number of reviews read //in from the category file // //This funciton checks to ensure that the number of reviews //is not a negative number // //called by: verifyVRS //calls: None // //Params: integer number read from .vrs file // //Author: Tim McGaughey // //Revisions: None // //Version: 1.0 // // int CheckNumReviews(int negtest) { if (negtest < 0) return 1; return 0; } //Fexists // //This function checks the existance of a file before it //attempts to open it // //called by: VerifyVRS // VerifyMOV //calls: None // //Params: None // //Author: N D Barnette? // //Revisions: ?? // //Version: ?? // // int Fexists(char fname[]) { int failed; ifstream infile (fname,ios::nocreate); failed = infile.fail(); infile.close(); return (!failed); } //CheckStarRating // //This function checks the validity of the star rating //read in from the .mov file // //This funciton tests the value of the star rating by ensuring //first that it falls within the prescribed range of values, //then checks that it is a multiple of 0.5 // //called by: VerifyMOV //calls: None // //Params: rating // //Author: Glenn Rioux // //Revisions: None // //Version: 1.0 // // int CheckStarRating (float rating) { if ((rating >= 0.0) && (rating <= 5.0)) { rating *= 2; if ( ((int)(rating * 10)) == ((int)(rating)) * 10 ) { return 0; } } return 1; } //CheckExtension // //This function tests for the proper file extension in a //string of characters // //This funciton uses the strstr() function from the ctype.h //standard library // //called by: VerifyVRS // VerifyMOV //calls: strstr // strcpy // //Params: None // //Author: Glenn Rioux // //Revisions: None // //Version: 2.0 // // Boolean CheckExtension(const char someLine[], const char somefileExtension[]) { char stringLine[55]; char fileExtension[5]; char * testPtr = NULL; strcpy (stringLine,someLine); strcpy (fileExtension, somefileExtension); for (int index=0;index<(abs(strlen(stringLine)));index++) stringLine[index]=toupper(stringLine[index]); for (index=0;index<(abs(strlen(fileExtension)));index++) fileExtension[index]=toupper(fileExtension[index]); if(strlen(stringLine) < 5) return FALSE; testPtr = stringLine+(abs(strlen(stringLine))-4); if(strstr(testPtr, fileExtension)) { return TRUE; } else { return FALSE; } }