예제 #1
0
                public bool RemoveDevice(Device.CharacterDevice device)
                {
                    int id = device.Id;

                    if (!DevicesById.ContainsKey(id))
                    {
                        return(false);
                    }
                    DevicesById.Remove(id);
                    string type = device.DeviceType();

                    DevicesByType[type].Remove(device);
                    if (DevicesByType[type].Count == 0)
                    {
                        DevicesByType.Remove(type);
                    }
                    return(true);
                }
예제 #2
0
                public Stream OpenFile(NixPath path, FileAccess access, FileMode mode)
                {
                    string openPath = GetPathTo(path);
                    int    deviceId = GetDeviceId(path);

                    if (deviceId != -1)
                    {
                        //return MainSystem.MainDeviceManager.FindDevice(deviceId);
                        Device.CharacterDevice device = MainSystem.MainDeviceManager.FindDevice(deviceId);
                        if (device != null)
                        {
                            return(device.CreateStream());
                        }
                        return(null);
                    }
                    else
                    {
                        return(File.Open(openPath, mode, access));
                    }
                    return(null);
                }
예제 #3
0
                public bool AddDevice(Device.CharacterDevice device)
                {
                    if (device.Id == -1)
                    {
                        device.Id = Counter;
                    }
                    if (DevicesById.ContainsKey(device.Id))
                    {
                        return(false);
                    }
                    DevicesById[device.Id] = device;

                    string type = device.DeviceType();

                    if (!DevicesByType.ContainsKey(type))
                    {
                        DevicesByType[type] = new List <Device.CharacterDevice>();
                    }
                    DevicesByType[type].Add(device);
                    return(true);
                }