From 5300250a28f3f9f51f8a062ce10b7c1a9293f542 Mon Sep 17 00:00:00 2001 From: Valentin Charbonnier Date: Sat, 12 Aug 2017 18:51:21 +0200 Subject: [PATCH 1/5] GetVolumes mSize fix. --- source/Cosmos.System2/FileSystem/CosmosVFS.cs | 4 +++- source/Cosmos.System2/FileSystem/FAT/FatFileSystem.cs | 6 +++--- .../FileSystem/FAT/Listing/FatDiretoryEntry.cs | 2 +- source/Cosmos.System2/FileSystem/FileSystem.cs | 5 ++++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/source/Cosmos.System2/FileSystem/CosmosVFS.cs b/source/Cosmos.System2/FileSystem/CosmosVFS.cs index 534c493f5..e406f18ba 100644 --- a/source/Cosmos.System2/FileSystem/CosmosVFS.cs +++ b/source/Cosmos.System2/FileSystem/CosmosVFS.cs @@ -355,10 +355,12 @@ namespace Cosmos.System.FileSystem for (int i = 0; i < mPartitions.Count; i++) { string xRootPath = string.Concat(i, VolumeSeparatorChar, DirectorySeparatorChar); + ulong Size = mPartitions[i].BlockCount * mPartitions[i].BlockSize / 1024 / 1024; + long xSize = (long)Size; switch (FileSystem.GetFileSystemType(mPartitions[i])) { case FileSystemType.FAT: - mFileSystems.Add(new FatFileSystem(mPartitions[i], xRootPath)); + mFileSystems.Add(new FatFileSystem(mPartitions[i], xRootPath, xSize)); break; default: global::System.Console.WriteLine("Unknown filesystem type!"); diff --git a/source/Cosmos.System2/FileSystem/FAT/FatFileSystem.cs b/source/Cosmos.System2/FileSystem/FAT/FatFileSystem.cs index 44929705c..21c513a8f 100644 --- a/source/Cosmos.System2/FileSystem/FAT/FatFileSystem.cs +++ b/source/Cosmos.System2/FileSystem/FAT/FatFileSystem.cs @@ -359,8 +359,8 @@ namespace Cosmos.System.FileSystem.FAT /// The partition. /// The root path. /// FAT signature not found. - public FatFileSystem(Partition aDevice, string aRootPath) - : base(aDevice, aRootPath) + public FatFileSystem(Partition aDevice, string aRootPath, long aSize) + : base(aDevice, aRootPath, aSize) { if (aDevice == null) { @@ -603,7 +603,7 @@ namespace Cosmos.System.FileSystem.FAT { Global.mFileSystemDebugger.SendInternal("-- FatFileSystem.GetRootDirectory --"); - var xRootEntry = new FatDirectoryEntry(this, null, mRootPath, mRootPath, RootCluster); + var xRootEntry = new FatDirectoryEntry(this, null, mRootPath, mSize, mRootPath, RootCluster); return xRootEntry; } diff --git a/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs b/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs index c36b8356c..dd80fb80d 100644 --- a/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs +++ b/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs @@ -44,7 +44,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing string aFullPath, string aName, uint aFirstCluster) - : base(aFileSystem, aParent, aFullPath, aName, 0, DirectoryEntryTypeEnum.Directory) + : base(aFileSystem, aParent, aFullPath, aName, aSize, DirectoryEntryTypeEnum.Directory) { if (aFirstCluster < aFileSystem.RootCluster) { diff --git a/source/Cosmos.System2/FileSystem/FileSystem.cs b/source/Cosmos.System2/FileSystem/FileSystem.cs index 03a92ddac..5486127f2 100644 --- a/source/Cosmos.System2/FileSystem/FileSystem.cs +++ b/source/Cosmos.System2/FileSystem/FileSystem.cs @@ -9,10 +9,11 @@ namespace Cosmos.System.FileSystem { public abstract class FileSystem { - protected FileSystem(Partition aDevice, string aRootPath) + protected FileSystem(Partition aDevice, string aRootPath, long aSize) { mDevice = aDevice; mRootPath = aRootPath; + mSize = aSize; } public static FileSystemType GetFileSystemType(Partition aDevice) @@ -42,5 +43,7 @@ namespace Cosmos.System.FileSystem protected Partition mDevice { get; } public string mRootPath { get; } + + public long mSize { get; } } } From d9e45ce26b5446fd1096042ba30f710882a91550 Mon Sep 17 00:00:00 2001 From: Valentin Charbonnier Date: Sat, 12 Aug 2017 19:07:40 +0200 Subject: [PATCH 2/5] Fix. --- source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs b/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs index dd80fb80d..66633ac09 100644 --- a/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs +++ b/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs @@ -42,6 +42,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing FatFileSystem aFileSystem, FatDirectoryEntry aParent, string aFullPath, + long aSize, string aName, uint aFirstCluster) : base(aFileSystem, aParent, aFullPath, aName, aSize, DirectoryEntryTypeEnum.Directory) From f827994340c55049bbe884bdbbdd45f9988ac52e Mon Sep 17 00:00:00 2001 From: Valentin Charbonnier Date: Sat, 12 Aug 2017 19:36:32 +0200 Subject: [PATCH 3/5] long changed to ulong. --- source/Cosmos.System2/FileSystem/CosmosVFS.cs | 2 +- source/Cosmos.System2/FileSystem/FAT/FatFileSystem.cs | 2 +- .../FileSystem/FAT/Listing/FatDiretoryEntry.cs | 8 ++++---- source/Cosmos.System2/FileSystem/FileSystem.cs | 4 ++-- .../Cosmos.System2/FileSystem/Listing/DirectoryEntry.cs | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source/Cosmos.System2/FileSystem/CosmosVFS.cs b/source/Cosmos.System2/FileSystem/CosmosVFS.cs index e406f18ba..056eef326 100644 --- a/source/Cosmos.System2/FileSystem/CosmosVFS.cs +++ b/source/Cosmos.System2/FileSystem/CosmosVFS.cs @@ -360,7 +360,7 @@ namespace Cosmos.System.FileSystem switch (FileSystem.GetFileSystemType(mPartitions[i])) { case FileSystemType.FAT: - mFileSystems.Add(new FatFileSystem(mPartitions[i], xRootPath, xSize)); + mFileSystems.Add(new FatFileSystem(mPartitions[i], xRootPath, (ulong)xSize)); break; default: global::System.Console.WriteLine("Unknown filesystem type!"); diff --git a/source/Cosmos.System2/FileSystem/FAT/FatFileSystem.cs b/source/Cosmos.System2/FileSystem/FAT/FatFileSystem.cs index 21c513a8f..694c6ec76 100644 --- a/source/Cosmos.System2/FileSystem/FAT/FatFileSystem.cs +++ b/source/Cosmos.System2/FileSystem/FAT/FatFileSystem.cs @@ -359,7 +359,7 @@ namespace Cosmos.System.FileSystem.FAT /// The partition. /// The root path. /// FAT signature not found. - public FatFileSystem(Partition aDevice, string aRootPath, long aSize) + public FatFileSystem(Partition aDevice, string aRootPath, ulong aSize) : base(aDevice, aRootPath, aSize) { if (aDevice == null) diff --git a/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs b/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs index 66633ac09..9839f7927 100644 --- a/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs +++ b/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs @@ -23,7 +23,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing FatDirectoryEntry aParent, string aFullPath, string aName, - long aSize, + ulong aSize, uint aFirstCluster, uint aEntryHeaderDataOffset, DirectoryEntryTypeEnum aEntryType) @@ -42,7 +42,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing FatFileSystem aFileSystem, FatDirectoryEntry aParent, string aFullPath, - long aSize, + ulong aSize, string aName, uint aFirstCluster) : base(aFileSystem, aParent, aFullPath, aName, aSize, DirectoryEntryTypeEnum.Directory) @@ -61,7 +61,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing Global.mFileSystemDebugger.SendInternal("-- FatDirectoryEntry.GetFatTable --"); var xFat = ((FatFileSystem)mFileSystem).GetFat(0); - return xFat?.GetFatChain(mFirstClusterNum, mSize); + return xFat?.GetFatChain(mFirstClusterNum, (long)mSize); } public FatFileSystem GetFileSystem() @@ -110,7 +110,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing } SetDirectoryEntryMetadataValue(FatDirectoryEntryMetadata.Size, aSize); - mSize = aSize; + mSize = (ulong)aSize; } private void AllocateDirectoryEntry(string aShortName) diff --git a/source/Cosmos.System2/FileSystem/FileSystem.cs b/source/Cosmos.System2/FileSystem/FileSystem.cs index 5486127f2..bf884140b 100644 --- a/source/Cosmos.System2/FileSystem/FileSystem.cs +++ b/source/Cosmos.System2/FileSystem/FileSystem.cs @@ -9,7 +9,7 @@ namespace Cosmos.System.FileSystem { public abstract class FileSystem { - protected FileSystem(Partition aDevice, string aRootPath, long aSize) + protected FileSystem(Partition aDevice, string aRootPath, ulong aSize) { mDevice = aDevice; mRootPath = aRootPath; @@ -44,6 +44,6 @@ namespace Cosmos.System.FileSystem public string mRootPath { get; } - public long mSize { get; } + public ulong mSize { get; } } } diff --git a/source/Cosmos.System2/FileSystem/Listing/DirectoryEntry.cs b/source/Cosmos.System2/FileSystem/Listing/DirectoryEntry.cs index 4ac7ef2cb..5a9d92f17 100644 --- a/source/Cosmos.System2/FileSystem/Listing/DirectoryEntry.cs +++ b/source/Cosmos.System2/FileSystem/Listing/DirectoryEntry.cs @@ -29,7 +29,7 @@ namespace Cosmos.System.FileSystem.Listing /// public abstract class DirectoryEntry { - public long mSize; + public ulong mSize; public string mFullPath; public string mName; protected readonly FileSystem mFileSystem; @@ -51,7 +51,7 @@ namespace Cosmos.System.FileSystem.Listing /// /// /// - protected DirectoryEntry(FileSystem aFileSystem, DirectoryEntry aParent, string aFullPath, string aName, long aSize, DirectoryEntryTypeEnum aEntryType) + protected DirectoryEntry(FileSystem aFileSystem, DirectoryEntry aParent, string aFullPath, string aName, ulong aSize, DirectoryEntryTypeEnum aEntryType) { if (aFileSystem == null) { From 9e198d1ba71ad2ad68569b7b391a0ef0e40bea2a Mon Sep 17 00:00:00 2001 From: Valentin Charbonnier Date: Sun, 13 Aug 2017 20:56:03 +0200 Subject: [PATCH 4/5] Revert "long changed to ulong." This reverts commit f827994340c55049bbe884bdbbdd45f9988ac52e. Revert. --- source/Cosmos.System2/FileSystem/CosmosVFS.cs | 2 +- source/Cosmos.System2/FileSystem/FAT/FatFileSystem.cs | 2 +- .../FileSystem/FAT/Listing/FatDiretoryEntry.cs | 8 ++++---- source/Cosmos.System2/FileSystem/FileSystem.cs | 4 ++-- .../Cosmos.System2/FileSystem/Listing/DirectoryEntry.cs | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source/Cosmos.System2/FileSystem/CosmosVFS.cs b/source/Cosmos.System2/FileSystem/CosmosVFS.cs index 056eef326..e406f18ba 100644 --- a/source/Cosmos.System2/FileSystem/CosmosVFS.cs +++ b/source/Cosmos.System2/FileSystem/CosmosVFS.cs @@ -360,7 +360,7 @@ namespace Cosmos.System.FileSystem switch (FileSystem.GetFileSystemType(mPartitions[i])) { case FileSystemType.FAT: - mFileSystems.Add(new FatFileSystem(mPartitions[i], xRootPath, (ulong)xSize)); + mFileSystems.Add(new FatFileSystem(mPartitions[i], xRootPath, xSize)); break; default: global::System.Console.WriteLine("Unknown filesystem type!"); diff --git a/source/Cosmos.System2/FileSystem/FAT/FatFileSystem.cs b/source/Cosmos.System2/FileSystem/FAT/FatFileSystem.cs index 694c6ec76..21c513a8f 100644 --- a/source/Cosmos.System2/FileSystem/FAT/FatFileSystem.cs +++ b/source/Cosmos.System2/FileSystem/FAT/FatFileSystem.cs @@ -359,7 +359,7 @@ namespace Cosmos.System.FileSystem.FAT /// The partition. /// The root path. /// FAT signature not found. - public FatFileSystem(Partition aDevice, string aRootPath, ulong aSize) + public FatFileSystem(Partition aDevice, string aRootPath, long aSize) : base(aDevice, aRootPath, aSize) { if (aDevice == null) diff --git a/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs b/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs index 9839f7927..66633ac09 100644 --- a/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs +++ b/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs @@ -23,7 +23,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing FatDirectoryEntry aParent, string aFullPath, string aName, - ulong aSize, + long aSize, uint aFirstCluster, uint aEntryHeaderDataOffset, DirectoryEntryTypeEnum aEntryType) @@ -42,7 +42,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing FatFileSystem aFileSystem, FatDirectoryEntry aParent, string aFullPath, - ulong aSize, + long aSize, string aName, uint aFirstCluster) : base(aFileSystem, aParent, aFullPath, aName, aSize, DirectoryEntryTypeEnum.Directory) @@ -61,7 +61,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing Global.mFileSystemDebugger.SendInternal("-- FatDirectoryEntry.GetFatTable --"); var xFat = ((FatFileSystem)mFileSystem).GetFat(0); - return xFat?.GetFatChain(mFirstClusterNum, (long)mSize); + return xFat?.GetFatChain(mFirstClusterNum, mSize); } public FatFileSystem GetFileSystem() @@ -110,7 +110,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing } SetDirectoryEntryMetadataValue(FatDirectoryEntryMetadata.Size, aSize); - mSize = (ulong)aSize; + mSize = aSize; } private void AllocateDirectoryEntry(string aShortName) diff --git a/source/Cosmos.System2/FileSystem/FileSystem.cs b/source/Cosmos.System2/FileSystem/FileSystem.cs index bf884140b..5486127f2 100644 --- a/source/Cosmos.System2/FileSystem/FileSystem.cs +++ b/source/Cosmos.System2/FileSystem/FileSystem.cs @@ -9,7 +9,7 @@ namespace Cosmos.System.FileSystem { public abstract class FileSystem { - protected FileSystem(Partition aDevice, string aRootPath, ulong aSize) + protected FileSystem(Partition aDevice, string aRootPath, long aSize) { mDevice = aDevice; mRootPath = aRootPath; @@ -44,6 +44,6 @@ namespace Cosmos.System.FileSystem public string mRootPath { get; } - public ulong mSize { get; } + public long mSize { get; } } } diff --git a/source/Cosmos.System2/FileSystem/Listing/DirectoryEntry.cs b/source/Cosmos.System2/FileSystem/Listing/DirectoryEntry.cs index 5a9d92f17..4ac7ef2cb 100644 --- a/source/Cosmos.System2/FileSystem/Listing/DirectoryEntry.cs +++ b/source/Cosmos.System2/FileSystem/Listing/DirectoryEntry.cs @@ -29,7 +29,7 @@ namespace Cosmos.System.FileSystem.Listing /// public abstract class DirectoryEntry { - public ulong mSize; + public long mSize; public string mFullPath; public string mName; protected readonly FileSystem mFileSystem; @@ -51,7 +51,7 @@ namespace Cosmos.System.FileSystem.Listing /// /// /// - protected DirectoryEntry(FileSystem aFileSystem, DirectoryEntry aParent, string aFullPath, string aName, ulong aSize, DirectoryEntryTypeEnum aEntryType) + protected DirectoryEntry(FileSystem aFileSystem, DirectoryEntry aParent, string aFullPath, string aName, long aSize, DirectoryEntryTypeEnum aEntryType) { if (aFileSystem == null) { From 9d462b60f53deb2b25bdf1a42cc9cd511ed5b80d Mon Sep 17 00:00:00 2001 From: Valentin Charbonnier Date: Sun, 13 Aug 2017 23:36:15 +0200 Subject: [PATCH 5/5] Changes. --- source/Cosmos.System2/FileSystem/CosmosVFS.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/Cosmos.System2/FileSystem/CosmosVFS.cs b/source/Cosmos.System2/FileSystem/CosmosVFS.cs index e406f18ba..1d062af11 100644 --- a/source/Cosmos.System2/FileSystem/CosmosVFS.cs +++ b/source/Cosmos.System2/FileSystem/CosmosVFS.cs @@ -355,8 +355,7 @@ namespace Cosmos.System.FileSystem for (int i = 0; i < mPartitions.Count; i++) { string xRootPath = string.Concat(i, VolumeSeparatorChar, DirectorySeparatorChar); - ulong Size = mPartitions[i].BlockCount * mPartitions[i].BlockSize / 1024 / 1024; - long xSize = (long)Size; + var xSize = (long)(mPartitions[i].BlockCount * mPartitions[i].BlockSize / 1024 / 1024); switch (FileSystem.GetFileSystemType(mPartitions[i])) { case FileSystemType.FAT: