Index: sources/storage/filehandler.cpp =================================================================== diff -u -r5e78f0799b46963feb5756decb1a27b952cd19b3 -r56d00a82669a7a2c00ab90109a89dbec8db27527 --- sources/storage/filehandler.cpp (.../filehandler.cpp) (revision 5e78f0799b46963feb5756decb1a27b952cd19b3) +++ sources/storage/filehandler.cpp (.../filehandler.cpp) (revision 56d00a82669a7a2c00ab90109a89dbec8db27527) @@ -22,10 +22,19 @@ // Project #include "storageglobals.h" #include "logger.h" +#include "threads.h" // namespace using namespace Storage; +/*! + * \brief FileHandler::write + * \details Writes the content of vContent into the file vFileName. + * \param vFileName - Source file name + * \param vContent - The content which is going to be written in the file. + * \param vAppend - if set to true the content will be appended at the end of the file. + * \return false if file can't be opened. + */ bool FileHandler::write(const QString &vFileName, const QString &vContent, bool vAppend) { QFile file(vFileName); @@ -42,6 +51,13 @@ return true; } +/*! + * \brief FileHandler::read + * \details reads file vFilename content into vContent variable. + * \param vFileName - Source file name + * \param vContent - The content of the file which will be set when done. + * \return false if file can't be opened. + */ bool FileHandler::read(const QString &vFileName, QString &vContent) { QFile file(vFileName); @@ -54,22 +70,38 @@ return true; } +/*! + * \brief FileHandler::copyFolder + * \details Copies all the file and folders recursively. + * \param vSource - The source folder + * \param vDestination - The destination folder + * \return Tue on successful execution. + * \note This method uses the Linux "cp -r vSource vDestination" command + * Not a Thread-Safe method so made private to be called by export log + * QtConcurrent::run. + * + */ int FileHandler::copyFolder(const QString &vSource, const QString &vDestination ) { - PRINT_THREAD_NAME; - QString cp = "cp"; QStringList arguments; arguments << "-r" << vSource << vDestination; return QProcess::execute(cp, arguments); } -bool FileHandler::exportLog() +/*! + * \brief FileHandler::concurrentExportLog + * \details Exports the log files from log folder (Storage::Log_Base_Path_Name_Location) + * into USB drive folder (Storage::USB_Mount_Point) + * \return always returns true for now. + * \note This method uses QtConcurrent run to execute the copyFolder method. + */ +bool FileHandler::concurrentExportLog() { QString mSource = Storage::Log_Base_Path_Name_Location; QString mDestination = Storage::USB_Mount_Point; //QFuture future = QtConcurrent::run(this, &FileHandler::copyFolder, mSource, mDestination); //return future.result(); - return 0; + return true; }