示例#1
0
 internal void UpdateCache(VfsFileInfo info)
 {
     lock (_files)
     {
         _files[info.FullName] = info;
     }
 }
示例#2
0
        public FileInfoBase FromFileName(string fileName)
        {
            FileInfo fileInfo = new FileInfo(fileName);
            lock (_files)
            {
                VfsFileInfo file;
                if (!_files.TryGetValue(fileInfo.FullName, out file))
                {
                    DirectoryInfoBase info = _fileSystem.DirectoryInfo.FromDirectoryName(fileInfo.Directory.FullName);
                    if (info.Exists)
                    {
                        file = (VfsFileInfo)info.GetFiles().Where(f => f.Name == fileInfo.Name).FirstOrDefault();
                        if (file == null)
                        {
                            file = new VfsFileInfo(_fileSystem, fileInfo);
                        }
                    }
                    else
                    {
                        file = new VfsFileInfo(_fileSystem, fileInfo);
                    }

                    _files[fileInfo.FullName] = file;
                }
                return file;
            }
        }
示例#3
0
 internal void UpdateCache(VfsFileInfo info)
 {
     lock (_files)
     {
         _files[info.FullName] = info;
     }
 }
示例#4
0
        public FileInfoBase FromFileName(string fileName)
        {
            FileInfo fileInfo = new FileInfo(fileName);

            lock (_files)
            {
                VfsFileInfo file;
                if (!_files.TryGetValue(fileInfo.FullName, out file))
                {
                    DirectoryInfoBase info = _fileSystem.DirectoryInfo.FromDirectoryName(fileInfo.Directory.FullName);
                    if (info.Exists)
                    {
                        file = (VfsFileInfo)info.GetFiles().Where(f => f.Name == fileInfo.Name).FirstOrDefault();
                        if (file == null)
                        {
                            file = new VfsFileInfo(_fileSystem, fileInfo);
                        }
                    }
                    else
                    {
                        file = new VfsFileInfo(_fileSystem, fileInfo);
                    }

                    _files[fileInfo.FullName] = file;
                }
                return(file);
            }
        }
示例#5
0
        internal void UpdateLastWriteTimeUtc(string fileName, DateTime lastWriteTimeUtc)
        {
            FileInfo fileInfo = new FileInfo(fileName);
            lock (_files)
            {
                VfsFileInfo file;
                if (!_files.TryGetValue(fileInfo.FullName, out file))
                {
                    _files[fileInfo.FullName] = file = new VfsFileInfo(_fileSystem, fileInfo);
                }

                file.LastWriteTimeUtc = lastWriteTimeUtc;
                file.MarkExists(true);
            }
        }
示例#6
0
        internal void UpdateLastWriteTimeUtc(string fileName, DateTime lastWriteTimeUtc)
        {
            FileInfo fileInfo = new FileInfo(fileName);

            lock (_files)
            {
                VfsFileInfo file;
                if (!_files.TryGetValue(fileInfo.FullName, out file))
                {
                    _files[fileInfo.FullName] = file = new VfsFileInfo(_fileSystem, fileInfo);
                }

                file.LastWriteTimeUtc = lastWriteTimeUtc;
                file.MarkExists(true);
            }
        }
示例#7
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);
        }
示例#8
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;
        }