THYFile

Overview

The THYFile class provides a convenient and object oriented way to access disk files.

Although it can be used independently, THYFile instances are usually returned by the THYDirectory class.

Methods such as Open, Close, Copy, CopyFromStream, etc. are wrappers around VCL functions that don't encapsulate such behavior and helps the developer to use a structured programming approach.

Location


 

constructor Create (THYDirectory, TSearchRec)  overload virtual    (declared in THYCustomFile)

Creates a new instance of the class.

constructor Create(aParent: THYDirectory; aSearchRec: TSearchRec)

Parameters:

  • aParent: Reference to a parent directory.
  • aSearchRec: Pointer to a structure.

constructor Create (THYDirectory, string)  overload    (declared in THYCustomFile)

Creates a new instance of the class.

constructor Create(aParent: THYDirectory; const aName: string)

Parameters:

  • aParent: Reference to a parent directory.
  • aName: Name of the item.

constructor CreateNew

Check whether file is open.

constructor CreateNew(aParent: THYDirectory; const aName: string; KeepOpen: Boolean)

Parameters:

  • aParent: Reference to a parent directory.
  • aName: Name of the new file.
  • KeepOpen: Specifies whether new file will remain open.

Attributes    (declared in THYCustomFile)

Gets or sets file attributes. Attributes values is a standard delphi values for .

property Attributes: Integer read write

AttributesString    (declared in THYCustomFile)

Gets string representation of the file attributes.

property AttributesString: string read write

CheckOpen  protected

Check whether file is open.

procedure CheckOpen(MustBeOpen: Boolean)

Parameters:

  • MustBeOpen: Value that indicates whether file should already be opened.

Close

Closes the file.

procedure Close

Copy

Copies the file to a specified location.

procedure Copy(aDestination: string)

Parameters:

  • aDestination: New location of the file.

CopyFromStream

Check whether file is open.

function CopyFromStream(aSource: TStream; aCount: Integer): Integer

Parameters:

  • aSource: Reference to a stream.
  • aCount: Number of bytes to copy.

CopyToStream

Check whether file is open.

function CopyToStream(aDestination: TStream; aCount: Integer): Integer

Parameters:

  • aDestination: Reference to a stream.
  • aCount: Number of bytes to copy.

Data    (declared in THYCustomFile)

Gets or sets pointer to a custom data associated with the file.

property Data: pointer read write

Delete

Deletes the file.

procedure Delete

Directory    (declared in THYCustomFile)

Gets reference to a parent directory.

property Directory: THYDirectory read write

FullName    (declared in THYCustomFile)

Gets full path of the file.

property FullName: string read write

GetFullName  protected virtual    (declared in THYCustomFile)

Returns full path of the file.

function GetFullName: string

GetSize  protected override

Returns size of the file.

function GetSize: Integer

Handle

Gets handle of the file.

property Handle: Integer read write

IsOpen

Gets a value which idicates whether file is open.

property IsOpen: Boolean read write

Name    (declared in THYCustomFile)

Gets or sets name of the file.

property Name: string read write

Open

Check whether file is open.

procedure Open(aFileMode: cardinal)

Parameters:

  • aFileMode: Value that indicates whether file should already be opened.

Position

Gets or sets current position in the underlying file stream.

property Position: Integer read write

Size    (declared in THYCustomFile)

Gets size of the file.

property Size: Integer read write

Stream

Gets reference to the underlying file stream.

property Stream: TFileStream read write

Time    (declared in THYCustomFile)

Gets or sets file time.

property Time: TDateTime read write

Version    (declared in THYCustomFile)

Gets string representation of the file version.

property Version: string read write

 

Attributes    (declared in THYCustomFile)

Gets or sets file attributes. Attributes values is a standard delphi values for .

property Attributes: Integer read write

AttributesString    (declared in THYCustomFile)

Gets string representation of the file attributes.

property AttributesString: string read write

Data    (declared in THYCustomFile)

Gets or sets pointer to a custom data associated with the file.

property Data: pointer read write

Directory    (declared in THYCustomFile)

Gets reference to a parent directory.

property Directory: THYDirectory read write

FullName    (declared in THYCustomFile)

Gets full path of the file.

property FullName: string read write

Handle

Gets handle of the file.

property Handle: Integer read write

IsOpen

Gets a value which idicates whether file is open.

property IsOpen: Boolean read write

Name    (declared in THYCustomFile)

Gets or sets name of the file.

property Name: string read write

Position

Gets or sets current position in the underlying file stream.

property Position: Integer read write

Size    (declared in THYCustomFile)

Gets size of the file.

property Size: Integer read write

Stream

Gets reference to the underlying file stream.

property Stream: TFileStream read write

Time    (declared in THYCustomFile)

Gets or sets file time.

property Time: TDateTime read write

Version    (declared in THYCustomFile)

Gets string representation of the file version.

property Version: string read write

 

constructor Create (THYDirectory, TSearchRec)  overload virtual    (declared in THYCustomFile)

Creates a new instance of the class.

constructor Create(aParent: THYDirectory; aSearchRec: TSearchRec)

Parameters:

  • aParent: Reference to a parent directory.
  • aSearchRec: Pointer to a structure.

constructor Create (THYDirectory, string)  overload    (declared in THYCustomFile)

Creates a new instance of the class.

constructor Create(aParent: THYDirectory; const aName: string)

Parameters:

  • aParent: Reference to a parent directory.
  • aName: Name of the item.

constructor CreateNew

Check whether file is open.

constructor CreateNew(aParent: THYDirectory; const aName: string; KeepOpen: Boolean)

Parameters:

  • aParent: Reference to a parent directory.
  • aName: Name of the new file.
  • KeepOpen: Specifies whether new file will remain open.

CheckOpen  protected

Check whether file is open.

procedure CheckOpen(MustBeOpen: Boolean)

Parameters:

  • MustBeOpen: Value that indicates whether file should already be opened.

Close

Closes the file.

procedure Close

Copy

Copies the file to a specified location.

procedure Copy(aDestination: string)

Parameters:

  • aDestination: New location of the file.

CopyFromStream

Check whether file is open.

function CopyFromStream(aSource: TStream; aCount: Integer): Integer

Parameters:

  • aSource: Reference to a stream.
  • aCount: Number of bytes to copy.

CopyToStream

Check whether file is open.

function CopyToStream(aDestination: TStream; aCount: Integer): Integer

Parameters:

  • aDestination: Reference to a stream.
  • aCount: Number of bytes to copy.

Delete

Deletes the file.

procedure Delete

GetFullName  protected virtual    (declared in THYCustomFile)

Returns full path of the file.

function GetFullName: string

GetSize  protected override

Returns size of the file.

function GetSize: Integer

Open

Check whether file is open.

procedure Open(aFileMode: cardinal)

Parameters:

  • aFileMode: Value that indicates whether file should already be opened.

 

  • THYDirectory
  • THYDirectoryManager