Script
Public Slots | Public Member Functions | List of all members
SCR_FileWrapper Class Reference

The SCR_FileWrapper class is used to represent an actual image file on disk. Files can be instantiated in the scripting environment or retrieved in an SM_InputPortWrapper object. More...

#include <fileinterface.h>

Inheritance diagram for SCR_FileWrapper:
Inheritance graph
[legend]
Collaboration diagram for SCR_FileWrapper:
Collaboration graph
[legend]

Public Slots

SCR_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...
 
SCR_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(SCR_FileIOTypeWrapper::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 (SCR_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 (SCR_FileWrapper *dest)
 
bool copy (SCR_FileWrapper *dest)
 

Public Member Functions

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

Detailed Description

The SCR_FileWrapper class is used to represent an actual image file on disk. Files can be instantiated in the scripting environment or retrieved in an SM_InputPortWrapper object.

You can use it in both the Script Editor and scriptModule.

In a script, there are two possible ructor: 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

SCR_FileWrapper::SCR_FileWrapper ( )

Create a new SCR_FileWrapper.

SCR_FileWrapper::SCR_FileWrapper ( String  path)

Create a new SCR_FileWrapper.

Parameters
pathPath to physic SCR_FileWrapper

Member Function Documentation

bool SCR_FileWrapper::close ( )
slot

Close file stream.

Returns
Sucess/Failure of operation
bool SCR_FileWrapper::copy ( SCR_FileWrapper dest)
slot

Copy current SCR_FileWrapper to new SCR_FileWrapper destination

Parameters
destDestination
Returns
Result of operation
bool SCR_FileWrapper::exists ( )
slot

Verify if file exists on disk.

Returns
exists on disk
String SCR_FileWrapper::extension ( )
slot

Retrieve file extension.

Returns
extension String
bool SCR_FileWrapper::isClose ( )
slot

Check if file is closed.

Returns
stream status
bool SCR_FileWrapper::isOpen ( )
slot

Check if file is opened.

Returns
stream status
bool SCR_FileWrapper::move ( SCR_FileWrapper dest)
slot

Move current SCR_FileWrapper to new SCR_FileWrapper destination

Parameters
destDestination
Returns
Result of operation
bool SCR_FileWrapper::open ( int  m = int(SCR_FileIOTypeWrapper::WRITE_ONLY))
slot

Open file stream for read/write.

Parameters
mIO stream descriptor
Returns
Success/Failure of operation
String SCR_FileWrapper::path ( )
slot

Retrieve file path.

Returns
full path String
String SCR_FileWrapper::read ( )
slot

Read entire content of stream.

Returns
String
String SCR_FileWrapper::readLine ( )
slot

Read single line of stream.

Returns
String
bool SCR_FileWrapper::remove ( )
slot

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

Returns
Result of operation
SCR_FileWrapper& SCR_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
SCR_FileWrapper reference
SCR_FileWrapper& SCR_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
SCR_FileWrapper reference
void SCR_FileWrapper::write ( String &  text)
slot

Write string in current stream.

Parameters
textText to write
void SCR_FileWrapper::writeFile ( SCR_FileWrapper file)
slot

Write entire content of parameter file in current stream.

Parameters
fileSCR_FileWrapper object
void SCR_FileWrapper::writeLine ( String &  text)
slot

Write string line in current stream.

Parameters
textText to write

The documentation for this class was generated from the following file: