File Class Reference

The File JavaScript class. Open, close, read, write, get information about files. More...

Public Slots

void open (int accessMode)
 Open the file with specific access mode. More...
 
void close ()
 Close the file. More...
 
void remove ()
 Remove the file. More...
 
int readByte ()
 Read the next char of the file. More...
 
String read ()
 Read all the file. More...
 
String readLine ()
 Read one line of the file. More...
 
StringList readLines ()
 Read each line of the file. More...
 
void writeByte (int byte)
 Write a char in the file. More...
 
void write (String &data, int length=-1)
 Write a string in the file. More...
 
void writeLine (String &data)
 Write a string in the file and go next line. More...
 

Public Member Functions

 File (String &filename)
 

Properties

String name
 File name. More...
 
String path
 File path. More...
 
String fullName
 File name. More...
 
String baseName
 Base file name. More...
 
String extension
 File extension. More...
 
String symLink
 
bool exists
 File exists. More...
 
bool readable
 File readable flag. More...
 
bool writable
 File writable flag. More...
 
bool executable
 File executable flag. More...
 
bool hidden
 File hidden flag. More...
 
bool eof
 File reach end. More...
 
QDateTime created
 Date when the file was created. More...
 
QDateTime lastModified
 Date when the file was modified. More...
 
QDateTime lastRead
 Date when the file was read. More...
 
int size
 Size of the file. More...
 

Detailed Description

The File JavaScript class. Open, close, read, write, get information about files.

var file = new File( filePath );
if ( file.exists )
{
var message = "The output file \"" + file.name + "\" exists. Do you wish to overwrite it?"
var ans = MessageBox.warning(message, MessageBox.Yes, MessageBox.No);
var check = MessageBox.Yes;
if(ans != MessageBox.Yes)
return false;
}
return true;

Constructor & Destructor Documentation

◆ File()

File::File ( String &  filename)
Parameters
filename: The path to the file.

Member Function Documentation

◆ close

void File::close ( )
inlineslot

Close the file.

◆ open

void File::open ( int  accessMode)
slot

Open the file with specific access mode.

Parameters
accessMode: The specified access mode. See FileAccess for available modes.

◆ read

String File::read ( )
slot

Read all the file.

Returns
Returns the entire file.

◆ readByte

int File::readByte ( )
slot

Read the next char of the file.

Returns
Returns the next char of the file.

◆ readLine

String File::readLine ( )
slot

Read one line of the file.

Returns
Returns the next line of the file.

◆ readLines

StringList File::readLines ( )
slot

Read each line of the file.

Returns
Returns a list of strings each storing one line of the file.

◆ remove

void File::remove ( )
slot

Remove the file.

◆ write

void File::write ( String &  data,
int  length = -1 
)
slot

Write a string in the file.

Parameters
data: The data to be written to the file.
length: The length of the data to be written.

◆ writeByte

void File::writeByte ( int  byte)
slot

Write a char in the file.

Parameters
byte: The char to write to the file.

◆ writeLine

void File::writeLine ( String &  data)
inlineslot

Write a string in the file and go next line.

Parameters
data: The data to be written to the file.

Property Documentation

◆ baseName

String File::baseName
read

Base file name.

◆ created

QDateTime File::created
read

Date when the file was created.

◆ eof

bool File::eof
read

File reach end.

◆ executable

bool File::executable
read

File executable flag.

◆ exists

bool File::exists
read

File exists.

◆ extension

String File::extension
read

File extension.

◆ fullName

String File::fullName
read

File name.

◆ hidden

bool File::hidden
read

File hidden flag.

◆ lastModified

QDateTime File::lastModified
read

Date when the file was modified.

◆ lastRead

QDateTime File::lastRead
read

Date when the file was read.

◆ name

String File::name
read

File name.

◆ path

String File::path
read

File path.

◆ readable

bool File::readable
read

File readable flag.

◆ size

int File::size
read

Size of the file.

◆ symLink

String File::symLink
read

◆ writable

bool File::writable
read

File writable flag.