diff --git a/Pentole/LICENSE b/Pentole/LICENSE
new file mode 120000
index 0000000..ea5b606
--- /dev/null
+++ b/Pentole/LICENSE
@@ -0,0 +1 @@
+../LICENSE
\ No newline at end of file
diff --git a/src/src.fsproj b/Pentole/Pentole.fsproj
similarity index 76%
rename from src/src.fsproj
rename to Pentole/Pentole.fsproj
index 59b1384..a16b241 100644
--- a/src/src.fsproj
+++ b/Pentole/Pentole.fsproj
@@ -1,23 +1,27 @@
-
-
-
- net8.0
- true
-
-
+
+
+
+ net8.0
+ true
+ Pentole
+ 0.0.1
+ Francesco Mecca
+ Bugless24
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
diff --git a/Pentole/binaryprefix.fs b/Pentole/binaryprefix.fs
new file mode 100644
index 0000000..508685e
--- /dev/null
+++ b/Pentole/binaryprefix.fs
@@ -0,0 +1,160 @@
+module Pentole.BinaryPrefix
+
+module Bits =
+ module IECScale =
+ type IECBit =
+ | B
+ | Kb
+ | Mb
+ | Gb
+ | Tb
+ | Pb
+
+ type Bit =
+ | Bit of double
+ | Kb of double
+ | Mb of double
+ | Gb of double
+ | Tb of double
+ | Pb of double
+
+ member this.bytes =
+ match this with
+ | Bit.Bit i -> i
+ | Bit.Kb i -> i * 1000.0 / 8.0
+ | Bit.Mb i -> i * 1000.0 * 1000.0 / 8.0
+ | Bit.Gb i -> i * 1000.0 * 1000.0 * 1000.0 / 8.0
+ | Bit.Tb i -> i * 1000.0 * 1000.0 * 1000.0 * 1000.0 / 8.0
+ | Bit.Pb i -> i * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 / 8.0
+
+ type System.Double with
+ member this.bit = Bit this
+ member this.Kb = Bit this
+ member this.Mb = Mb this
+ member this.Gb = Gb this
+ member this.Tb = Tb this
+ member this.Pb = Pb this
+
+ let private get_i_bit = function
+ | Kb i | Mb i | Gb i | Tb i | Pb i
+ | Bit.Bit i -> i
+
+ let change_scale (scale: IECScale.IECBit) (old_value: Bit) =
+ let x = get_i_bit old_value
+ let up, base_ =
+ match old_value with
+ | Bit _ -> 0.0, 1000.0
+ | Kb _ -> 1.0, 1000.0
+ | Mb _ -> 2.0, 1000.0
+ | Gb _ -> 3.0, 1000.0
+ | Tb _ -> 4.0, 1000.0
+ | Pb _ -> 5.0, 1000.0
+
+ let down, kst =
+ match scale with
+ | IECScale.IECBit.B -> 0.0, Bit
+ | IECScale.IECBit.Kb -> 1.0, Kb
+ | IECScale.IECBit.Mb -> 2.0, Mb
+ | IECScale.IECBit.Gb -> 3.0, Gb
+ | IECScale.IECBit.Tb -> 4.0, Tb
+ | IECScale.IECBit.Pb -> 5.0, Pb
+
+ x * (base_ ** (up - down)) |> kst
+
+module Bytes =
+ type Byte =
+ | Byte of double
+ | KB of double
+ | MB of double
+ | GB of double
+ | TB of double
+ | PB of double
+
+ | KiB of double
+ | MiB of double
+ | GiB of double
+ | TiB of double
+ | PiB of double
+
+ member this.bytes =
+ match this with
+ | Byte.Byte i -> i
+ | Byte.KB i -> i * 1000.0
+ | Byte.MB i -> i * 1000.0 * 1000.0
+ | Byte.GB i -> i * 1000.0 * 1000.0 * 1000.0
+ | Byte.TB i -> i * 1000.0 * 1000.0 * 1000.0 * 1000.0
+ | Byte.PB i -> i * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0
+
+ | Byte.KiB i -> i * 1024.0
+ | Byte.MiB i -> i * 1024.0 * 1024.0
+ | Byte.GiB i -> i * 1024.0 * 1024.0 * 1024.0
+ | Byte.TiB i -> i * 1024.0 * 1024.0 * 1024.0 * 1024.0
+ | Byte.PiB i -> i * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0
+
+ type System.Double with
+ member this.byte = Byte.Byte this
+ member this.KB = KB this
+ member this.MB = MB this
+ member this.GB = GB this
+ member this.TB = TB this
+ member this.PB = PB this
+
+ member this.KiB = KiB this
+ member this.MiB = MiB this
+ member this.GiB = GiB this
+ member this.TiB = TiB this
+ member this.PiB = PiB this
+
+ let private get_i_byte = function
+ | KB i | MB i | GB i | TB i | PB i
+ | KiB i | MiB i | GiB i | TiB i | PiB i
+ | Byte.Byte i -> i
+
+ module IECScale =
+ type IECByte =
+ | B
+ | KB
+ | KiB
+ | MB
+ | MiB
+ | GB
+ | GiB
+ | TB
+ | TiB
+ | PB
+ | PiB
+
+ let change_scale (scale: IECScale.IECByte) (old_value: Byte) =
+ let x = get_i_byte old_value
+ let up, base_ =
+ match old_value with
+ | KB _ -> 1.0, 1000.0
+ | MB _ -> 2.0, 1000.0
+ | GB _ -> 3.0, 1000.0
+ | TB _ -> 4.0, 1000.0
+ | PB _ -> 5.0, 1000.0
+
+ | Byte.KiB _ -> 1.0, 1024.0
+ | Byte.MiB _ -> 2.0, 1024.0
+ | Byte.GiB _ -> 3.0, 1024.0
+ | Byte.TiB _ -> 4.0, 1024.0
+ | Byte.PiB _ -> 5.0, 1024.0
+
+ | Byte.Byte _ -> 0.0, 1000.0
+
+ let down, kst =
+ match scale with
+ | IECScale.IECByte.B -> 0.0, Byte
+ | IECScale.IECByte.KB -> 1.0, KB
+ | IECScale.IECByte.MB -> 2.0, MB
+ | IECScale.IECByte.GB -> 3.0, GB
+ | IECScale.IECByte.TB -> 4.0, TB
+ | IECScale.IECByte.PB -> 5.0, PB
+
+ | IECScale.IECByte.KiB -> 1.0, KiB
+ | IECScale.IECByte.MiB -> 2.0, MiB
+ | IECScale.IECByte.GiB -> 3.0, GiB
+ | IECScale.IECByte.TiB -> 4.0, TiB
+ | IECScale.IECByte.PiB -> 5.0, PiB
+
+ x * 8.0 * (base_ ** (up - down)) |> kst
diff --git a/Pentole/bytesize.fs b/Pentole/bytesize.fs
new file mode 100644
index 0000000..34c38fb
--- /dev/null
+++ b/Pentole/bytesize.fs
@@ -0,0 +1,182 @@
+module Pentole.BinaryPrefix
+
+type Bit =
+ | Bit of double
+ | Kb of double
+ | Mb of double
+ | Gb of double
+ | Tb of double
+ | Pb of double
+
+ member this.bytes =
+ match this with
+ | Bit.Bit i -> i
+ | Bit.Kb i -> i * 1000.0 / 8.0
+ | Bit.Mb i -> i * 1000.0 * 1000.0 / 8.0
+ | Bit.Gb i -> i * 1000.0 * 1000.0 * 1000.0 / 8.0
+ | Bit.Tb i -> i * 1000.0 * 1000.0 * 1000.0 * 1000.0 / 8.0
+ | Bit.Pb i -> i * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 / 8.0
+
+type Byte =
+ | Byte of double
+ | KB of double
+ | MB of double
+ | GB of double
+ | TB of double
+ | PB of double
+
+ | KiB of double
+ | MiB of double
+ | GiB of double
+ | TiB of double
+ | PiB of double
+
+ member this.bytes =
+ match this with
+ | Byte.Byte i -> i
+ | Byte.KB i -> i * 1000.0
+ | Byte.MB i -> i * 1000.0 * 1000.0
+ | Byte.GB i -> i * 1000.0 * 1000.0 * 1000.0
+ | Byte.TB i -> i * 1000.0 * 1000.0 * 1000.0 * 1000.0
+ | Byte.PB i -> i * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0
+
+ | Byte.KiB i -> i * 1024.0
+ | Byte.MiB i -> i * 1024.0 * 1024.0
+ | Byte.GiB i -> i * 1024.0 * 1024.0 * 1024.0
+ | Byte.TiB i -> i * 1024.0 * 1024.0 * 1024.0 * 1024.0
+ | Byte.PiB i -> i * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0
+
+type System.Double with
+ member this.bit = Bit this
+ member this.Kb = Bit this
+ member this.Mb = Mb this
+ member this.Gb = Gb this
+ member this.Tb = Tb this
+ member this.Pb = Pb this
+
+ member this.byte = Bit this
+ member this.KB = Bit this
+ member this.MB = Mb this
+ member this.GB = Gb this
+ member this.TB = Tb this
+ member this.PB = Pb this
+
+ member this.KiB = Bit this
+ member this.MiB = Mb this
+ member this.GiB = Gb this
+ member this.TiB = Tb this
+ member this.PiB = Pb this
+
+module =
+
+ type IECBitUnit =
+ | Bit
+ | Kilobit
+ | Megabit
+ | Gigabit
+ | Terabit
+ | Petabit
+
+ type IECByteUnit =
+ | Byte
+ | Kilobyte
+ | Kibibyte
+ | Megabyte
+ | Mebibyte
+ | Gigabyte
+ | Gibibyte
+ | Terabyte
+ | Tebibyte
+ | Petabyte
+ | Pebibyte
+
+ let private get_i_byte = function
+ | KB i | MB i | GB i | TB i | PB i
+ | KiB i | MiB i | GiB i | TiB i | PiB i
+ | Byte.Byte i -> i
+
+ let convert_bytes (scale: IECBitUnit) (old_value: Byte) =
+ let x = get_i_byte old_value
+ let up, base_ =
+ match old_value with
+ | Byte.Byte _ -> 0.0, 1000.0
+ | KB _ -> 1.0, 1000.0
+ | MB _ -> 2.0, 1000.0
+ | GB _ -> 3.0, 1000.0
+ | TB _ -> 4.0, 1000.0
+ | PB _ -> 5.0, 1000.0
+
+ | KiB _ -> 1.0, 1024.0
+ | MiB _ -> 2.0, 1024.0
+ | GiB _ -> 3.0, 1024.0
+ | TiB _ -> 4.0, 1024.0
+ | PiB _ -> 5.0, 1024.0
+
+ let down =
+ match scale with
+ | Bit -> 0.0
+ | Kilobit -> 1.0
+ | Megabit -> 2.0
+ | Gigabit -> 3.0
+ | Terabit -> 4.0
+ | Petabit -> 5.0
+
+ let new_value = x * 8.0 * (base_ ** (up - down))
+
+ match scale with
+ | Bit -> Bit.Bit new_value
+ | Kilobit -> Bit.Kb new_value
+ | Megabit -> Bit.Mb new_value
+ | Gigabit -> Bit.Gb new_value
+ | Terabit -> Bit.Tb new_value
+ | Petabit -> Bit.Pb new_value
+
+ let inline convert_bytes (scale: IECByteUnit) (old_value: Byte) =
+ let x = get_i_byte old_value
+ let up, base_ =
+ match old_value with
+ | KB _ -> 1.0, 1000.0
+ | MB _ -> 2.0, 1000.0
+ | GB _ -> 3.0, 1000.0
+ | TB _ -> 4.0, 1000.0
+ | PB _ -> 5.0, 1000.0
+
+ | KiB _ -> 1.0, 1024.0
+ | MiB _ -> 2.0, 1024.0
+ | GiB _ -> 3.0, 1024.0
+ | TiB _ -> 4.0, 1024.0
+ | PiB _ -> 5.0, 1024.0
+
+ | Byte.Byte _ -> 0.0, 1000.0
+
+ let down =
+ match scale with
+ | Kilobyte -> 1.0
+ | Megabyte -> 2.0
+ | Gigabyte -> 3.0
+ | Terabyte -> 4.0
+ | Petabyte -> 5.0
+
+ | Kibibyte -> 1.0
+ | Mebibyte -> 2.0
+ | Gibibyte -> 3.0
+ | Tebibyte -> 4.0
+ | Pebibyte -> 5.0
+
+ | Byte -> 0.0
+
+ let new_value = x * 8.0 * (base_ ** (up - down))
+
+ match scale with
+ | Byte -> Byte.Byte new_value
+ | Kilobyte -> KB new_value
+ | Megabyte -> MB new_value
+ | Gigabyte -> GB new_value
+ | Terabyte -> TB new_value
+ | Petabyte -> PB new_value
+
+ | Kibibyte -> KiB new_value
+ | Mebibyte -> MiB new_value
+ | Gibibyte -> GiB new_value
+ | Tebibyte -> TiB new_value
+ | Pebibyte -> PiB new_value
diff --git a/src/native.fs b/Pentole/native.fs
similarity index 100%
rename from src/native.fs
rename to Pentole/native.fs
diff --git a/src/option.fs b/Pentole/option.fs
similarity index 100%
rename from src/option.fs
rename to Pentole/option.fs
diff --git a/src/path.fs b/Pentole/path.fs
similarity index 93%
rename from src/path.fs
rename to Pentole/path.fs
index a6b69bd..c09feb8 100644
--- a/src/path.fs
+++ b/Pentole/path.fs
@@ -29,12 +29,12 @@ let private string_apply fun_ = function
| Absolute p -> fun_ p |> Absolute
| Relative p -> fun_ p |> Relative
- ///
- /// Return the parent path
- ///
- ///
+///
+/// Return the parent path
+///
+///
let parent (path: Path) =
- failwith "t"
+ failwith "TODO"
///
/// Return the extension of the given path
@@ -49,8 +49,8 @@ let extension = function
///
///
let basename = function
- | Absolute p ->System.IO.Path.GetFileNameWithoutExtension p
- | Relative p ->System.IO.Path.GetFileNameWithoutExtension p
+ | Absolute p -> System.IO.Path.GetFileNameWithoutExtension p
+ | Relative p -> System.IO.Path.GetFileNameWithoutExtension p
///
/// Concatenates `path` and `other` and adds a directory separator character between any of the path components if one is not already present.
diff --git a/src/pervasives.fs b/Pentole/pervasives.fs
similarity index 100%
rename from src/pervasives.fs
rename to Pentole/pervasives.fs
diff --git a/Pentole/readme.org b/Pentole/readme.org
new file mode 120000
index 0000000..4e17293
--- /dev/null
+++ b/Pentole/readme.org
@@ -0,0 +1 @@
+../readme.org
\ No newline at end of file
diff --git a/src/result.fs b/Pentole/result.fs
similarity index 100%
rename from src/result.fs
rename to Pentole/result.fs
diff --git a/src/string.fs b/Pentole/string.fs
similarity index 100%
rename from src/string.fs
rename to Pentole/string.fs
diff --git a/src/test_extensions.fs b/Pentole/test_extensions.fs
similarity index 100%
rename from src/test_extensions.fs
rename to Pentole/test_extensions.fs
diff --git a/pentole.sln b/pentole.sln
index 4f52b06..fd00966 100644
--- a/pentole.sln
+++ b/pentole.sln
@@ -3,10 +3,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "src", "src\src.fsproj", "{B6807554-26A8-44C1-9B51-4F29F66E439D}"
-EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "tests", "tests\tests.fsproj", "{48FCE2C1-5013-4574-8006-C56FEECEDBB5}"
EndProject
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Pentole", "Pentole\Pentole.fsproj", "{9B2AA44B-FAC3-4723-BF07-6767E766284A}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -16,13 +16,13 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {B6807554-26A8-44C1-9B51-4F29F66E439D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B6807554-26A8-44C1-9B51-4F29F66E439D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B6807554-26A8-44C1-9B51-4F29F66E439D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B6807554-26A8-44C1-9B51-4F29F66E439D}.Release|Any CPU.Build.0 = Release|Any CPU
{48FCE2C1-5013-4574-8006-C56FEECEDBB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48FCE2C1-5013-4574-8006-C56FEECEDBB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48FCE2C1-5013-4574-8006-C56FEECEDBB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48FCE2C1-5013-4574-8006-C56FEECEDBB5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9B2AA44B-FAC3-4723-BF07-6767E766284A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9B2AA44B-FAC3-4723-BF07-6767E766284A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9B2AA44B-FAC3-4723-BF07-6767E766284A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9B2AA44B-FAC3-4723-BF07-6767E766284A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/tests/bytes_tests.fs b/tests/bytes_tests.fs
new file mode 100644
index 0000000..f9e3c12
--- /dev/null
+++ b/tests/bytes_tests.fs
@@ -0,0 +1,11 @@
+module Tests.BinaryPrefix
+
+open NUnit.Framework
+
+open Pentole.TestsExtensions
+open Pentole.BinaryPrefix
+
+[]
+let split_test () =
+ Assert.are_equal (Bytes.KB 1) (Bytes.Byte 1000)
+ Assert.are_equal (Bytes.KiB 1) (Bytes.Byte 1024)
diff --git a/tests/tests.fsproj b/tests/tests.fsproj
index 5cb0d4d..bb59764 100644
--- a/tests/tests.fsproj
+++ b/tests/tests.fsproj
@@ -9,6 +9,7 @@
+
@@ -23,7 +24,7 @@
-
+