TPCCLIB
Loading...
Searching...
No Matches
niftiname.c
Go to the documentation of this file.
1
4/*****************************************************************************/
5#include "tpcclibConfig.h"
6/*****************************************************************************/
7#include "tpcnifti.h"
8/*****************************************************************************/
9
10/*****************************************************************************/
16 char *filename
17) {
18 if(filename==NULL) return;
19 char basename[FILENAME_MAX];
20 strncpyCleanSpaces(basename, filename, FILENAME_MAX);
21 strcpy(filename, "");
22 char *cptr=filenameGetExtension(basename);
23 if(cptr!=NULL) {
24 if(strcasecmp(cptr, ".hdr")==0) *cptr=(char)0;
25 else if(strcasecmp(cptr, ".nii")==0) *cptr=(char)0;
26 else if(strcasecmp(cptr, ".img")==0) *cptr=(char)0;
27 else if(strcasecmp(cptr, ".sif")==0) *cptr=(char)0;
28 else if(strcasecmp(cptr, ".")==0) *cptr=(char)0;
29 }
30 /* Remove also double extensions, e.g. from data.img.hdr */
31 cptr=filenameGetExtension(basename);
32 if(cptr!=NULL) {
33 if(strcasecmp(cptr, ".nii")==0) *cptr=(char)0;
34 else if(strcasecmp(cptr, ".img")==0) *cptr=(char)0;
35 else if(strcasecmp(cptr, ".")==0) *cptr=(char)0;
36 }
37 strcpy(filename, basename);
38 return;
39}
40/*****************************************************************************/
41
42/*****************************************************************************/
char * filenameGetExtension(const char *s)
Get the last extension of a file name.
Definition filename.c:178
void niftiBasename(char *filename)
Definition niftiname.c:14
int strncpyCleanSpaces(char *s1, const char *s2, int maxlen)
Definition stringext.c:265
Header file for libtpcnifti.