ScriptModule
Public Slots | Public Member Functions | List of all members
File Class Reference

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

#include <FileInterface.h>

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

Public Slots

FilesetPath (const 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 () const
 Retrieve file path. More...
 
FilesetExtension (const String &ext)
 Change extension for file name. Extension won't change if there is an open stream. More...
 
String extension () const
 Retrieve file extension. More...
 
bool exists () const
 Verify if file exists on disk. More...
 
bool remove ()
 
Stream Manipulation
bool isOpen () const
 Check if file is opened. More...
 
bool isClose () const
 Check if file is closed. More...
 
bool open (int m=int(IO::WRITE_ONLY))
 Open file stream for read/write. More...
 
bool close ()
 Close file stream. More...
 
void write (const String &text)
 Write string in current stream. More...
 
void writeLine (const String &text)
 Write string line in current stream. More...
 
void writeFile (File 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 (File dest)
 
bool copy (File dest)
 

Public Member Functions

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

Detailed Description

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

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

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

File::File ( )

Create a new File.

File::File ( String  path)

Create a new File.

Parameters
pathPath to physic File

Member Function Documentation

bool File::close ( )
slot

Close file stream.

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

Copy current File to new File destination

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

Verify if file exists on disk.

Returns
exists on disk
String File::extension ( ) const
slot

Retrieve file extension.

Returns
extension String
bool File::isClose ( ) const
slot

Check if file is closed.

Returns
stream status
bool File::isOpen ( ) const
slot

Check if file is opened.

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

Move current File to new File destination

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

Open file stream for read/write.

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

Retrieve file path.

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

Read entire content of stream.

Returns
String
String File::readLine ( )
slot

Read single line of stream.

Returns
String
bool File::remove ( )
slot

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

Returns
Result of operation
File& File::setExtension ( const 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
File reference
File& File::setPath ( const 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
File reference
void File::write ( const String &  text)
slot

Write string in current stream.

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

Write entire content of parameter file in current stream.

Parameters
fileFile object
void File::writeLine ( const String &  text)
slot

Write string line in current stream.

Parameters
textText to write

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