Author: Cinly OOI (---.medschl.cam.ac.uk)
Date: 04-28-09 10:25
Dear Rick
my $0.02:
Can I suggest encapsulating the system into a function, say switchFilename(filename, level). All other functions that you mention will call this function to perform the necessary conversions.
For example
In quasi pseudocode:
#define FILENAME_VARIATION_END 100
/**
* switch the filename, according to the 'level'
* \param myfilename On input, the filename
* must be large enough to
* accommodate the variation requirested.
* Recommend length(filename) +7 to satisfy
* all possible variation. On output, will
* contain the filename that staistfy the level
* \param level the variation required
* [0, FILENAME_VARIATION_END)
* \return myfilename
*/
char* switchFilename(char *myfilename, int level) {
if(level==0) return myfilename;
/* don't want any modification */
/* strip all extesions */
stripExtension(myfilename);
if(level==1) return myfilename.NII
if(level==2) return myfilename.HDR
if(level==3) return myfilename.IMG
....
}
FILE* fp = open(myfilename);
myfile.NII will find any of myfile.NII, myfile.HDR,
myfile.IMG or .GZ versions, in that order.
The idea is (1) future modification will be centralized in one place, (2) other people can change the definition of this function to customize the library to cope with different file systems in the future, (3) [important to me] Using (2) I can choose to disable the system.
|
|