diff --git a/Files; an overview.md b/Files; an overview.md new file mode 100644 index 0000000..3890ea9 --- /dev/null +++ b/Files; an overview.md @@ -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, +} +``` + + + +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, + + @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; + + @documentation["The offset is to allow you do write to specific data like the header of a file"] + write: function(offset: u64, data: Vector) -> 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. \ No newline at end of file diff --git a/Unix; Your mouse are a file.md b/Unix; Your mouse are a file.md index e381ff2..b00fcf6 100644 --- a/Unix; Your mouse are a file.md +++ b/Unix; Your mouse are a file.md @@ -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.