MCPcopy Create free account
hub / github.com/Parchive/par2cmdline / WriteData

Method WriteData

src/datablock.cpp:85–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83// from memory to disk
84
85bool DataBlock::WriteData(u64 position, // Position within the block
86 size_t size, // Size of the memory buffer
87 const void *buffer, // Pointer to memory buffer
88 size_t &wrote) // Amount actually written
89{
90 assert(diskfile != 0);
91
92 wrote = 0;
93
94 // Check to see if the position from which data is to be written
95 // is within the bounds of the data block
96 if (length > position)
97 {
98 // Compute the file offset and how much data to physically write to disk
99 u64 fileoffset = offset + position;
100 size_t have = (size_t)std::min((u64)size, length - position);
101
102 // Write the data from the buffer to disk
103 if (!diskfile->Write(fileoffset, buffer, have))
104 return false;
105
106 wrote = have;
107 }
108
109 return true;
110}

Callers 3

ProcessDataMethod · 0.45
ProcessDataMethod · 0.45
ProcessDataMethod · 0.45

Calls 1

WriteMethod · 0.80

Tested by

no test coverage detected