KWin
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
KWin::RamFile Class Reference

Creates a file in memory. More...

#include <ramfile.h>

Public Types

enum class  Flag { SealWrite = 1 << 0 }
 

Public Member Functions

 RamFile ()=default
 
 RamFile (const char *name, const void *inData, int size, Flags flags={})
 
 RamFile (RamFile &&other) Q_DECL_NOEXCEPT
 
RamFileoperator= (RamFile &&other) Q_DECL_NOEXCEPT
 
 ~RamFile ()
 
bool isValid () const
 
Flags effectiveFlags () const
 
int fd () const
 
int size () const
 

Detailed Description

Creates a file in memory.

This is useful for passing larger data to clients, for example the xkeymap.

If memfd is supported, it is used, otherwise a temporary file is created.

Note
It is advisable not to send the same file descriptor out to multiple clients unless it is sealed for writing. Check which flags actually apply before handing out the file descriptor.
See also
effectiveFlags()

Definition at line 46 of file ramfile.h.

Member Enumeration Documentation

◆ Flag

enum class KWin::RamFile::Flag
strong

Flags to use when creating the file.

Note
Check with effectiveFlags() which flags actually apply after the file was created.
Enumerator
SealWrite 

Seal the file descriptor for writing.

Definition at line 55 of file ramfile.h.

Constructor & Destructor Documentation

◆ RamFile() [1/3]

KWin::RamFile::RamFile ( )
default

◆ RamFile() [2/3]

KWin::RamFile::RamFile ( const char * name,
const void * inData,
int size,
Flags flags = {} )

Create a file of given size with given data.

Note
You should call seal() after copying the data into the file.
Parameters
nameThe file name, useful for debugging.
dataThe data to store in the file.
sizeThe size of the file.
flagsThe flags to use when creating the file.

◆ RamFile() [3/3]

KWin::RamFile::RamFile ( RamFile && other)

Definition at line 93 of file ramfile.cpp.

◆ ~RamFile()

KWin::RamFile::~RamFile ( )

Destroys the file.

Definition at line 117 of file ramfile.cpp.

Member Function Documentation

◆ effectiveFlags()

RamFile::Flags KWin::RamFile::effectiveFlags ( ) const

The flags that are effectively applied.

For instance, even though SealWrite was passed in the constructor, it might not be supported.

Definition at line 136 of file ramfile.cpp.

◆ fd()

int KWin::RamFile::fd ( ) const

The underlying file descriptor

Returns
The fd, or -1 if there is none.

Definition at line 150 of file ramfile.cpp.

◆ isValid()

bool KWin::RamFile::isValid ( ) const

Whether this instance contains a valid file descriptor.

Definition at line 131 of file ramfile.cpp.

◆ operator=()

RamFile & KWin::RamFile::operator= ( RamFile && other)

Definition at line 104 of file ramfile.cpp.

◆ size()

int KWin::RamFile::size ( ) const

The size of the file

Definition at line 159 of file ramfile.cpp.


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