Android-cuttlefish cvd tool
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
android::base::MappedFile Class Reference

#include <mapped_file.h>

Public Member Functions

 ~MappedFile ()
 
 MappedFile (MappedFile &&other)
 
MappedFileoperator= (MappedFile &&other)
 
char * data () const
 
size_t size () const
 

Static Public Member Functions

static std::unique_ptr< MappedFileFromFd (borrowed_fd fd, off64_t offset, size_t length, int prot)
 
static std::unique_ptr< MappedFileFromOsHandle (os_handle h, off64_t offset, size_t length, int prot)
 

Private Member Functions

 DISALLOW_IMPLICIT_CONSTRUCTORS (MappedFile)
 
void Close ()
 
 MappedFile (char *base, size_t size, size_t offset)
 

Private Attributes

char * base_
 
size_t size_
 
size_t offset_
 

Detailed Description

A region of a file mapped into memory (for grepping: also known as MmapFile or file mapping).

Constructor & Destructor Documentation

◆ ~MappedFile()

android::base::MappedFile::~MappedFile ( )

Removes the mapping.

◆ MappedFile() [1/2]

android::base::MappedFile::MappedFile ( MappedFile &&  other)

Not copyable but movable.

◆ MappedFile() [2/2]

android::base::MappedFile::MappedFile ( char *  base,
size_t  size,
size_t  offset 
)
inlineprivate

Member Function Documentation

◆ Close()

void android::base::MappedFile::Close ( )
private

◆ data()

char * android::base::MappedFile::data ( ) const
inline

◆ DISALLOW_IMPLICIT_CONSTRUCTORS()

android::base::MappedFile::DISALLOW_IMPLICIT_CONSTRUCTORS ( MappedFile  )
private

◆ FromFd()

std::unique_ptr< MappedFile > android::base::MappedFile::FromFd ( borrowed_fd  fd,
off64_t  offset,
size_t  length,
int  prot 
)
static

Creates a new mapping of the file pointed to by fd. Unlike the underlying OS primitives, offset does not need to be page-aligned. If PROT_WRITE is set in prot, the mapping will be writable, otherwise it will be read-only. Mappings are always MAP_SHARED.

◆ FromOsHandle()

std::unique_ptr< MappedFile > android::base::MappedFile::FromOsHandle ( os_handle  h,
off64_t  offset,
size_t  length,
int  prot 
)
static

Same thing, but using the raw OS file handle instead of a CRT wrapper.

◆ operator=()

MappedFile & android::base::MappedFile::operator= ( MappedFile &&  other)

◆ size()

size_t android::base::MappedFile::size ( ) const
inline

Member Data Documentation

◆ base_

char* android::base::MappedFile::base_
private

◆ offset_

size_t android::base::MappedFile::offset_
private

◆ size_

size_t android::base::MappedFile::size_
private

The documentation for this class was generated from the following files: