Cisco Packet Tracer Extensions API 8.1.0
API for communication between Cisco Packet Tracer application and its extension applications and modules.
Public Member Functions | List of all members
SystemFileManager Class Reference

SystemFileManager provides file IO to the local system. More...

Public Member Functions

QString getOpenFileName (QString, QString, QString)
 Prompt the user to select a file to open. It blocks until the user has selected or canceled the dialog. More...
 
vector< String > getOpenFileNames (QString, QString, QString)
 Prompt the user to select one or multiple files to open. It blocks until the user has selected or canceled the dialog. More...
 
QString getSelectedDirectory (QString, QString)
 Prompt the user to select a folder. It blocks until the user has selected or canceled the dialog. More...
 
QString getSaveFileName (QString, QString, QString)
 Prompt the user to select a file to save. It blocks until the user has selected or canceled the dialog. More...
 
QString getFileContents (QString)
 Returns the content of a plain text file. More...
 
QString getFileBinaryContents (QString)
 Returns the content of a binary file in base 64 format. More...
 
bool writeTextToFile (QString, QString)
 Writes plain text content to a file using UTF-8 encoding. More...
 
bool writePlainTextToFile (QString, QString)
 Writes plain text content to a file using UTF-8 encoding. More...
 
bool writeBinaryToFile (QString, QString)
 Writes binary content to a file. More...
 
int getFileSize (QString)
 Returns the size of a file in bytes. More...
 
QString getFileCheckSum (QString)
 Returns the SHA-1 checksum of a file. More...
 
long getFileModificationTime (QString)
 Returns the last modification time of a file in number of seconds that have passed since 1970-01-01T00:00:00 UTC. More...
 
FilePermissions getFilePermissions (QString)
 Returns the permissions of a file. More...
 
bool setFilePermissions (QString, FilePermissions)
 Sets the permissions of a file. More...
 
bool copySrcFileToDestFile (QString, QString)
 Copies a file. More...
 
bool moveSrcFileToDestFile (QString, QString, bool)
 Moves or renames a file. More...
 
bool copySrcDirectoryToDestDirectory (QString, QString, bool, FilePermissions)
 Copies a directory. More...
 
bool moveSrcDirectoryToDestDirectory (QString, QString, bool)
 Moves or renames a directory. More...
 
bool zipDirectory (QString)
 Zips up a directory into a zip file with the same name. More...
 
bool zipDirectoryWithPassword (QString, QString)
 
bool zipDirectoryTo (QString, QString)
 Zips up a directory into a zip file. More...
 
bool zipDirectoryToWithPassword (QString, QString, QString)
 
bool unzipFile (QString)
 Unzips up a file in the same directory with the same name. More...
 
bool unzipFileWithPassword (QString, QString)
 
bool unzipFileTo (QString, QString)
 Unzips up a file in the same directory to a specified directory. More...
 
bool unzipFileToWithPassword (QString, QString, QString)
 
QString encrypt (QString, QString)
 FOR INTERNAL USE ONLY. Encrypts the string using password. Returns empty string if not internal script module or exapps. More...
 
QString decrypt (QString, QString)
 FOR INTERNAL USE ONLY. Decrypts the data using password. Returns empty string if not internal script module or exapps. More...
 
QString encryptBinary (QString, QString)
 FOR INTERNAL USE ONLY. Encrypts the binary data using password. Returns empty string if not internal script module or exapps. More...
 
QString decryptBinary (QString, QString)
 FOR INTERNAL USE ONLY. Decrypts the data using password. Returns empty string if not internal script module or exapps. More...
 
QString getEncryptedFileContents (QString, QString)
 FOR INTERNAL USE ONLY. Reads and decrypts the file content using password. Returns empty string if not internal script module or exapps. More...
 
QString getEncryptedFileBinaryContents (QString, QString)
 FOR INTERNAL USE ONLY. Reads and decrypts the binary file content using password. Returns empty string if not internal script module or exapps. More...
 
bool writeTextToEncryptedFile (QString, QString, QString)
 FOR INTERNAL USE ONLY. Encrypts the text content using password and writes to file. Returns false if not internal script module or exapps. More...
 
