X-Git-Url: https://git.saurik.com/apple/system_cmds.git/blobdiff_plain/1a7e3f61d38d679bba59130891c2031b5a0092b6..bd6521f0fc816ab056bc71376f9706a69b3b52c1:/CPPUtil/UtilMappedFile.hpp diff --git a/CPPUtil/UtilMappedFile.hpp b/CPPUtil/UtilMappedFile.hpp new file mode 100644 index 0000000..1494752 --- /dev/null +++ b/CPPUtil/UtilMappedFile.hpp @@ -0,0 +1,27 @@ +// +// UtilMappedFile.h +// CPPUtil +// +// Created by James McIlree on 4/19/13. +// Copyright (c) 2013 Apple. All rights reserved. +// + +#ifndef __CPPUtil__UtilMappedFile__ +#define __CPPUtil__UtilMappedFile__ + +class MappedFile { + protected: + unsigned char* _address; + size_t _size; + + public: + MappedFile(const char* path); + ~MappedFile(); + + uint8_t* address() { return _address; } + size_t size() { return _size; } + + bool mmap_failed() const { return _size > 0 && _address == nullptr; } +}; + +#endif /* defined(__CPPUtil__UtilMappedFile__) */