Example #1
0
        public IFileInfo GetFileInfo(string subpath)
        {
            IFileInfo info;
            bool found = fileInfoCache.TryGet(subpath, out info);
            if (!found)
            {
                info = provider.GetFileInfo(subpath);

                if (info.Exists)
                {
                    if (info.IsDirectory)
                    {
                        info = new AnotherDirectoryInfo(info.LastModified, info.Name, info.PhysicalPath);
                    }
                    else
                    {
                        info = new AnotherFileInfo(this, subpath, info.LastModified, info.Length, info.Name, info.PhysicalPath);
                    }
                }
                else
                {
                    //Use the NotFoundFileInfo object returned by the internal provider
                }
                fileInfoCache.Add(subpath, info);
            }

            return info;
        }
Example #2
0
        public IDirectoryContents GetDirectoryContents(string subpath)
        {
            IDirectoryContents contents;
            bool found = directoryContentsCache.TryGet(subpath, out contents);
            if (!found)
            {
                contents = provider.GetDirectoryContents(subpath);
                if (contents.Exists)
                {
                    LinkedList<IFileInfo> fileInfos = new LinkedList<IFileInfo>();
                    foreach (var i in contents)
                    {
                        IFileInfo info = new AnotherFileInfo(this, subpath + Path.DirectorySeparatorChar + i.Name, i.LastModified, i.Length, i.Name, i.PhysicalPath);
                        fileInfos.Append(info);
                    }
                    contents = new AnotherDirectoryContents(fileInfos);
                }
                else
                {
                    //Use the NotFoundDirectoryContents object returned by the internal provider
                }
                directoryContentsCache.Add(subpath, contents);
            }

            return contents;
        }