bool writeBinaryToEncryptedFile (QString, QString, QString)
 FOR INTERNAL USE ONLY. Encrypts the binary content using password and writes to file. Returns false if not internal script module or exapps. More...
 
bool writeTextToEncryptedLogFile (QString, QString)
 FOR INTERNAL USE ONLY. Encrypts the text content using same method as PT log file format and writes to file. Returns false if not internal script module or exapps. More...
 
bool encryptFile (QString, QString, QString)
 FOR INTERNAL USE ONLY. Encrypts a file using password and writes to another file. Returns false if not internal script module or exapps. More...
 
bool decryptFile (QString, QString, QString)
 FOR INTERNAL USE ONLY. Decrypts a file using password and writes to another file. Returns false if not internal script module or exapps. More...
 
bool makeDirectory (QString)
 Creates a directory including all missing parents. More...
 
bool removeFile (QString)
 Removes a file. More...
 
bool removeDirectory (QString)
 Removes a directory recursively including all sub directories and files. More...
 
bool directoryExists (QString)
 Returns whether a directory exists. More...
 
bool fileExists (QString)
 Returns whether a file exists. More...
 
QString convertToNativeSeparators (QString)
 Converts a path to native format with native separators. More...
 
QString convertFromNativeSeparators (QString)
 Converts a path to Unix format with Unix separators. More...
 
bool isAbsolutePath (QString)
 Returns whether the path is absolute. More...
 
bool isRelativePath (QString)
 Returns whether the path is relative. More...
 
QString getRelativePath (QString, QString)
 Returns path name of path2 relative to path1. More...
 
QString getAbsolutePath (QString)
 Returns absolute path name. More...
 
vector< QString > getFilesInDirectory (QString)
 Returns a list of files and directory names in a directory. More...
 
SystemFileWatcher getFileWatcher ()
 Returns the SystemFileWatcher instance for this Script Module. This is not available for ExApps and will return NULL. More...
 

Detailed Description

SystemFileManager provides file IO to the local system.

Member Function Documentation

◆ convertFromNativeSeparators()

QString SystemFileManager::convertFromNativeSeparators ( QString  )

Converts a path to Unix format with Unix separators.

Parameters
path,apath name
Returns
QString, the path converted to Unix format

◆ convertToNativeSeparators()

QString SystemFileManager::convertToNativeSeparators ( QString  )

Converts a path to native format with native separators.

Parameters
path,apath name
Returns
QString, the path converted to native format

◆ copySrcDirectoryToDestDirectory()

bool SystemFileManager::copySrcDirectoryToDestDirectory ( QString  ,
QString  ,
bool  ,
FilePermissions   
)

Copies a directory.

Parameters
srcDir,thefull path of the source
destDir,thefull path of the destination
bReplace,trueif to replace, false otherwise
permissions,standardUnix permissions format
Returns
bool, true if successful, false otherwise

◆ copySrcFileToDestFile()

bool SystemFileManager::copySrcFileToDestFile ( QString  ,
QString   
)

Copies a file.

Parameters
srcFile,thefull path of the source
destFile,thefull path of the destination
Returns
bool, true if successful, false otherwise

◆ decrypt()

QString SystemFileManager::decrypt ( QString  ,
QString   
)

FOR INTERNAL USE ONLY. Decrypts the data using password. Returns empty string if not internal script module or exapps.

Parameters
data,thedata to be decrypted in base 64 format
password,thepassword to use to decrypt
Returns
QString, the decrypted string

◆ decryptBinary()

QString SystemFileManager::decryptBinary ( QString  ,
QString   
)

FOR INTERNAL USE ONLY. Decrypts the data using password. Returns empty string if not internal script module or exapps.

Parameters
data64,thedata to be decrypted in base 64 format
password,thepassword to use to decrypt
Returns
QString, the decrypted data in base 64 format

◆ decryptFile()

bool SystemFileManager::decryptFile ( QString  ,
QString  ,
QString   
)

FOR INTERNAL USE ONLY. Decrypts a file using password and writes to another file. Returns false if not internal script module or exapps.

Parameters
srcFile,thefull path to the source file
dstFile,thefull path of the destination file
password,thepassword to use to decrypt
Returns
bool, true if successful, false otherwise

