the new post :)

main
able 2023-06-26 03:03:51 -05:00
parent b4543c81ec
commit bd1107f412
2 changed files with 53 additions and 1 deletions

52
Files; an overview.md Normal file
View File

@ -0,0 +1,52 @@
Continuing from the [previous](https://git.ablecorp.us/able/The_Programmers_ByAble/src/branch/main/Unix%3B%20Your%20mouse%20are%20a%20file.md) post we will define a very minimal example of a file and API
Here is our file definition
```rust
struct File{}
```
Files could have some metadata like a name
```rust
struct File{
@documentation["The length of the file name is limited to 100 because of simplicity"]
@validator[Length(100)]
name: String,
}
```
and of course the data
```rust
struct File{
@documentation["The length of the file name is limited to 100 because of simplicity"]
@validator[Length(100)]
name: String,
@documentation["Untyped raw bytes of the file"]
data: Vector<u8>,
}
```
Now we come to the fun part. Bikeshedding the api.
I propose a simple read/write/open/close api that supports offsets for read/write
```rust
struct File{
@documentation["The length of the file name is limited to 100 because of simplicity"]
@validator[Length(100)]
name: String,
@documentation["Untyped raw bytes of the file"]
data: Vector<u8>,
@documentation["The offset is to allow you do reads of specific data like the header of a file"]
read: function(offset: u64, length: u64) -> Vector<u8>;
@documentation["The offset is to allow you do write to specific data like the header of a file"]
write: function(offset: u64, data: Vector<u8>) -> None;
@documentation["Open a file based on a path"]
open: function(Path) -> File;
@documentation["Close a file and save all changes"]
close: function(None) -> None;
}
```
Small post this time that is more hand holdy. Next time will be a full filesystem definition as well as a virtual file system.

View File

@ -1,4 +1,4 @@
A file is a wonderful abstraction over raw data on a storage device.
A [file](https://git.ablecorp.us/able/The_Programmers_ByAble/src/branch/main/Files%3B%20an%20overview.md) is a wonderful abstraction over raw data on a storage device.
Users don't want to think about how many blocks on a disk their data takes up.
They want a nice clean efficient way to reference all of the data, as such filesystems were a genius idea.
A mouse device by design has some state which can be represented in a certian way, say we use JSON.