GMimeStreamMmap

GMimeStreamMmap — A memory-mapped file stream

Functions

Types and Values

Description

A GMimeStream implementation using a memory-mapped file backing store. This may be faster than GMimeStreamFs or GMimeStreamFile but you'll have to do your own performance checking to be sure for your particular application/platform.

Substreams retain independent positions and EOF state over a fixed-size mapping. Reads and partial writes stop at both the view's end and the mapped extent; seeking does not grow the file or the mapping.

Views borrow the mapping and descriptor. Finish using them before explicitly closing an owning parent, and do not truncate the underlying file while any mapped view is active.

Functions

g_mime_stream_mmap_new ()

GMimeStream *
g_mime_stream_mmap_new (int fd,
                        int prot,
                        int flags);

Creates a new GMimeStreamMmap object around fd .

Parameters

fd

file descriptor

 

prot

protection flags

 

flags

map flags

 

Returns

a stream using fd , or NULL on error with errno set. Empty files cannot be mapped. On failure, fd remains owned by the caller.

[nullable]


g_mime_stream_mmap_new_with_bounds ()

GMimeStream *
g_mime_stream_mmap_new_with_bounds (int fd,
                                    int prot,
                                    int flags,
                                    gint64 start,
                                    gint64 end);

Creates a new GMimeStreamMmap object around fd with bounds start and end . The mapping stops at the actual file extent even when end extends farther; finite length still reports the declared range. Nonempty reads require PROT_READ and writes require PROT_WRITE in prot .

Parameters

fd

file descriptor

 

prot

protection flags

 

flags

map flags

 

start

start boundary

 

end

end boundary

 

Returns

a stream using fd with bounds start and end , or NULL on error with errno set. Empty mappings fail with EINVAL; unsupported platforms fail with ENOSYS. On failure, fd remains owned by the caller.

[nullable]


g_mime_stream_mmap_get_owner ()

gboolean
g_mime_stream_mmap_get_owner (GMimeStreamMmap *stream);

Gets whether or not stream owns the backend file descriptor.

Parameters

stream

a GMimeStreamMmap

 

Returns

TRUE if stream owns the backend file descriptor or FALSE otherwise.

Since: 3.2


g_mime_stream_mmap_set_owner ()

void
g_mime_stream_mmap_set_owner (GMimeStreamMmap *stream,
                              gboolean owner);

Sets whether or not stream owns the backend file descriptor.

Note: owner should be TRUE if the stream should close() the backend file descriptor when destroyed or FALSE otherwise.

Parameters

stream

a GMimeStreamMmap

 

owner

TRUE if this stream should own the file descriptor or FALSE otherwise

 

Since: 3.2

Types and Values

GMimeStreamMmap

typedef struct _GMimeStreamMmap GMimeStreamMmap;

A memory-mapped GMimeStream.

See Also

GMimeStream