Gorgon
Show / Hide Table of Contents

Interface IGorgonVirtualFile

A representation of a file from a physical file system.

Inherited Members
IGorgonNamedObject.Name
Namespace: Gorgon.IO
Assembly: Gorgon.FileSystem.dll
Syntax
public interface IGorgonVirtualFile : IGorgonNamedObject
Remarks

This represents the information for a file on a physical file system. This object only contains data about the file, and not the file itself. These files are read only and cannot be written into from the standard IGorgonFileSystem.

Users may retrieve a file from a IGorgonFileSystem via the GetFile(string) method. When the file has been returned to the user, they may call the OpenStream() method to read the contents of the file.

To create, update or delete a file from the IGorgonFileSystem, use an instance of the IGorgonFileSystemWriter<T> object and call the OpenStream(string, FileMode) method to create or update a file. Use the DeleteFile(string) method to delete a file.

Examples

This is an example of retrieving a file, and opening it for reading:

IGorgonFileSystem fileSystem = new GorgonFileSystem();

// Mount a directory for this file system.
fileSystem.Mount(@"C:\MyDirectory\", "/"); 

// Get the file.
IGorgonVirtualFile file = fileSystem.GetFile("/AFile.txt");

using (Stream stream = file.OpenStream())
{
	using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
	{
		while (!reader.EndOfStream)
		{
			Console.WriteLine(reader.ReadLine());
		}
	}
}

Properties

| Edit this page View Source

BaseFileName

Property to return the file name without the extension.

Declaration
string BaseFileName { get; }
Property Value
Type Description
string
| Edit this page View Source

CreateDate

Property to return the file creation date.

Declaration
DateTime CreateDate { get; }
Property Value
Type Description
DateTime
| Edit this page View Source

Directory

Property to return the IGorgonVirtualDirectory that contains this file.

Declaration
IGorgonVirtualDirectory Directory { get; }
Property Value
Type Description
IGorgonVirtualDirectory
| Edit this page View Source

Extension

Property to return the file name extension.

Declaration
string Extension { get; }
Property Value
Type Description
string
| Edit this page View Source

FileSystem

Property to return the file system that owns this file.

Declaration
IGorgonFileSystem FileSystem { get; }
Property Value
Type Description
IGorgonFileSystem
| Edit this page View Source

FullPath

Property to return the full path to the file in the IGorgonFileSystem.

Declaration
string FullPath { get; }
Property Value
Type Description
string
| Edit this page View Source

LastModifiedDate

Property to return the last modified date.

Declaration
DateTime LastModifiedDate { get; }
Property Value
Type Description
DateTime
| Edit this page View Source

MountPoint

Property to return the mount point for this file.

Declaration
GorgonFileSystemMountPoint MountPoint { get; }
Property Value
Type Description
GorgonFileSystemMountPoint
Remarks

This will show where the file is mounted within the IGorgonFileSystem, the physical path to the file, and the IGorgonFileSystemProvider used to import the file information.

| Edit this page View Source

PhysicalFile

Property to return the physical file information for this virtual file.

Declaration
IGorgonPhysicalFileInfo PhysicalFile { get; }
Property Value
Type Description
IGorgonPhysicalFileInfo
Remarks

This will return information about the file queried from the physical file system.

| Edit this page View Source

Size

Property to return the uncompressed size of the file in bytes.

Declaration
long Size { get; }
Property Value
Type Description
long

Methods

| Edit this page View Source

OpenStream()

Function to open a stream to the file on the physical file system.

Declaration
Stream OpenStream()
Returns
Type Description
Stream

The open Stream object.

Remarks

This will open a Stream to the physical file for reading. Applications that open a stream to a file are responsible for closing the Stream when they are done.

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author