| 1329 | |
| 1330 | |
| 1331 | static const char *my_get_module_parent(char *buf, size_t size) |
| 1332 | { |
| 1333 | char *last= NULL; |
| 1334 | char *end; |
| 1335 | if (!GetModuleFileName(NULL, buf, (DWORD) size)) |
| 1336 | return NULL; |
| 1337 | end= strend(buf); |
| 1338 | |
| 1339 | /* |
| 1340 | Look for the second-to-last \ in the filename, but hang on |
| 1341 | to a pointer after the last \ in case we're in the root of |
| 1342 | a drive. |
| 1343 | */ |
| 1344 | for ( ; end > buf; end--) |
| 1345 | { |
| 1346 | if (*end == FN_LIBCHAR) |
| 1347 | { |
| 1348 | if (last) |
| 1349 | { |
| 1350 | /* Keep the last '\' as this works both with D:\ and a directory */ |
| 1351 | end[1]= 0; |
| 1352 | break; |
| 1353 | } |
| 1354 | last= end; |
| 1355 | } |
| 1356 | } |
| 1357 | |
| 1358 | return buf; |
| 1359 | } |
| 1360 | #endif /* __WIN__ */ |
| 1361 | |
| 1362 |
no test coverage detected