internal void UpdateCache(VfsFileInfo info) { lock (_files) { _files[info.FullName] = info; } }
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; } }
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); } }
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); } }
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; }