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

Method SetLength

src/CFile.cpp:533–559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

531
532
533bool CFile::SetLength(uint64 new_len)
534{
535 MULE_VALIDATE_STATE(IsOpened(), "CFile: Cannot set length when no file is open.");
536
537 std::lock_guard<std::recursive_mutex> lock(m_mutex);
538
539 // ftruncate / chsize operate on the kernel-side size; drain the
540 // userspace buffer first so any pending bytes are part of the
541 // length-resolution decision (e.g. extend-then-write patterns).
542 DrainWriteBuffer();
543
544#ifdef __WINDOWS__
545#ifdef _MSC_VER
546// MSVC has a 64bit version
547 bool result = _chsize_s(m_fd, new_len) == 0;
548#else
549// MingW has an old runtime without it
550 bool result = chsize(m_fd, new_len) == 0;
551#endif
552#else
553 bool result = ftruncate(m_fd, new_len) != -1;
554#endif
555
556 syscall_check(result, m_filePath, "truncating file");
557
558 return result;
559}
560// File_checked_for_headers

Callers 9

SaveHashSetMethod · 0.45
EntryMethod · 0.45
performConvertToeMuleMethod · 0.45
LoadPartFileMethod · 0.45
FlushBufferMethod · 0.45
SendValidSourceResultMethod · 0.45
SendValidNoteResultMethod · 0.45
TESTFunction · 0.45

Calls 1

syscall_checkFunction · 0.85

Tested by 1

TESTFunction · 0.36