◆ directoryExists()

bool SystemFileManager::directoryExists ( QString  )

Returns whether a directory exists.

Parameters
path,thefull path of the directory
Returns
bool, true if it exists and is a directory, false otherwise

◆ encrypt()

QString SystemFileManager::encrypt ( QString  ,
QString   
)

FOR INTERNAL USE ONLY. Encrypts the string using password. Returns empty string if not internal script module or exapps.

Parameters
data,thestring to be encrypted
password,thepassword to use to encrypt
Returns
QString, the encrypted data in base 64 format

◆ encryptBinary()

QString SystemFileManager::encryptBinary ( QString  ,
QString   
)

FOR INTERNAL USE ONLY. Encrypts the binary data using password. Returns empty string if not internal script module or exapps.

Parameters
data64,thebinary data to be encrypted in base 64 format
password,thepassword to use to encrypt
Returns
QString, the encrypted data in base 64 format

◆ encryptFile()

bool SystemFileManager::encryptFile ( QString  ,
QString  ,
QString   
)

FOR INTERNAL USE ONLY. Encrypts a file using password and writes to another file. Returns false if not internal script module or exapps.

Parameters
srcFile,thefull path to the source file
dstFile,thefull path of the destination file
password,thepassword to use to encrypt
Returns
bool, true if successful, false otherwise

◆ fileExists()

bool SystemFileManager::fileExists ( QString  )

Returns whether a file exists.

Parameters
path,thefull path of the file
Returns
bool, true if it exists and is a file, false otherwise

◆ getAbsolutePath()

QString SystemFileManager::getAbsolutePath ( QString  )

Returns absolute path name.

Parameters
path,apath anme
Returns
QString, absolute path name.

◆ getEncryptedFileBinaryContents()

QString SystemFileManager::getEncryptedFileBinaryContents ( QString  ,
QString   
)

FOR INTERNAL USE ONLY. Reads and decrypts the binary file content using password. Returns empty string if not internal script module or exapps.

Parameters
filename,thefull path to the file
password,thepassword to use to decrypt
Returns
QString, the decrypted data in base 64 format

◆ getEncryptedFileContents()

QString SystemFileManager::getEncryptedFileContents ( QString  ,
QString   
)

FOR INTERNAL USE ONLY. Reads and decrypts the file content using password. Returns empty string if not internal script module or exapps.

Parameters
filename,thefull path to the file
password,thepassword to use to decrypt
Returns
QString, the decrypted string

◆ getFileBinaryContents()

QString SystemFileManager::getFileBinaryContents ( QString  )

Returns the content of a binary file in base 64 format.

Parameters
filename,thefull path of the file
Returns
QString, the content of the file

◆ getFileCheckSum()

QString SystemFileManager::getFileCheckSum ( QString  )

Returns the SHA-1 checksum of a file.

Parameters
path,thefull path of the file.
Returns
QString, the SHA-1 checksum of the file

◆ getFileContents()

QString SystemFileManager::getFileContents ( QString  )

Returns the content of a plain text file.

Parameters
filename,thefull path of the file
Returns
QString, the content of the file

◆ getFileModificationTime()

long SystemFileManager::getFileModificationTime ( QString  )

Returns the last modification time of a file in number of seconds that have passed since 1970-01-01T00:00:00 UTC.

Parameters
path,thefull path of the file.
Returns
int, last modification time in number of seconds that have passed since 1970-01-01T00:00:00 UTC.

◆ getFilePermissions()

FilePermissions SystemFileManager::getFilePermissions ( QString  )

Returns the permissions of a file.

Parameters
path,thefull path of the file.
Returns
int, the permissions of the file.

◆ getFilesInDirectory()

vector< QString > SystemFileManager::getFilesInDirectory ( QString  )

Returns a list of files and directory names in a directory.

Parameters
path,thefull path of the directory
Returns
vector<QString>, the list of files and directory names

◆ getFileSize()

int SystemFileManager::getFileSize ( QString  )

Returns the size of a file in bytes.

Parameters
path,thefull path of the file.
Returns
int, size of file in bytes

◆ getFileWatcher()

SystemFileWatcher SystemFileManager::getFileWatcher ( )

