2 * Copyright 2005-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2016, Axel Dörfler, axeld@pinc-software.de.
4 * Distributed under the terms of the MIT License.
8 #include "AttributeUtilities.h"
12 #include <StorageDefs.h>
15 static const int kCopyBufferSize
= 64 * 1024;
23 CopyAttributes(BNode
& source
, BNode
& destination
)
25 char attrName
[B_ATTR_NAME_LENGTH
];
26 while (source
.GetNextAttrName(attrName
) == B_OK
) {
29 status_t status
= source
.GetAttrInfo(attrName
, &attrInfo
);
34 char buffer
[kCopyBufferSize
];
36 off_t bytesLeft
= attrInfo
.size
;
38 // Go at least once through the loop, so that an empty attribute will be
41 size_t toRead
= kCopyBufferSize
;
42 if ((off_t
)toRead
> bytesLeft
)
46 ssize_t bytesRead
= source
.ReadAttr(attrName
, attrInfo
.type
,
47 offset
, buffer
, toRead
);
52 ssize_t bytesWritten
= destination
.WriteAttr(attrName
,
53 attrInfo
.type
, offset
, buffer
, bytesRead
);
57 bytesLeft
-= bytesRead
;
59 } while (bytesLeft
> 0);
65 } // namespace BPrivate