Harmony
Scripting Interface Documentation
FileWrapper Class Reference

The PermanentFile and TemporaryFile JavaScript classes. Used to represent an actual image file on disk. More...

Public Slots

FileWrappersetPath (String &path)
 Specify absolute path of this image file. Name of file can not be changed if there is an open stream. More...
 
String path ()
 Retrieve file path. More...
 
FileWrappersetExtension (String &ext)
 Change extension for file name. Extension won't change if there is an open stream. More...
 
String extension ()
 Retrieve file extension. More...
 
bool exists ()
 Verify if file exists on disk. More...
 
bool remove ()
 
Stream Manipulation
bool isOpen ()
 Check if file is opened. More...
 
bool isClose ()
 Check if file is closed. More...
 
bool open (int m=int(FileIOType::WRITE_ONLY))
 Open file stream for read/write. More...
 
bool close ()
 Close file stream. More...
 
void write (String &text)
 Write string in current stream. More...
 
void writeLine (String &text)
 Write string line in current stream. More...
 
void writeFile (FileWrapper file)
 Write entire content of parameter file in current stream. More...
 
String read ()
 Read entire content of stream. More...
 
String readLine ()
 Read single line of stream. More...
 
File management
bool move (FileWrapper dest)
 
bool copy (FileWrapper dest)
 

Public Member Functions

 FileWrapper ()
 Create a new FileWrapper. More...
 
 FileWrapper (String path)
 Create a new FileWrapper. More...
 

Detailed Description

The PermanentFile and TemporaryFile JavaScript classes. Used to represent an actual image file on disk.

Files can be instantiated in the scripting environment or retrieved in an SM_InputPortWrapper object.

In a script, there are two possible constructor: the PermanentFile or TemporaryFile. The PermanentFile takes the name of a file as an argument. Example:

file = new PermanentFile( "C:\file.txt" );
file.open( IO.WRITE_ONLY ); // open with write only stream
file.writeLine( "Hello World!" ); // write line to file
file.close(); // close file

The TemporaryFile takes an extension as an argument, an returns a temporary file with that extension. The temporary file and its containing directory will be deleted on exit.Example:

file = new TemporaryFile( "txt" );
file.open( IO.WRITE_ONLY ); // open with write only stream
file.writeLine( "Hello World!" ); // write line to file
file.close(); // close file

Constructor & Destructor Documentation

◆ FileWrapper() [1/2]

FileWrapper::FileWrapper ( )

Create a new FileWrapper.

◆ FileWrapper() [2/2]

FileWrapper::FileWrapper ( String  path)

Create a new FileWrapper.

Parameters
pathPath to physic FileWrapper

Member Function Documentation

◆ close

bool FileWrapper::close ( )
slot

Close file stream.

Returns
Sucess/Failure of operation

◆ copy

bool FileWrapper::copy ( FileWrapper  dest)
slot

Copy current FileWrapper to new FileWrapper destination

Parameters
destDestination
Returns
Result of operation

◆ exists

bool FileWrapper::exists ( )
slot

Verify if file exists on disk.

Returns
exists on disk

◆ extension

String FileWrapper::extension ( )
slot

Retrieve file extension.

Returns
extension String

◆ isClose

bool FileWrapper::isClose ( )
slot

Check if file is closed.

Returns
stream status

◆ isOpen

bool FileWrapper::isOpen ( )
slot

Check if file is opened.

Returns
stream status

◆ move

bool FileWrapper::move ( FileWrapper  dest)
slot

Move current FileWrapper to new FileWrapper destination

Parameters
destDestination
Returns
Result of operation

◆ open

bool FileWrapper::open ( int  m = int(FileIOType::WRITE_ONLY))
slot

Open file stream for read/write.

Parameters
mIO stream descriptor
Returns
Success/Failure of operation

◆ path

String FileWrapper::path ( )
slot

Retrieve file path.

Returns
full path String

◆ read

String FileWrapper::read ( )
slot

Read entire content of stream.

Returns
String

◆ readLine

String FileWrapper::readLine ( )
slot

Read single line of stream.

Returns
String

◆ remove

bool FileWrapper::remove ( )
slot

Remove physical file manually. Cannot remove file if there is an open stream.

Returns
Result of operation

◆ setExtension

FileWrapper& FileWrapper::setExtension ( String &  ext)
slot

Change extension for file name. Extension won't change if there is an open stream.

Parameters
extExtension String of image file
Returns
FileWrapper reference

◆ setPath

FileWrapper& FileWrapper::setPath ( String &  path)
slot

Specify absolute path of this image file. Name of file can not be changed if there is an open stream.

Parameters
pathAbsolute path String of image file
Returns
FileWrapper reference

◆ write

void FileWrapper::write ( String &  text)
slot

Write string in current stream.

Parameters
textText to write

◆ writeFile

void FileWrapper::writeFile ( FileWrapper  file)
slot

Write entire content of parameter file in current stream.

Parameters
fileFileWrapper object

◆ writeLine

void FileWrapper::writeLine ( String &  text)
slot

Write string line in current stream.

Parameters
textText to write