Esempio n. 1
0
    public Stream Open(FileEntry file, FileMode mode, FileAccess access, FileShare share)
    {
        var p      = mountPoint.GetRelativePathTo(file);
        var myFile = file as MyFileEntry;

        if (myFile == null)
        {
            throw new FileNotFoundException("device '" + file.FullName + "' was not created by this file system");
        }
        var device = os.Devices.FirstOrDefault(d => d.guid == myFile.guid);

        if (device == null)
        {
            throw new FileNotFoundException("device '" + file.FullName + "' not found");
        }

        if (access == FileAccess.Read)
        {
            return(device.OpenRead());
        }
        if (access == FileAccess.Write)
        {
            return(device.OpenWrite());
        }

        throw new NotImplementedException(FileAccess.ReadWrite + " is not implemented");
    }
Esempio n. 2
0
    public void UpdateDirectoryInfo(DirEntry.UpdateHandle dir)
    {
        var path = mountPoint.GetRelativePathTo(dir.DirEntry);

        ulong id = 0;

        GetEntry(path, ref id);

        var filtered = entries.Where(e => e.Value.parentId == id).ToArray();
        var files    = filtered.Where(e => fileContents.ContainsKey(e.Key)).ToArray();
        var dirs     = filtered.Except(files).ToArray();

        foreach (var d in dirs)
        {
            dir.AddDirectory(d.Value.name);
        }
        foreach (var f in files)
        {
            dir.AddFile(f.Value.name);
        }
    }