コード例 #1
0
			private NodeVirtualFileInfo LocateParentNode(VirtualFilePath Path, out string LastPartName)
			{
				Path = Path.GetNormalized();

				if (Path.IsAbsolute)
				{
					return Root.LocateParentNode(Path.FullPath.Substring(1), out LastPartName);
				}

				NodeVirtualFileInfo CurrentDirectory = this;
				var Parts = Path.GetParts();
				if (Parts.Length < 1)
				{
					LastPartName = "";
					return this;
				}
				for (int n = 0; n < Parts.Length - 1; n++)
				{
					var Part = Parts[n];
					CurrentDirectory = CurrentDirectory.GetChild(Part);
					if (CurrentDirectory == null || !CurrentDirectory.IsDirectory) throw (new FileNotFoundException("Component '" + Part + "' is not a directory in '" + Path + "'", Path));
				}

				LastPartName = Parts[Parts.Length - 1];

				return CurrentDirectory;
			}
コード例 #2
0
ファイル: ZipFileSystem.cs プロジェクト: soywiz/NodeNetAsync
		async public Task<VirtualFileInfo> GetFileInfoAsync(VirtualFilePath Path)
		{
			await ParseZipOnceAsync();

			return await TaskEx.RunPropagatingExceptionsAsync<VirtualFileInfo>(() =>
			{
				throw new NotImplementedException();
				//return default(VirtualFileInfo);
			});
		}
コード例 #3
0
			internal NodeVirtualFileInfo Open(VirtualFilePath Path)
			{
				string FileName;
				var ParentDirectory = LocateParentNode(Path, out FileName);
				if (!ParentDirectory.ContainsChild(FileName))
				{
					throw (new IOException("File '" + Path + "' : '" + FileName + "' doesn't Exist"));
				}
				return ParentDirectory.GetChild(FileName);
			}
コード例 #4
0
		async public Task<VirtualFileInfo> GetFileInfoAsync(VirtualFilePath Path)
		{
			return await Task.Run(() =>
			{
				try
				{
					return ConvertFileSystemInfoToVirtualFileInfo(new FileInfo(GetAbsolutePathFromRelative(Path)));
				}
				catch
				{
					return new VirtualFileInfo()
					{
						Exists = false,
					};
				}
			});
		}
コード例 #5
0
			internal NodeVirtualFileInfo Create(VirtualFilePath Path, VirtualFileType CreateType, bool ErrorIfExists)
			{
				string FileName;
				var ParentDirectory = LocateParentNode(Path, out FileName);
				if (ParentDirectory.ContainsChild(FileName))
				{
					if (ErrorIfExists)
					{
						throw (new IOException("File Already Exists"));
					}
					else
					{
						return ParentDirectory.GetChild(FileName);
					}
				}
				else
				{
					return ParentDirectory.AddChild(FileName, CreateType);
				}
			}
コード例 #6
0
		async public Task<IEnumerable<VirtualFileInfo>> EnumerateDirectoryAsync(VirtualFilePath Path)
		{
			return await TaskEx.RunPropagatingExceptionsAsync(() =>
			{
				var List = new List<VirtualFileInfo>();
				foreach (var FileSystemInfo in new DirectoryInfo(GetAbsolutePathFromRelative(Path)).EnumerateFileSystemInfos())
				{
					List.Add(ConvertFileSystemInfoToVirtualFileInfo(FileSystemInfo));
				}
				return List;
			});
		}
コード例 #7
0
		async public Task<IVirtualFileStream> OpenAsync(VirtualFilePath Path, FileMode FileMode, FileAccess FileAccess, FileShare FileShare)
		{
			return await TaskEx.RunPropagatingExceptionsAsync(() =>
			{
				var Stream = File.Open(GetAbsolutePathFromRelative(Path), FileMode, FileAccess, FileShare);
				return new VirtualFileStream(Stream);
			});
		}
コード例 #8
0
		async public Task CreateDirectoryAsync(VirtualFilePath Path, DirectorySecurity DirectorySecurity)
		{
			await Task.Yield();
			Directory.CreateDirectory(GetAbsolutePathFromRelative(Path), DirectorySecurity);
		}
コード例 #9
0
ファイル: ZipFileSystem.cs プロジェクト: soywiz/NodeNetAsync
		public Task CreateDirectoryAsync(VirtualFilePath Path, System.Security.AccessControl.DirectorySecurity DirectorySecurity)
		{
			throw new NotImplementedException();
		}
コード例 #10
0
ファイル: ZipFileSystem.cs プロジェクト: soywiz/NodeNetAsync
		async public Task<IEnumerable<VirtualFileInfo>> EnumerateDirectoryAsync(VirtualFilePath Path)
		{
			await ParseZipOnceAsync();
			throw new NotImplementedException();
		}
コード例 #11
0
ファイル: ZipFileSystem.cs プロジェクト: soywiz/NodeNetAsync
		async public Task<IVirtualFileStream> OpenAsync(VirtualFilePath Path, System.IO.FileMode FileMode, System.IO.FileAccess FileAccess, System.IO.FileShare FileShare)
		{
			await ParseZipOnceAsync();
			throw new NotImplementedException();
		}
コード例 #12
0
		async public Task CreateDirectoryAsync(VirtualFilePath Path, System.Security.AccessControl.DirectorySecurity DirectorySecurity)
		{
			await Task.Yield();
			Root.Create(Path, CreateType: VirtualFileType.Directory, ErrorIfExists: true);
		}
コード例 #13
0
		async public Task<IEnumerable<VirtualFileInfo>> EnumerateDirectoryAsync(VirtualFilePath Path)
		{
			await Task.Yield();
			return Root.Open(Path).Childs;
		}
コード例 #14
0
		async public Task<IVirtualFileStream> OpenAsync(VirtualFilePath Path, FileMode OpenFileMode, FileAccess FileAccess, FileShare FileShare)
		{
			NodeVirtualFileInfo Node;

			switch (OpenFileMode)
			{
				case FileMode.Create:
				case FileMode.CreateNew:
				case FileMode.OpenOrCreate:
				case FileMode.Append:
					Node = Root.Create(Path, CreateType: VirtualFileType.File, ErrorIfExists: OpenFileMode == FileMode.CreateNew);
					break;
				default:
				case FileMode.Open:
				case FileMode.Truncate:
					Node = Root.Open(Path);
					break;
			}
			return await Node.OpenAsync(OpenFileMode, FileAccess, FileShare);
		}
コード例 #15
0
		async public Task<VirtualFileInfo> GetFileInfoAsync(VirtualFilePath Path)
		{
			await Task.Yield();
			return Root.Open(Path);
		}