vfs: check userland buffers before reading them.
[haiku.git] / headers / private / package / ChecksumAccessors.h
blobba95aa5d01b14689016692f57de826c6a1ed9a66
1 /*
2 * Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _PACKAGE__PRIVATE__CHECKSUM_ACCESSORS_H_
6 #define _PACKAGE__PRIVATE__CHECKSUM_ACCESSORS_H_
9 #include <Entry.h>
10 #include <String.h>
13 namespace BPackageKit {
15 namespace BPrivate {
18 class ChecksumAccessor {
19 public:
20 virtual ~ChecksumAccessor();
22 virtual status_t GetChecksum(BString& checksum) const = 0;
26 class ChecksumFileChecksumAccessor : public ChecksumAccessor {
27 public:
28 ChecksumFileChecksumAccessor(
29 const BEntry& checksumFileEntry);
31 virtual status_t GetChecksum(BString& checksum) const;
33 private:
34 BEntry fChecksumFileEntry;
38 class GeneralFileChecksumAccessor : public ChecksumAccessor {
39 public:
40 GeneralFileChecksumAccessor(
41 const BEntry& fileEntry,
42 bool skipMissingFile = false);
44 virtual status_t GetChecksum(BString& checksum) const;
46 private:
47 BEntry fFileEntry;
48 bool fSkipMissingFile;
52 class StringChecksumAccessor : public ChecksumAccessor {
53 public:
54 StringChecksumAccessor(const BString& checksum);
56 virtual status_t GetChecksum(BString& _checksum) const;
58 private:
59 BString fChecksum;
63 } // namespace BPrivate
65 } // namespace BPackageKit
68 #endif // _PACKAGE__PRIVATE__CHECKSUM_ACCESSORS_H_