Returns the SystemFileWatcher instance for this Script Module. This is not available for ExApps and will return NULL.

Returns
SystemFileWatcher, the instance for this Script Module

◆ getOpenFileName()

QString SystemFileManager::getOpenFileName ( QString  ,
QString  ,
QString   
)

Prompt the user to select a file to open. It blocks until the user has selected or canceled the dialog.

Parameters
caption,thetitle of the open dialog
path,thedefault full path
filter,thefilter of files to show in open dialog in the following format: <filter>[;;<filter[...]]] where each <filter> is in the following format: <name>(*.<extension>[ *.<extension>[...]])

example: "Packet Tracer Activity Sequencer File (*.pks *.pksz);;Zip File (*.zip)"

Returns
QString, the full path of the selected file

◆ getOpenFileNames()

vector< String > SystemFileManager::getOpenFileNames ( QString  ,
QString  ,
QString   
)

Prompt the user to select one or multiple files to open. It blocks until the user has selected or canceled the dialog.

Parameters
caption,thetitle of the open dialog
path,thedefault full path
filter,thefilter of files to show in open dialog in the following format: <filter>[;;<filter[...]]] where each <filter> is in the following format: <name>(*.<extension>[ *.<extension>[...]])

example: "Packet Tracer Activity Sequencer File (*.pks *.pksz);;Zip File (*.zip)"

Returns
vector<QString>, the full path of the selected files

◆ getRelativePath()

QString SystemFileManager::getRelativePath ( QString  ,
QString   
)

Returns path name of path2 relative to path1.

Parameters
path1,thefull base path name
path2,thefull sub path name
Returns
QString, the path name of path2 relative to path1.

◆ getSaveFileName()

QString SystemFileManager::getSaveFileName ( QString  ,
QString  ,
QString   
)

Prompt the user to select a file to save. It blocks until the user has selected or canceled the dialog.

Parameters
caption,thetitle of the save dialog
path,thedefault full path
filter,thefilter of files to show in save dialog in the following format: <filter>[;;<filter[...]]] where each <filter> is in the following format: <name>(*.<extension>[ *.<extension>[...]])

example: "Packet Tracer Activity Sequencer File (*.pks *.pksz);;Zip File (*.zip)"

Returns
QString, the full path of the selected file

◆ getSelectedDirectory()

QString SystemFileManager::getSelectedDirectory ( QString  ,
QString   
)

Prompt the user to select a folder. It blocks until the user has selected or canceled the dialog.

Parameters
caption,thetitle of the dialog
path,thedefault full path
Returns
QString, the full path of the selected directory

◆ isAbsolutePath()

bool SystemFileManager::isAbsolutePath ( QString  )

Returns whether the path is absolute.

Parameters
path,apath name
Returns
bool, whether the path is absolute.

◆ isRelativePath()

bool SystemFileManager::isRelativePath ( QString  )

Returns whether the path is relative.

Parameters
path,apath name
Returns
bool, whether the path is relative.

◆ makeDirectory()

bool SystemFileManager::makeDirectory ( QString  )

Creates a directory including all missing parents.

Parameters
path,thefull path of the directory
Returns
bool, true if successful, false otherwise

◆ moveSrcDirectoryToDestDirectory()

bool SystemFileManager::moveSrcDirectoryToDestDirectory ( QString  ,
QString  ,
bool   
)

Moves or renames a directory.

Parameters
srcDir,thefull path of the source
destDir,thefull path of the destination
bReplace,trueif to replace, false otherwise
Returns
bool, true if successful, false otherwise

◆ moveSrcFileToDestFile()

bool SystemFileManager::moveSrcFileToDestFile ( QString  ,
QString  ,
bool   
)

Moves or renames a file.

Parameters
srcFile,thefull path of the source
destFile,thefull path of the destination
bReplace,trueif to replace, false otherwise
Returns
bool, true if successful, false otherwise

◆ removeDirectory()

bool SystemFileManager::removeDirectory ( QString  )

Removes a directory recursively including all sub directories and files.

Parameters
path,thefull path of the directory
Returns
bool, true if successful, false otherwise

◆ removeFile()

bool SystemFileManager::removeFile ( QString  )

Removes a file.

