Пример #1
0
        public RPCResult <int> Read(tysos.lib.File f, long pos, byte[] dest, int dest_offset, int count)
        {
            int        bytes_read = 0;
            modfs_File mf         = f as modfs_File;

            if (pos < 0)
            {
                f.Error = tysos.lib.MonoIOError.ERROR_READ_FAULT;
                System.Diagnostics.Debugger.Log(0, "modfs", "Read Fault (pos = " + pos.ToString() + ")");
                return(-1);
            }

            System.Diagnostics.Debugger.Log(0, "modfs", "Reading from " + mf.name +
                                            ", pos: " + pos.ToString() +
                                            ", addr: " + (mf.mem.Addr64 + (ulong)pos).ToString("X") +
                                            ", length: " + ((long)mf.mem.Length64).ToString() +
                                            ", count: " + count.ToString());

            while (pos < (long)mf.mem.Length64 && bytes_read < count)
            {
                dest[dest_offset++] = (byte)mf.mem.Read(mf.mem.Addr64 + (ulong)pos, 1);
                pos++;
                bytes_read++;
            }

            System.Diagnostics.Debugger.Log(0, "modfs", "Read done");

            return(bytes_read);
        }
Пример #2
0
        public RPCResult <tysos.lib.File> Open(IList <string> path, System.IO.FileMode mode,
                                               System.IO.FileAccess access, System.IO.FileShare share,
                                               System.IO.FileOptions options)
        {
            if (path.Count == 0)
            {
                var ret = new tysos.lib.VirtualDirectory(this, "", children,
                                                         new tysos.lib.File.Property[] {
                    new tysos.lib.File.Property {
                        Name = "class", Value = "fs"
                    }
                });
            }

            // modfs has only one level
            if (path.Count != 1)
            {
                return(new tysos.lib.ErrorFile(tysos.lib.MonoIOError.ERROR_FILE_NOT_FOUND));
            }

            foreach (tysos.lib.File.Property p in mods)
            {
                if (p.Name == path[0])
                {
                    modfs_File f = new modfs_File(this);
                    f.name  = p.Name;
                    f.mem   = p.Value as tysos.VirtualMemoryResource64;
                    f.Error = tysos.lib.MonoIOError.ERROR_SUCCESS;

                    System.Diagnostics.Debugger.Log(0, "modfs", "Request for " +
                                                    path[0] + " returning " +
                                                    f.mem.ToString());
                    return(f);
                }
            }

            return(new tysos.lib.ErrorFile(tysos.lib.MonoIOError.ERROR_FILE_NOT_FOUND));
        }