Пример #1
0
        internal IFolder GetFolder(string dest, bool createAllowed,
                                   IFolder start = null)
        {
            const char separator = '/';
            var        current   = start ?? root;

            foreach (var part in dest.Split(separator))
            {
                if (string.IsNullOrWhiteSpace(part))
                {
                    continue;
                }
                var item = current[part] as IFolder;
                if (item != null)
                {
                    current = item;
                    continue;
                }
                if (!createAllowed)
                {
                    return(null);
                }
                var parent = current as VfsFolder;
                parent[part] = current = new VfsFolder(part, parent);
            }
            return(current);
        }
Пример #2
0
 IReadOnlyList <IUnixFileSystemEntry> GetEntries(
     VirtualDirectory folder, VfsFolder model)
 => model.Folders.OfType <IEntry>().Concat(model.Files)
 .Select(v => v.ToEntry(this, folder))
 .ToList().AsReadOnly();