Parameters
path,thefull path of the file
Returns
bool, true if successful, false otherwise

◆ setFilePermissions()

bool SystemFileManager::setFilePermissions ( QString  ,
FilePermissions   
)

Sets the permissions of a file.

Parameters
path,thefull path of the file.
int,standardUnix permissions format
Returns
bool, true if successful, false otherwise

◆ unzipFile()

bool SystemFileManager::unzipFile ( QString  )

Unzips up a file in the same directory with the same name.

Parameters
filePath,thefull path of the zip file
password,thepassword to use to decrypt the encrypted zip
Returns
bool, true if successful, false otherwise

◆ unzipFileTo()

bool SystemFileManager::unzipFileTo ( QString  ,
QString   
)

Unzips up a file in the same directory to a specified directory.

Parameters
filePath,thefull path of the zip file
dstPath,thefull path of the destination directory
password,thepassword to use to decrypt the encrypted zip
Returns
bool, true if successful, false otherwise

◆ unzipFileToWithPassword()

bool SystemFileManager::unzipFileToWithPassword ( QString  ,
QString  ,
QString   
)

◆ unzipFileWithPassword()

bool SystemFileManager::unzipFileWithPassword ( QString  ,
QString   
)

◆ writeBinaryToEncryptedFile()

bool SystemFileManager::writeBinaryToEncryptedFile ( QString  ,
QString  ,
QString   
)

FOR INTERNAL USE ONLY. Encrypts the binary content using password and writes to file. Returns false if not internal script module or exapps.

Parameters
filename,thefull path to the file
contents64,thedata in base 64 format
password,thepassword to use to encrypt
Returns
bool, true if successful, false otherwise

◆ writeBinaryToFile()

bool SystemFileManager::writeBinaryToFile ( QString  ,
QString   
)

Writes binary content to a file.

Parameters
filename,thefull path of the file.
contents64,thecontent in base 64 format
Returns
bool, true if successful, false otherwise

◆ writePlainTextToFile()

bool SystemFileManager::writePlainTextToFile ( QString  ,
QString   
)

Writes plain text content to a file using UTF-8 encoding.

Parameters
filename,thefull path of the file.
contents,thecontents
Returns
bool, true if successful, false otherwise

◆ writeTextToEncryptedFile()

bool SystemFileManager::writeTextToEncryptedFile ( QString  ,
QString  ,
QString   
)

FOR INTERNAL USE ONLY. Encrypts the text content using password and writes to file. Returns false if not internal script module or exapps.

Parameters
filename,thefull path to the file
contents,thetext content
password,thepassword to use to encrypt
Returns
bool, true if successful, false otherwise

◆ writeTextToEncryptedLogFile()

bool SystemFileManager::writeTextToEncryptedLogFile ( QString  ,
QString   
)

FOR INTERNAL USE ONLY. Encrypts the text content using same method as PT log file format and writes to file. Returns false if not internal script module or exapps.

Parameters
filename,thefull path to the file
contents,thetext content
Returns
bool, true if successful, false otherwise

◆ writeTextToFile()

bool SystemFileManager::writeTextToFile ( QString  ,
QString   
)

Writes plain text content to a file using UTF-8 encoding.

Parameters
filename,thefull path of the file.
contents64,thecontent in base 64 format
Returns
bool, true if successful, false otherwise

◆ zipDirectory()

bool SystemFileManager::zipDirectory ( QString  )

Zips up a directory into a zip file with the same name.

Parameters
path,thefull path of the directory
password,thepassword to use to encrypt the zip
Returns
bool, true if successful, false otherwise

◆ zipDirectoryTo()

bool SystemFileManager::zipDirectoryTo ( QString  ,
QString   
)

Zips up a directory into a zip file.

Parameters
path,thefull path of the directory
dstFile,thefull path of the destination zip file
password,thepassword to use to encrypt the zip
Returns
bool, true if successful, false otherwise

◆ zipDirectoryToWithPassword()

bool SystemFileManager::zipDirectoryToWithPassword ( QString  ,
QString  ,
QString   
)

◆ zipDirectoryWithPassword()

bool SystemFileManager::zipDirectoryWithPassword ( QString  ,
QString   
)

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