MCPcopy Create free account
hub / github.com/amule-project/amule / GetAvailable

Method GetAvailable

src/CFile.cpp:512–530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

510
511
512uint64 CFile::GetAvailable() const
513{
514 // Lock around both calls so length/position are taken atomically;
515 // otherwise a concurrent write could land between and skew the
516 // reported "available" count. Recursive so the inner GetLength /
517 // GetPosition calls (which lock again) don't deadlock.
518 std::lock_guard<std::recursive_mutex> lock(m_mutex);
519
520 const uint64 length = GetLength();
521 const uint64 position = GetPosition();
522
523 // Safely handle seeking past EOF
524 if (position < length) {
525 return length - position;
526 }
527
528 // File is at or after EOF
529 return 0;
530}
531
532
533bool CFile::SetLength(uint64 new_len)

Callers 1

TESTFunction · 0.45

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.36