--------------------------------------------------------------------------- Return file base name stripping out preceding path and trailing suffix.
| 115 | //--------------------------------------------------------------------------- |
| 116 | // Return file base name stripping out preceding path and trailing suffix. |
| 117 | int getFileBaseName( const char *filepath, char *base, char *suffix ) |
| 118 | { |
| 119 | int i=0,j=0,end=0; |
| 120 | |
| 121 | if ( suffix != NULL ) |
| 122 | { |
| 123 | suffix[0] = 0; |
| 124 | } |
| 125 | if ( filepath == NULL ) |
| 126 | { |
| 127 | base[0] = 0; |
| 128 | return 0; |
| 129 | } |
| 130 | i=0; j=0; |
| 131 | while ( filepath[i] != 0 ) |
| 132 | { |
| 133 | if ( (filepath[i] == '/') || (filepath[i] == '\\') ) |
| 134 | { |
| 135 | j = i+1; |
| 136 | } |
| 137 | i++; |
| 138 | } |
| 139 | i = j; |
| 140 | |
| 141 | j=0; |
| 142 | while ( filepath[i] != 0 ) |
| 143 | { |
| 144 | base[j] = filepath[i]; i++; j++; |
| 145 | } |
| 146 | base[j] = 0; end=j; |
| 147 | |
| 148 | while ( j > 1 ) |
| 149 | { |
| 150 | j--; |
| 151 | if ( base[j] == '.' ) |
| 152 | { |
| 153 | if ( suffix != NULL ) |
| 154 | { |
| 155 | strcpy( suffix, &base[j] ); |
| 156 | } |
| 157 | end=j; base[j] = 0; break; |
| 158 | } |
| 159 | } |
| 160 | return end; |
| 161 | } |
| 162 | //--------------------------------------------------------------------------- |
| 163 | int parseFilepath( const char *filepath, std::string *dir, std::string *base, std::string *suffix ) |
| 164 | { |
no outgoing calls
no test coverage detected