Digital Signal Processing LibraryVoice LabProgram name: file_ext Language: C In file: file_lib.c Objective: Create an output filename given: filename directory, filename basename, and filename extension. Usage: void file_ext(char *out_name, char *directory, char *base_name, char *extension); Parameters:
Mathematical Description: Comments: Routine used to create out_name from directory name, basename and extension Code: void file_ext(char *out_name, char *directory, char *base_name, char *extension) { int i, j; int upper_case; char buffer[20]; upper_case = isupper(base_name[2]); j = strlen(extension); /* ** Convert extension to proper case (upper or lower) ** according to the rest of the filename */ if(upper_case == 0) { for(i = 0; i <= j; i++) { buffer[i] = tolower(extension[i]); } } else { for(i = 0; i <= j; i++) { buffer[i] = toupper(extension[i]); } } /* copy directory name to output_name */ strcpy(out_name, directory); /* add base name to output_name */ strcat(out_name, base_name); /* add extension to output_name */ strcat(out_name, buffer); } |
English Version > Documents and tutorials > D.Sc. projects > Routines for DSP > file_lib >