Create abstraction for handling files and directories in a generic manner #88

Open
opened 2026-01-29 15:09:05 +00:00 by claunia · 1 comment
Owner

Originally created by @darkstar on GitHub (Aug 30, 2016).

There should be some abstraction to handle files and directories. It should at least allow the following things:

  • Locate the "root" directory (if it is unique; if not, locate one of the root directories. btrfs and WAFL have multiple filesystem roots, for example)
  • Enumerate entries in a directory. Basic data each entry should have: one (or more) name(s), an "inode" number (or any other unique ID) and an indication of whether it's a file or directory
  • Open a file from a directory (this is probably left for last since it requires reading the file table/block bitmap/btree/...)
  • Open a (sub-)directory

I think roughly something like this should work

class Directory
{
  Directory(int inode); // open directory from inode number
  Directory(); // open the "root" directory explicitly
          // (either via a fixed inode number or from a fixed position. depends on the filesystem)
         // there could also be a FileSystem.OpenRootDirectory() function in each FS plugin...
  DirectoryEntry[] Enumerate(); // enumerate all directory entries
}

class DirectoryEntry
{
  string PrimaryName; // an FS can have multiple names
  int InodeNumber; //or any other unique ID identifying the file in question
  int Flags; // directory or file? case-sensitive or not? is compressed or not? etc. etc. etc.
  int size;
  // ... whatever else is needed
}

class File
{
  File(int inode);
  byte[] read(int offset);
  // ... whatever else is needed
}

Something like this should suffice for almost all file systems.

It could even be possible to nest these in each other, so a file inside one filesystem could be detected as (for example) an ISO and opened transparently by nesting another Filesystem in it :)

Originally created by @darkstar on GitHub (Aug 30, 2016). There should be some abstraction to handle files and directories. It should at least allow the following things: - Locate the "root" directory (if it is unique; if not, locate one of the root directories. btrfs and WAFL have multiple filesystem roots, for example) - Enumerate entries in a directory. Basic data each entry should have: one (or more) name(s), an "inode" number (or any other unique ID) and an indication of whether it's a file or directory - Open a file from a directory (this is probably left for last since it requires reading the file table/block bitmap/btree/...) - Open a (sub-)directory I think roughly something like this should work ``` class Directory { Directory(int inode); // open directory from inode number Directory(); // open the "root" directory explicitly // (either via a fixed inode number or from a fixed position. depends on the filesystem) // there could also be a FileSystem.OpenRootDirectory() function in each FS plugin... DirectoryEntry[] Enumerate(); // enumerate all directory entries } class DirectoryEntry { string PrimaryName; // an FS can have multiple names int InodeNumber; //or any other unique ID identifying the file in question int Flags; // directory or file? case-sensitive or not? is compressed or not? etc. etc. etc. int size; // ... whatever else is needed } class File { File(int inode); byte[] read(int offset); // ... whatever else is needed } ``` Something like this should suffice for almost all file systems. It could even be possible to nest these in each other, so a file inside one filesystem could be detected as (for example) an ISO and opened transparently by nesting another Filesystem in it :)
claunia added the feature request label 2026-01-29 15:09:05 +00:00
Author
Owner

@claunia commented on GitHub (Sep 2, 2016):

There is already code for that.

Just see MFS, CP/M, Lisa and Pascal filesystems code.

The API is still unstable and incomplete.

The idea is to get an API similar enough to FUSE so in the FAR future any supported disc image or filesystem could be mounted on Linux using FUSE and on Windows using Dokan

@claunia commented on GitHub (Sep 2, 2016): There is already code for that. Just see MFS, CP/M, Lisa and Pascal filesystems code. The API is still unstable and incomplete. The idea is to get an API similar enough to FUSE so in the FAR future any supported disc image or filesystem could be mounted on Linux using [FUSE](https://github.com/jonpryor/mono-fuse) and on Windows using [Dokan](https://github.com/dokan-dev/dokan-dotnet)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: aaru-dps/Aaru-aaru-dps#88