Index: sources/storage/FileHandler.cpp =================================================================== diff -u -r552f811f7ba3b62ecbaa6eab9343b90e3f790c12 -r6c6f1f5d466badd9b4fd67be7c907234c342b2a2 --- sources/storage/FileHandler.cpp (.../FileHandler.cpp) (revision 552f811f7ba3b62ecbaa6eab9343b90e3f790c12) +++ sources/storage/FileHandler.cpp (.../FileHandler.cpp) (revision 6c6f1f5d466badd9b4fd67be7c907234c342b2a2) @@ -23,6 +23,7 @@ // Project // #include "Logger.h" // logger should not be used in this class. +#include "StorageGlobals.h" // namespace using namespace Storage; @@ -265,7 +266,6 @@ */ bool FileHandler::isMounted(const QString &vPath, bool *vIsReadOnly) { - // disabled coco begin validated: Needed User Interaction to make the device not ready so tested manually bool mounted = false; // removing the extra '/' from the vPath if there is to be able to compare to the root path of the storage QString path = vPath.trimmed(); @@ -289,9 +289,36 @@ } return mounted; } -// disabled coco end /*! + * \brief FileHandler::tmpUsable + * \details Checks if the temp folder is available for read and write to file and directory + * \note This function will only chek the temp folder usability once + * and next call will just return the first result, + * assuming that the temp file situation is not going to change and is stable. + * \return true on success + */ +bool FileHandler::tmpUsable() +{ + static bool ok = false; + static bool tested = false; + if ( tested ) return ok; + + QString tmp = Storage::Standard_tmp; + QString tmpTestFolder = tmp + "tmp_test_folder" ; + QString tmpTestFile = tmp + "tmp_test_file" ; + QString tmpTestContent = "tmp_test_content"; + QDir dir(tmp); + if ( ! dir.exists() ) { ok = false; goto lOut; } + if ( ! FileHandler::makeFolder (tmpTestFolder )) { ok = false; goto lOut; } + if ( ! FileHandler::write (tmpTestFile , tmpTestContent )) { ok = false; goto lOut; } + if ( ! FileHandler::read (tmpTestFolder, tmpTestContent )) { ok = false; goto lOut; } +lOut: + tested = true; + return ok; +} + +/*! * \brief FileHandler::find * \details The function to find files. * It mainly been implemented to find the files are using some amount of total storage in the vPath by percentage,