Cyclone 3DR Script
from Technodigit, part of Hexagon. Copyright 1997-2024.
Loading...
Searching...
No Matches
SFile Class Reference

Provide an interface for reading from and writing to files on disk. More...

Public Types

enum  OpenModeEnum {
  ReadOnly = 1 , WriteOnly = 2 , ReadWrite = 3 , Append = 4 ,
  Truncate = 8
}
 The opening modes. More...
 

Public Member Functions

boolean AtEnd ()
 Return if the current read and write position is at the end of the file (i.e. there is no more data available for reading on the file). More...
 
 Close ()
 Close the file. More...
 
boolean Exists ()
 Check if the file exists. More...
 
string FileName ()
 Get the filename of the SFile. More...
 
boolean IsOpen ()
 Return if the file is open or not. A file is open if it can be read from and/or written to. More...
 
boolean Open (OpenModeEnum openMode)
 Open the existing file (The file is always open in text mode). More...
 
string ReadAll ()
 Read all available data from the file. More...
 
string ReadLine ()
 Read a line from the file. More...
 
boolean Remove ()
 Remove the file specified by the FileName(). More...
 
boolean Rename (string newName)
 Rename the file currently specified by FileName() with the given name. More...
 
 SFile (string name)
 Construct a new file object to represent the file with the given name. More...
 
string toString ()
 Get the type of the variable. More...
 
boolean Write (string toWrite)
 Write the content of a string to the file. More...
 

Static Public Member Functions

static SFile New (string name)
 Construct a new file object to represent the file with the given name. More...
 
static boolean Remove (string fileName)
 Remove the file specified by the fileName given. More...
 

Detailed Description

Provide an interface for reading from and writing to files on disk.

Member Enumeration Documentation

◆ OpenModeEnum

The opening modes.

Enumerator
ReadOnly 

The file is opened for reading.

WriteOnly 

The file is opened for writing. Note that this mode implies Truncate.

ReadWrite 

The file is opened for reading and writing.

Append 

The file is opened in append mode so that all data is written to the end of the file.

Truncate 

If possible, the file is truncated before it is opened. All earlier contents of the device are lost.

Constructor & Destructor Documentation

◆ SFile()

SFile::SFile ( string  name)

Construct a new file object to represent the file with the given name.

Parameters
name(string) The name of the file.

Member Function Documentation

◆ AtEnd()

boolean SFile::AtEnd ( )

Return if the current read and write position is at the end of the file (i.e. there is no more data available for reading on the file).

Returns
(boolean) True if the current read and write position is at the end of the file.

◆ Close()

SFile::Close ( )

Close the file.

◆ Exists()

boolean SFile::Exists ( )

Check if the file exists.

Returns
(boolean) True if the file exists.

◆ FileName()

string SFile::FileName ( )

Get the filename of the SFile.

Returns
(string) The filename.

◆ IsOpen()

boolean SFile::IsOpen ( )

Return if the file is open or not. A file is open if it can be read from and/or written to.

Returns
(boolean) True if the file is open.

◆ New()

static SFile SFile::New ( string  name)
static

Construct a new file object to represent the file with the given name.

Parameters
name(string) The name of the file.
Returns
(SFile) The new SFile.

◆ Open()

boolean SFile::Open ( OpenModeEnum  openMode)

Open the existing file (The file is always open in text mode).

Parameters
openMode(OpenModeEnum) The opening mode to use.
  • SFile.ReadOnly: The file is opened for reading.
  • SFile.WriteOnly: The file is opened for writing. Note that this mode implies Truncate.
  • SFile.ReadWrite: The file is opened for reading and writing.
  • SFile.Append: The file is opened in append mode so that all data is written to the end of the file.
  • SFile.Truncate: If possible, the file is truncated before it is opened. All earlier contents of the device are lost.
Returns
(boolean) True if the file has been successfully opened.

◆ ReadAll()

string SFile::ReadAll ( )

Read all available data from the file.

Returns
(string) A string with all read content.

◆ ReadLine()

string SFile::ReadLine ( )

Read a line from the file.

Returns
(string) A string with the read line.

◆ Remove() [1/2]

boolean SFile::Remove ( )

Remove the file specified by the FileName().

Returns
(boolean) True if the file has been successfully removed.

◆ Remove() [2/2]

static boolean SFile::Remove ( string  fileName)
static

Remove the file specified by the fileName given.

Parameters
fileName(string) The name of the file to remove.
Returns
(boolean) True if the file has been successfully removed.

◆ Rename()

boolean SFile::Rename ( string  newName)

Rename the file currently specified by FileName() with the given name.

Parameters
newName(string) The new name of the file.
Returns
(boolean) True if the file has been successfully renamed.

◆ toString()

string SFile::toString ( )

Get the type of the variable.

Returns
(string) The type name

◆ Write()

boolean SFile::Write ( string  toWrite)

Write the content of a string to the file.

Parameters
toWrite(string) The string to write in the file
Returns
(boolean) True if the content has been successfully written.