mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
* DiscImageChef.DiscImages/CPCDSK.cs:
* DiscImageChef.DiscImages/DiscImageChef.DiscImages.csproj: Added CPCEMU Disk File and Extended Disk File. * TODO: * README.md: * DiscImageChef.Filesystems/CPM/CPM.cs: * DiscImageChef.Filesystems/CPM/Dir.cs: * DiscImageChef.Filesystems/CPM/Info.cs: * DiscImageChef.Filesystems/CPM/File.cs: * DiscImageChef.Filesystems/CPM/Xattr.cs: * DiscImageChef.Filesystems/CPM/Super.cs: * DiscImageChef.Filesystems/CPM/Consts.cs: * DiscImageChef.Filesystems/CPM/Structs.cs: * DiscImageChef.Filesystems/CPM/cpmdefs.xml: * DiscImageChef.Filesystems/CPM/Definitions.cs: * DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj: Added CP/M filesystem, closes #29.
This commit is contained in:
@@ -5,11 +5,11 @@
|
||||
// Filename : File.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Component
|
||||
// Component : CP/M filesystem plugin.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Description
|
||||
// Methods to handle files.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
@@ -29,14 +29,117 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2016 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace DiscImageChef.Filesystems.CPM
|
||||
{
|
||||
public class File
|
||||
partial class CPM : Filesystem
|
||||
{
|
||||
public File()
|
||||
public override Errno GetAttributes(string path, ref FileAttributes attributes)
|
||||
{
|
||||
if(!mounted)
|
||||
return Errno.AccessDenied;
|
||||
|
||||
string[] pathElements = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if(pathElements.Length != 1)
|
||||
return Errno.NotSupported;
|
||||
|
||||
FileEntryInfo fInfo;
|
||||
|
||||
if(string.IsNullOrEmpty(pathElements[0]) || string.Compare(pathElements[0], "/", StringComparison.OrdinalIgnoreCase) == 0)
|
||||
{
|
||||
attributes = new FileAttributes();
|
||||
attributes = FileAttributes.Directory;
|
||||
return Errno.NoError;
|
||||
}
|
||||
|
||||
if(statCache.TryGetValue(pathElements[0].ToUpperInvariant(), out fInfo))
|
||||
{
|
||||
attributes = fInfo.Attributes;
|
||||
return Errno.NoError;
|
||||
}
|
||||
|
||||
return Errno.NoSuchFile;
|
||||
}
|
||||
|
||||
public override Errno MapBlock(string path, long fileBlock, ref long deviceBlock)
|
||||
{
|
||||
if(!mounted)
|
||||
return Errno.AccessDenied;
|
||||
|
||||
// TODO: Implementing this would require storing the interleaving
|
||||
return Errno.NotImplemented;
|
||||
}
|
||||
|
||||
public override Errno Read(string path, long offset, long size, ref byte[] buf)
|
||||
{
|
||||
if(!mounted)
|
||||
return Errno.AccessDenied;
|
||||
|
||||
if(size == 0)
|
||||
{
|
||||
buf = new byte[0];
|
||||
return Errno.NoError;
|
||||
}
|
||||
|
||||
if(offset < 0)
|
||||
return Errno.InvalidArgument;
|
||||
|
||||
string[] pathElements = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if(pathElements.Length != 1)
|
||||
return Errno.NotSupported;
|
||||
|
||||
byte[] file;
|
||||
|
||||
if(!fileCache.TryGetValue(pathElements[0].ToUpperInvariant(), out file))
|
||||
return Errno.NoSuchFile;
|
||||
|
||||
if(offset >= file.Length)
|
||||
return Errno.EINVAL;
|
||||
|
||||
if(size + offset >= file.Length)
|
||||
size = file.Length - offset;
|
||||
|
||||
buf = new byte[size];
|
||||
Array.Copy(file, offset, buf, 0, size);
|
||||
return Errno.NoError;
|
||||
}
|
||||
|
||||
public override Errno ReadLink(string path, ref string dest)
|
||||
{
|
||||
if(!mounted)
|
||||
return Errno.AccessDenied;
|
||||
|
||||
return Errno.NotSupported;
|
||||
}
|
||||
|
||||
public override Errno Stat(string path, ref FileEntryInfo stat)
|
||||
{
|
||||
if(!mounted)
|
||||
return Errno.AccessDenied;
|
||||
|
||||
string[] pathElements = path.Split(new char[] { '/' }, 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(statCache.TryGetValue(pathElements[0].ToUpperInvariant(), out stat))
|
||||
return Errno.NoError;
|
||||
|
||||
return Errno.NoSuchFile;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user