🎨Changed IReadOnlyFilesystem so methods that only output don't get passed as ref.

This commit is contained in:
2017-12-26 08:17:28 +00:00
parent 18f9a349c9
commit 56198b1ee6
24 changed files with 113 additions and 95 deletions

View File

@@ -36,8 +36,9 @@ namespace DiscImageChef.Filesystems.CPM
{
partial class CPM
{
public Errno GetAttributes(string path, ref FileAttributes attributes)
public Errno GetAttributes(string path, out FileAttributes attributes)
{
attributes = new FileAttributes();
if(!mounted) return Errno.AccessDenied;
string[] pathElements = path.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
@@ -59,8 +60,9 @@ namespace DiscImageChef.Filesystems.CPM
}
// TODO: Implementing this would require storing the interleaving
public Errno MapBlock(string path, long fileBlock, ref long deviceBlock)
public Errno MapBlock(string path, long fileBlock, out long deviceBlock)
{
deviceBlock = 0;
return !mounted ? Errno.AccessDenied : Errno.NotImplemented;
}
@@ -90,30 +92,29 @@ namespace DiscImageChef.Filesystems.CPM
return Errno.NoError;
}
public Errno ReadLink(string path, ref string dest)
public Errno ReadLink(string path, out string dest)
{
dest = null;
return !mounted ? Errno.AccessDenied : Errno.NotSupported;
}
public Errno Stat(string path, ref FileEntryInfo stat)
public Errno Stat(string path, out FileEntryInfo stat)
{
stat = null;
if(!mounted) return Errno.AccessDenied;
string[] pathElements = path.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1) return Errno.NotSupported;
if(string.IsNullOrEmpty(path) || string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) == 0)
{
if(labelCreationDate != null) stat.CreationTime = DateHandlers.CpmToDateTime(labelCreationDate);
if(labelUpdateDate != null) stat.StatusChangeTime = DateHandlers.CpmToDateTime(labelUpdateDate);
stat.Attributes = FileAttributes.Directory;
stat.BlockSize = XmlFsType.ClusterSize;
return Errno.NoError;
}
if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0)
return statCache.TryGetValue(pathElements[0].ToUpperInvariant(), out stat)
? Errno.NoError
: Errno.NoSuchFile;
return statCache.TryGetValue(pathElements[0].ToUpperInvariant(), out stat)
? Errno.NoError
: Errno.NoSuchFile;
stat = new FileEntryInfo {Attributes = FileAttributes.Directory, BlockSize = XmlFsType.ClusterSize};
if(labelCreationDate != null) stat.CreationTime = DateHandlers.CpmToDateTime(labelCreationDate);
if(labelUpdateDate != null) stat.StatusChangeTime = DateHandlers.CpmToDateTime(labelUpdateDate);
return Errno.NoError;
}
}
}