Skip to content

topfs2/libvfs

Repository files navigation

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");

About

Small module based vfs library in c

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages