MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / CopyImpl

Function CopyImpl

src/core/serializerutil.cpp:40–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38namespace
39{
40template<class FROM, class TO> int64 CopyImpl(TO* pTo, FROM* pFrom, int64 amt)
41{
42 enum
43 {
44 BUF_SIZE = 8192
45 };
46 int8 buf[BUF_SIZE];
47 int64 amtLeft = amt;
48
49 while (amtLeft > 0)
50 {
51 // NOTE: We use int's here rather than int64 because iSerializer and cArchive
52 // only take int's as their size parameter - dmb
53 int amtToRead = amtLeft > BUF_SIZE ? BUF_SIZE : (int)amtLeft;
54 int amtRead = pFrom->ReadBlob(buf, amtToRead);
55 amtLeft -= amtRead;
56 pTo->WriteBlob(buf, amtRead);
57 if (amtRead < amtToRead)
58 break;
59 }
60
61 // return the amount copied ...
62 return (amt - amtLeft);
63}
64} // namespace
65
66

Callers 1

CopyMethod · 0.85

Calls 2

ReadBlobMethod · 0.45
WriteBlobMethod · 0.45

Tested by

no test coverage detected