Small module based vfs library in c
C
Switch branches/tags
Nothing to show
Latest commit 8b19d3b Apr 5, 2011 @topfs2 Cleaned up the API. Different read of directories and added support f…
…or multiple contexts. Also moved to opaque structures for cleaner library
Permalink
Failed to load latest commit information.
README
vfs.c
vfs.h
vfs_descriptors.h
vfs_directory_hooks.h
vfs_iohook.h
vfs_lists.c
vfs_lists.h
vfs_posix.c
vfs_posix.h
vfs_properties.c
vfs_properties.h
vfs_watchdog_hooks.h

README

This vfs library is designed to work the same way as if you were to use posix io. The library will fallback to local reading and is not needed to be added as a iohook for usage.

To use the library use it exactly like any posix io:

  struct vfs_file_descriptor *fp = vfs_open("temp", O_RDONLY);

  char buffer[1024];
  buffer[0] = '\0';

  vfs_read(buffer, 1, 16, fp);
  buffer[16] = '\0';

  printf("%s\n", buffer);

  vfs_close(fp);

Directories can be read and all content they have will have some set of mandatory properties but can have any number of extra metadata, this allows for extending the vfs hooks to provide metadata with the files. Its important though that the property gets freed after used, it will not be garbage collected.

  struct vfs_directory_descriptor *dp = vfs_opendir("/foo/bar/");
  struct vfs_properties *dir;

  while ((dir = vfs_readdir(dp)) != NULL)
  {
    printf("%s\n", dir->name);
    vfs_free_properties(dir);
  }

  vfs_closedir(dp);

The library will have some iohook available but the library is designed around you choosing what you want to initialize, this way you are free to just use the library as a structure and add all iohooks you want. You can also use it only with compiled and available iohooks. Here is an example how you can initialize with all compiled in modules.

  if (vfs_initialize_iohooks(vfs_all_iohooks))
    printf("Failed to initialize all or some iohooks\n");