| | 485 | // first try to open, 'cos if the file doesn't exist, there's no point |
|---|
| | 486 | // in the below modification date checks either |
|---|
| | 487 | int fd = open( |
|---|
| | 488 | getPath().native_file_string().c_str(), |
|---|
| | 489 | O_RDONLY|O_LARGEFILE|O_BINARY |
|---|
| | 490 | ); |
|---|
| | 491 | |
|---|
| | 492 | if (fd == -1) { |
|---|
| | 493 | if (m_locations.size()) { |
|---|
| | 494 | setLocation(m_locations.back().second); |
|---|
| | 495 | m_locations.pop_back(); |
|---|
| | 496 | return read(begin, end); |
|---|
| | 497 | } |
|---|
| | 498 | boost::format fmt("Unable to open shared file %s%s (reason: %s)"); |
|---|
| | 499 | fmt % getName(); |
|---|
| | 500 | if (isPartial()) { |
|---|
| | 501 | fmt % (" (loc=" + getPath().native_file_string() + ")"); |
|---|
| | 502 | } else { |
|---|
| | 503 | fmt % ""; |
|---|
| | 504 | } |
|---|
| | 505 | #ifdef WIN32 |
|---|
| | 506 | fmt % "unable to open file"; |
|---|
| | 507 | #else |
|---|
| | 508 | fmt % strerror(errno); |
|---|
| | 509 | #endif |
|---|
| | 510 | destroy(); // sorry, but if our file died, so shall we |
|---|
| | 511 | throw std::runtime_error(fmt.str()); |
|---|
| | 512 | } |
|---|
| | 513 | |
|---|
| 506 | | } |
|---|
| 507 | | |
|---|
| 508 | | int fd = open( |
|---|
| 509 | | getPath().native_file_string().c_str(), |
|---|
| 510 | | O_RDONLY|O_LARGEFILE|O_BINARY |
|---|
| 511 | | ); |
|---|
| 512 | | |
|---|
| 513 | | if (fd == -1) { |
|---|
| 514 | | if (m_locations.size()) { |
|---|
| 515 | | setLocation(m_locations.back().second); |
|---|
| 516 | | m_locations.pop_back(); |
|---|
| 517 | | return read(begin, end); |
|---|
| 518 | | } |
|---|
| 519 | | boost::format fmt("Unable to open shared file %s%s (reason: %s)"); |
|---|
| 520 | | fmt % getName(); |
|---|
| 521 | | if (isPartial()) { |
|---|
| 522 | | fmt % (" (loc=" + getPath().native_file_string() + ")"); |
|---|
| 523 | | } else { |
|---|
| 524 | | fmt % ""; |
|---|
| 525 | | } |
|---|
| 526 | | #ifdef WIN32 |
|---|
| 527 | | fmt % "unable to open file"; |
|---|
| 528 | | #else |
|---|
| 529 | | fmt % strerror(errno); |
|---|
| 530 | | #endif |
|---|
| 531 | | destroy(); // sorry, but if our file died, so shall we |
|---|
| 532 | | throw std::runtime_error(fmt.str()); |
|---|
| | 535 | } catch (...) { |
|---|
| | 536 | close(fd); |
|---|
| | 537 | throw; |
|---|