------------------------------------------------------------------------------
| 1363 | |
| 1364 | //------------------------------------------------------------------------------ |
| 1365 | void vtkEnSightWriter::ComputeNames() |
| 1366 | { |
| 1367 | if (this->Path && this->BaseName) |
| 1368 | { |
| 1369 | return; |
| 1370 | } |
| 1371 | |
| 1372 | if (!this->FileName) |
| 1373 | { |
| 1374 | this->DefaultNames(); |
| 1375 | return; |
| 1376 | } |
| 1377 | |
| 1378 | // FileName = Path/BaseName.digits.digits |
| 1379 | |
| 1380 | char* path = nullptr; |
| 1381 | char* base = nullptr; |
| 1382 | |
| 1383 | char* f = this->FileName; |
| 1384 | |
| 1385 | while (!isgraph(*f)) |
| 1386 | f++; // find first printable character |
| 1387 | |
| 1388 | if (!*f) |
| 1389 | { |
| 1390 | // FileName is garbage |
| 1391 | DefaultNames(); |
| 1392 | return; |
| 1393 | } |
| 1394 | |
| 1395 | char* buf = new char[strlen(f) + 1]; |
| 1396 | strcpy(buf, f); |
| 1397 | |
| 1398 | char* slash = strrchr(buf, '/'); // final slash |
| 1399 | |
| 1400 | if (slash) |
| 1401 | { |
| 1402 | *slash = 0; |
| 1403 | path = new char[strlen(buf) + 1]; |
| 1404 | strcpy(path, buf); |
| 1405 | f = slash + 1; |
| 1406 | } |
| 1407 | else |
| 1408 | { |
| 1409 | path = new char[4]; |
| 1410 | strcpy(path, "./"); |
| 1411 | |
| 1412 | f = buf; |
| 1413 | } |
| 1414 | |
| 1415 | char* firstChar = f; |
| 1416 | while (*f && (*f != '.')) |
| 1417 | f++; |
| 1418 | *f = 0; |
| 1419 | |
| 1420 | base = new char[strlen(firstChar) + 1]; |
| 1421 | strcpy(base, firstChar); |
| 1422 |
no test coverage detected