| 45 | #endif |
| 46 | |
| 47 | char* AddFileSuffix ( const char * Filename, const char * Suffix ) { |
| 48 | char *pszFullname, *pszBasename; |
| 49 | int i; |
| 50 | |
| 51 | /* -------------------------------------------------------------------- */ |
| 52 | /* Compute the base (layer) name. If there is any extension */ |
| 53 | /* on the passed in filename we will strip it off. */ |
| 54 | /* -------------------------------------------------------------------- */ |
| 55 | pszBasename = (char *) msSmallMalloc(strlen(Filename)+5); |
| 56 | strcpy( pszBasename, Filename ); |
| 57 | for( i = strlen(pszBasename)-1; |
| 58 | i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/' |
| 59 | && pszBasename[i] != '\\'; |
| 60 | i-- ) {} |
| 61 | |
| 62 | if( pszBasename[i] == '.' ) |
| 63 | pszBasename[i] = '\0'; |
| 64 | |
| 65 | /* -------------------------------------------------------------------- */ |
| 66 | /* Open the .shp and .shx files. Note that files pulled from */ |
| 67 | /* a PC to Unix with upper case filenames won't work! */ |
| 68 | /* -------------------------------------------------------------------- */ |
| 69 | pszFullname = (char *) msSmallMalloc(strlen(pszBasename) + 5); |
| 70 | sprintf( pszFullname, "%s%s", pszBasename, Suffix); |
| 71 | |
| 72 | return (pszFullname); |
| 73 | } |
| 74 | |
| 75 | |
| 76 | int main( int argc, char ** argv ) |