| 1177 | //------------------------------------------------------------------------------ |
| 1178 | |
| 1179 | StringTableEntry getModNameFromPath(const char *path) |
| 1180 | { |
| 1181 | if(path == NULL || *path == 0) |
| 1182 | return NULL; |
| 1183 | |
| 1184 | char buf[1024]; |
| 1185 | buf[0] = 0; |
| 1186 | |
| 1187 | if(path[0] == '/' || path[1] == ':') |
| 1188 | { |
| 1189 | // It's an absolute path |
| 1190 | const StringTableEntry exePath = Platform::getMainDotCsDir(); |
| 1191 | U32 len = dStrlen(exePath); |
| 1192 | if(dStrnicmp(exePath, path, len) == 0) |
| 1193 | { |
| 1194 | const char *ptr = path + len + 1; |
| 1195 | const char *slash = dStrchr(ptr, '/'); |
| 1196 | if(slash) |
| 1197 | { |
| 1198 | dStrncpy(buf, ptr, slash - ptr); |
| 1199 | buf[slash - ptr] = 0; |
| 1200 | } |
| 1201 | else |
| 1202 | return NULL; |
| 1203 | } |
| 1204 | else |
| 1205 | return NULL; |
| 1206 | } |
| 1207 | else |
| 1208 | { |
| 1209 | const char *slash = dStrchr(path, '/'); |
| 1210 | if(slash) |
| 1211 | { |
| 1212 | dStrncpy(buf, path, slash - path); |
| 1213 | buf[slash - path] = 0; |
| 1214 | } |
| 1215 | else |
| 1216 | return NULL; |
| 1217 | } |
| 1218 | |
| 1219 | return StringTable->insert(buf); |
| 1220 | } |
| 1221 | |
| 1222 | //----------------------------------------------------------------------------- |
| 1223 | |