internal void UpdateCache(VfsDirectoryInfo info)
 {
     string key = info.FullName.TrimEnd('\\');
     lock (_directories)
     {
         _directories[key] = info;
     }
 }
        internal void UpdateCache(VfsDirectoryInfo info)
        {
            string key = info.FullName.TrimEnd('\\');

            lock (_directories)
            {
                _directories[key] = info;
            }
        }
 public DirectoryInfoBase FromDirectoryName(string directoryName)
 {
     string key = directoryName.TrimEnd('\\');
     VfsDirectoryInfo result;
     lock (_directories)
     {
         if (!_directories.TryGetValue(key, out result))
         {
             _directories[key] = result = new VfsDirectoryInfo(_fileSystem, new DirectoryInfo(directoryName));
         }
     }
     return result;
 }
        public DirectoryInfoBase FromDirectoryName(string directoryName)
        {
            string           key = directoryName.TrimEnd('\\');
            VfsDirectoryInfo result;

            lock (_directories)
            {
                if (!_directories.TryGetValue(key, out result))
                {
                    _directories[key] = result = new VfsDirectoryInfo(_fileSystem, new DirectoryInfo(directoryName));
                }
            }
            return(result);
        }
Exemple #5
0
        private FileSystemInfoBase[] GetFileSystemInfosInternal()
        {
            if (_infos == null)
            {
                using (var client = VfsUtils.NewHttpClient(_href, _fileSystem._creds))
                {
                    using (HttpResponseMessage response = client.GetAsync(_href.AbsolutePath).Result)
                    {
                        if (response.StatusCode == HttpStatusCode.NotFound)
                        {
                            throw new DirectoryNotFoundException(this.FullName + " does not exists.");
                        }

                        response.EnsureSuccessful();

                        if (response.Content.Headers.ContentType.MediaType != "application/json")
                        {
                            throw new IOException("The directory name is invalid.");
                        }

                        var array = response.Content.ReadAsAsync <VfsJsonFileSystemInfo[]>().Result;
                        _infos = array.Select(json =>
                        {
                            FileSystemInfoBase info;
                            if (json.Mime == "inode/directory")
                            {
                                info = new VfsDirectoryInfo(_fileSystem, json);
                            }
                            else
                            {
                                info = new VfsFileInfo(_fileSystem, json);
                            }
                            return(info);
                        }).ToArray();
                    }
                }
            }

            return(_infos);
        }
        private FileSystemInfoBase[] GetFileSystemInfosInternal()
        {
            if (_infos == null)
            {
                using (var client = VfsUtils.NewHttpClient(_href, _fileSystem._creds))
                {
                    using (HttpResponseMessage response = client.GetAsync(_href.AbsolutePath).Result)
                    {
                        if (response.StatusCode == HttpStatusCode.NotFound)
                        {
                            throw new DirectoryNotFoundException(this.FullName + " does not exists.");
                        }

                        response.EnsureSuccessful();

                        if (response.Content.Headers.ContentType.MediaType != "application/json")
                        {
                            throw new IOException("The directory name is invalid.");
                        }

                        var array = response.Content.ReadAsAsync<VfsJsonFileSystemInfo[]>().Result;
                        _infos = array.Select(json =>
                        {
                            FileSystemInfoBase info;
                            if (json.Mime == "inode/directory")
                            {
                                info = new VfsDirectoryInfo(_fileSystem, json);
                            }
                            else
                            {
                                info = new VfsFileInfo(_fileSystem, json);
                            }
                            return info;
                        }).ToArray();
                    }
                }
            }

            return _infos;
        }