The Allegro Wiki is migrating to github at https://github.com/liballeg/allegro_wiki/wiki

Proposed virtual file system

From Allegro Wiki
Jump to: navigation, search

Proposed Virtual File System

The system being proposed, will be made up of two separate layers. One low level handle based interface, and a high level URI based interface.

Note: this is no longer being proposed for ALLEGRO 5. See NewAPI/FileSystems for the new api.

Low Level

VFS__DATA

This struct provides a place to store handle specific data.

<highlightSyntax language="cpp">typedef struct VFS__DATA {

  enum { VFS__DATA_VFS = 1, VFS__DATA_STREAM, VFS__DATA_FILTER, VFS__DATA_DIR, VFS__DATA_STAT, VFS__DATA_PTR } type;
  union {
     VFS *vfs;
     VFS_STREAM *stream;
     VFS_FILTER *filter;
     VFS_DIR *dir;
     VFS_STAT *stat;
     void *ptr;
  };

};

</highlightSyntax>

VFS

struct VFS_VTABLE

This struct provides the methods a filesystem may want to provide. Some are manditory, while others, are not (TBA).

<highlightSyntax language="cpp">struct VFS_VTABLE {

  vfs_stream_open_func open;
  vfs_stream_close_func close;
  vfs_remove_func remove;
  vfs_opendir_func opendir;
  vfs_readdir_func readdir;
  vfs_closedir_func closedir;
  vfs_mkdir_func mkdir;
  vfs_rmdir_func rmdir;
  vfs_chmod_func chmod; // rwx, FIXME: needs to be thought about some more. Possibly going as far as allowing adding user/group permissions ala NTFS.
  // get_|set_ group|user, canread|write|execute
  vfs_rename_func rename;
  vfs_link_funk link;
  vfs_symlink_funk symlink;
  vfs_stat_func stat;
  vfs_getcwd_func getcwd;

};

</highlightSyntax>

struct VFS

This handle provides an interface to a file system, ie: file, and directory handling.

<highlightSyntax language="cpp">struct VFS {

  VFS_VTABLE *vtable;
  VFS__DATA data;

};

</highlightSyntax>

DIR

This handle provides an interface to working with directories.

TBA

STAT

This handle provides file and directory information.

TBA

STREAM

struct VFS_STREAM_VTABLE

This struct provides methods that a stream may want to provide (not final).

<highlightSyntax language="cpp">struct VFS_STREAM_VTABLE {

  vfs_stream_read_func read;
  vfs_stream_write_func write;
  vfs_stream_eof_func eof;
  vfs_stream_getc_func getc;
  vfs_stream_putc_func putc;
  vfs_stream_seek_func seek;
  vfs_stream_tell_func tell;
  vfs_stream_error_func error;

};

</highlightSyntax>

struct VFS_STREAM

This handle provides access to "files" in a file system.

<highlightSyntax language="cpp">struct VFS_STREAM {

  VFS_STREAM_VTABLE *vtable;
  VFS *vfs;
  VFS_FILTER *filters;
  VFS__DATA data;

};

</highlightSyntax>

struct VFS_FILTER

This handle allows you to chain filters to a stream

TBA

High Level

TBA


Place comments in the discussion page.