X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;ds=sidebyside;f=labo2-fsharp%2FCryptoFile%2FAPI.fs;h=f72395b43de8236a84508aaec2756e32038338c0;hb=8e04e7140bd58f941930dc15b890236f8a20c67b;hp=886b0d927b01d332fef164c3fdc4f6d44b6cd53d;hpb=95f772ef77baee15929c1feccc4de4c9a795f81d;p=crypto_lab2.git diff --git a/labo2-fsharp/CryptoFile/API.fs b/labo2-fsharp/CryptoFile/API.fs index 886b0d9..f72395b 100644 --- a/labo2-fsharp/CryptoFile/API.fs +++ b/labo2-fsharp/CryptoFile/API.fs @@ -9,7 +9,7 @@ type internal Metadata (d: (string * string) list) = new (stream : Stream) = let reader = new BinaryReader (stream) let length = reader.ReadByte () |> int - Metadata ([for i in 1..length -> reader.ReadString (), reader.ReadString ()]) + Metadata ([for _ in 1..length -> reader.ReadString (), reader.ReadString ()]) // Write metadata to a stream. member this.WriteTo (stream : Stream) = @@ -93,12 +93,12 @@ module API = // Decrypt metadata. inputStream.Position <- 32L + 256L + 256L use cryptoStream = Crypto.decryptAES keyAES iv inputStream - let metadata = Metadata (cryptoStream) + let metadata = Metadata cryptoStream // Create the file and write its content and metadata. let filePath = Path.Combine (targetDirPath, metadata.get MetadataKeys.filename) let modificationTime = DateTime (metadata.get MetadataKeys.modificationTime |> int64) - let fileInfo = FileInfo (filePath) + let fileInfo = FileInfo filePath using (fileInfo.Create ()) <| fun outputStream -> cryptoStream.CopyTo outputStream fileInfo.LastWriteTimeUtc <- modificationTime \ No newline at end of file