libwebsockets
Lightweight C library for HTML5 websockets
file operation wrapping

Data Structures

struct  lws_fop_fd
 
struct  lws_fops_index
 
struct  lws_plat_file_ops
 

Typedefs

typedef struct lws_fop_fdlws_fop_fd_t
 

Functions

LWS_VISIBLE LWS_EXTERN struct lws_plat_file_ops *LWS_WARN_UNUSED_RESULT lws_get_fops (struct lws_context *context)
 
LWS_VISIBLE LWS_EXTERN void lws_set_fops (struct lws_context *context, const struct lws_plat_file_ops *fops)
 
LWS_VISIBLE LWS_EXTERN lws_filepos_t LWS_WARN_UNUSED_RESULT lws_vfs_tell (lws_fop_fd_t fop_fd)
 
LWS_VISIBLE LWS_EXTERN lws_filepos_t LWS_WARN_UNUSED_RESULT lws_vfs_get_length (lws_fop_fd_t fop_fd)
 
LWS_VISIBLE LWS_EXTERN uint32_t LWS_WARN_UNUSED_RESULT lws_vfs_get_mod_time (lws_fop_fd_t fop_fd)
 
LWS_VISIBLE LWS_EXTERN lws_fileofs_t lws_vfs_file_seek_set (lws_fop_fd_t fop_fd, lws_fileofs_t offset)
 
LWS_VISIBLE LWS_EXTERN lws_fileofs_t lws_vfs_file_seek_end (lws_fop_fd_t fop_fd, lws_fileofs_t offset)
 
LWS_VISIBLE LWS_EXTERN lws_fop_fd_t LWS_WARN_UNUSED_RESULT lws_vfs_file_open (const struct lws_plat_file_ops *fops, const char *vfs_path, lws_fop_flags_t *flags)
 
LWS_VISIBLE LWS_EXTERN lws_fop_fd_t _lws_plat_file_open (const struct lws_plat_file_ops *fops, const char *filename, const char *vpath, lws_fop_flags_t *flags)
 
LWS_VISIBLE LWS_EXTERN int _lws_plat_file_close (lws_fop_fd_t *fop_fd)
 
LWS_VISIBLE LWS_EXTERN lws_fileofs_t _lws_plat_file_seek_cur (lws_fop_fd_t fop_fd, lws_fileofs_t offset)
 
LWS_VISIBLE LWS_EXTERN int _lws_plat_file_read (lws_fop_fd_t fop_fd, lws_filepos_t *amount, uint8_t *buf, lws_filepos_t len)
 
LWS_VISIBLE LWS_EXTERN int _lws_plat_file_write (lws_fop_fd_t fop_fd, lws_filepos_t *amount, uint8_t *buf, lws_filepos_t len)
 
LWS_VISIBLE LWS_EXTERN int lws_alloc_vfs_file (struct lws_context *context, const char *filename, uint8_t **buf, lws_filepos_t *amount)
 

Variables

struct lws_plat_file_ops fops_zip
 

Detailed Description

File operation wrapping

Use these helper functions if you want to access a file from the perspective of a specific wsi, which is usually the case. If you just want contextless file access, use the fops callbacks directly with NULL wsi instead of these helpers.

If so, then it calls the platform handler or user overrides where present (as defined in info->fops)

The advantage from all this is user code can be portable for file operations without having to deal with differences between platforms.

Function Documentation

◆ lws_get_fops()

LWS_VISIBLE LWS_EXTERN struct lws_plat_file_ops* LWS_WARN_UNUSED_RESULT lws_get_fops ( struct lws_context *  context)

#include <lib/libwebsockets.h>

lws_get_fops() - get current file ops

Parameters
contextcontext

◆ lws_vfs_file_open()

LWS_VISIBLE LWS_EXTERN lws_fop_fd_t LWS_WARN_UNUSED_RESULT lws_vfs_file_open ( const struct lws_plat_file_ops fops,
const char *  vfs_path,
lws_fop_flags_t *  flags 
)

#include <lib/libwebsockets.h>

lws_plat_file_open() - open vfs filepath

Parameters
fopsfile ops struct that applies to this descriptor
vfs_pathfilename to open
flagspointer to open flags

The vfs_path is scanned for known fops signatures, and the open directed to any matching fops open.

User code should use this api to perform vfs opens.

returns semi-opaque handle

◆ lws_vfs_file_seek_end()

LWS_VISIBLE LWS_EXTERN lws_fileofs_t lws_vfs_file_seek_end ( lws_fop_fd_t  fop_fd,
lws_fileofs_t  offset 
)

#include <lib/libwebsockets.h>

lws_vfs_file_seek_end() - seek relative to end of file

Parameters
fop_fdfop_fd we are seeking in
offsetoffset from start of file

◆ lws_vfs_file_seek_set()

LWS_VISIBLE LWS_EXTERN lws_fileofs_t lws_vfs_file_seek_set ( lws_fop_fd_t  fop_fd,
lws_fileofs_t  offset 
)

#include <lib/libwebsockets.h>

lws_vfs_file_seek_set() - seek relative to start of file

Parameters
fop_fdfop_fd we are seeking in
offsetoffset from start of file

◆ lws_vfs_get_length()

LWS_VISIBLE LWS_EXTERN lws_filepos_t LWS_WARN_UNUSED_RESULT lws_vfs_get_length ( lws_fop_fd_t  fop_fd)

#include <lib/libwebsockets.h>

lws_vfs_get_length() - get current file total length in bytes

Parameters
fop_fdfop_fd we are asking about

◆ lws_vfs_get_mod_time()

LWS_VISIBLE LWS_EXTERN uint32_t LWS_WARN_UNUSED_RESULT lws_vfs_get_mod_time ( lws_fop_fd_t  fop_fd)

#include <lib/libwebsockets.h>

lws_vfs_get_mod_time() - get time file last modified

Parameters
fop_fdfop_fd we are asking about

◆ lws_vfs_tell()

LWS_VISIBLE LWS_EXTERN lws_filepos_t LWS_WARN_UNUSED_RESULT lws_vfs_tell ( lws_fop_fd_t  fop_fd)

#include <lib/libwebsockets.h>

lws_vfs_tell() - get current file position

Parameters
fop_fdfop_fd we are asking about