-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
239 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
uid: FileSystem | ||
--- | ||
# FileSystem | ||
|
||
````mermaid | ||
classDiagram | ||
MoryxFile <|-- Blob | ||
MoryxFile <|-- Tree | ||
Tree --> MoryxFile | ||
OwnerFile --> Tree | ||
class MoryxFileSystem{ | ||
-string Directory | ||
+WriteBlob() | ||
+WriteTree() | ||
+ReadBlob() | ||
+ReadTree() | ||
} | ||
class MoryxFile { | ||
+String Hash | ||
} | ||
```` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Moryx.FileSystem | ||
{ | ||
public class MoryxFileMetadata | ||
{ | ||
public int Mode { get; set; } | ||
|
||
public FileType FileType { get; set; } | ||
|
||
public string MimeType { get; set; } | ||
|
||
public string Hash { get; set; } | ||
|
||
public string FileName { get; set; } | ||
|
||
public string ToLine() | ||
{ | ||
return $"{Mode} {FileType.ToString().ToLower()} {MimeType} {Hash} {FileName}"; | ||
} | ||
|
||
public static MoryxFileMetadata FromLine(string line) | ||
{ | ||
var parts = line.Split(' '); | ||
return new MoryxFileMetadata | ||
{ | ||
Mode = int.Parse(parts[0]), | ||
FileType = (FileType)Enum.Parse(typeof(FileType), parts[1]), | ||
MimeType = parts[2], | ||
Hash = parts[3], | ||
FileName = string.Join(" ", parts.Skip(4)) | ||
}; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Moryx file types in owner tree file | ||
/// </summary> | ||
public enum FileType | ||
{ | ||
Blob = 0, | ||
|
||
Tree = 1, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters