public static long Read(ServiceCtx Context) { AmIStorageAccessor Accessor = Context.GetObject <AmIStorageAccessor>(); AmIStorage Storage = Accessor.Storage; long ReadPosition = Context.RequestData.ReadInt64(); if (Context.Request.RecvListBuff.Count > 0) { long Position = Context.Request.RecvListBuff[0].Position; short Size = Context.Request.RecvListBuff[0].Size; byte[] Data; if (Storage.Data.Length > Size) { Data = new byte[Size]; Buffer.BlockCopy(Storage.Data, 0, Data, 0, Size); } else { Data = Storage.Data; } AMemoryHelper.WriteBytes(Context.Memory, Position, Data); } return(0); }
public static long Read(ServiceCtx Context) { FspSrvIStorage Storage = Context.GetObject <FspSrvIStorage>(); long Offset = Context.RequestData.ReadInt64(); long Size = Context.RequestData.ReadInt64(); if (Context.Request.ReceiveBuff.Count > 0) { IpcBuffDesc BuffDesc = Context.Request.ReceiveBuff[0]; //Use smaller length to avoid overflows. if (Size > BuffDesc.Size) { Size = BuffDesc.Size; } byte[] Data = new byte[Size]; Storage.BaseStream.Seek(Offset, SeekOrigin.Begin); Storage.BaseStream.Read(Data, 0, Data.Length); AMemoryHelper.WriteBytes(Context.Memory, BuffDesc.Position, Data); } return(0); }
public static long GetSize(ServiceCtx Context) { AmIStorageAccessor Accessor = Context.GetObject <AmIStorageAccessor>(); Context.ResponseData.Write((long)Accessor.Storage.Data.Length); return(0); }
public static long Open(ServiceCtx Context) { AmIStorage Storage = Context.GetObject <AmIStorage>(); MakeObject(Context, new AmIStorageAccessor(Storage)); return(0); }
public static long Write(ServiceCtx Context) { FspSrvIFile File = Context.GetObject <FspSrvIFile>(); long Position = Context.Request.SendBuff[0].Position; long Zero = Context.RequestData.ReadInt64(); long Offset = Context.RequestData.ReadInt64(); long Size = Context.RequestData.ReadInt64(); byte[] Data = AMemoryHelper.ReadBytes(Context.Memory, Position, (int)Size); File.BaseStream.Seek(Offset, SeekOrigin.Begin); File.BaseStream.Write(Data, 0, (int)Size); return(0); }
public static long GetEntryType(ServiceCtx Context) { FspSrvIFileSystem FileSystem = Context.GetObject <FspSrvIFileSystem>(); long Position = Context.Request.PtrBuff[0].Position; string Name = AMemoryHelper.ReadAsciiString(Context.Memory, Position); string FileName = Context.Ns.VFs.GetFullPath(FileSystem.FilePath, Name); if (FileName == null) { //TODO: Correct error code. return(-1); } bool IsFile = File.Exists(FileName); Context.ResponseData.Write(IsFile ? 1 : 0); return(0); }
public static long Read(ServiceCtx Context) { FspSrvIFile File = Context.GetObject <FspSrvIFile>(); long Position = Context.Request.ReceiveBuff[0].Position; long Zero = Context.RequestData.ReadInt64(); long Offset = Context.RequestData.ReadInt64(); long Size = Context.RequestData.ReadInt64(); byte[] Data = new byte[Size]; int ReadSize = File.BaseStream.Read(Data, 0, (int)Size); AMemoryHelper.WriteBytes(Context.Memory, Position, Data); //TODO: Use ReadSize, we need to return the size that was REALLY read from the file. //This is a workaround because we are doing something wrong and the game expects to read //data from a file that doesn't yet exists -- and breaks if it can't read anything. Context.ResponseData.Write((long)Size); return(0); }
public static long OpenFile(ServiceCtx Context) { FspSrvIFileSystem FileSystem = Context.GetObject <FspSrvIFileSystem>(); long Position = Context.Request.PtrBuff[0].Position; int FilterFlags = Context.RequestData.ReadInt32(); string Name = AMemoryHelper.ReadAsciiString(Context.Memory, Position); string FileName = Context.Ns.VFs.GetFullPath(FileSystem.FilePath, Name); if (FileName == null) { //TODO: Correct error code. return(-1); } FileStream Stream = new FileStream(FileName, FileMode.OpenOrCreate); MakeObject(Context, new FspSrvIFile(Stream)); return(0); }