Use C++17 method Filesystem instead of local

master
JuanJakobo 2022-09-08 15:10:23 +02:00
parent 27fce30665
commit 2042ca4da5
4 changed files with 11 additions and 15 deletions

View File

@ -81,7 +81,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/src/api/
)
TARGET_LINK_LIBRARIES (Nextcloud.app PRIVATE inkview freetype curl sqlite3)
TARGET_LINK_LIBRARIES (Nextcloud.app PRIVATE inkview freetype curl sqlite3 stdc++fs)
INSTALL (TARGETS Nextcloud.app)

View File

@ -156,6 +156,7 @@ std::vector<WebDAVItem> SqliteConnector::getItemsChildren(const string &parentPa
void SqliteConnector::deleteChildren(const string &parentPath)
{
//TODO missing the onces where parentPath is one folder deeper and also destroyed
open();
int rs;
sqlite3_stmt *stmt = 0;

View File

@ -13,6 +13,7 @@
#include "eventHandler.h"
#include <string>
#include <experimental/filesystem>
#include <curl/curl.h>
#include <fstream>
#include <sstream>
@ -81,13 +82,11 @@ void WebDAV::logout(bool deleteFiles)
{
if (deleteFiles)
{
string cmd = "rm -rf " + Util::accessConfig<string>(Action::IReadString, "storageLocation",{}) + "/" +
Util::accessConfig<string>(Action::IReadString,"UUID",{}) + '/';
system(cmd.c_str());
std::experimental::filesystem::remove_all(Util::accessConfig<string>(Action::IReadString, "storageLocation",{}) + "/" + Util::accessConfig<string>(Action::IReadString,"UUID",{}) + '/');
}
remove(CONFIG_PATH.c_str());
remove((CONFIG_PATH + ".back.").c_str());
remove(DB_PATH.c_str());
std::experimental::filesystem::remove(CONFIG_PATH.c_str());
std::experimental::filesystem::remove((CONFIG_PATH + ".back.").c_str());
std::experimental::filesystem::remove(DB_PATH.c_str());
_url = "";
_password = "";
_username = "";

View File

@ -19,6 +19,7 @@
#include "fileView.h"
#include "fileModel.h"
#include <experimental/filesystem>
#include <string>
#include <memory>
@ -289,16 +290,11 @@ void EventHandler::contextMenuHandler(const int index)
{
if (_webDAVView->getCurrentEntry().type == Itemtype::IFOLDER)
{
Message(ICON_ERROR, "Error", "Currently only files can be deleted.", 2000);
//string cmd = "rm -rf " + _webDAVView->getCurrentEntry().localPath + '/';
//if (rmdir((_webDAVView->getCurrentEntry().localPath + '/').c_str()) == 0)
//Log::writeInfoLog("okay");
//if (system(cmd.c_str()) == 0)
//Log::writeInfoLog("success");
std::experimental::filesystem::remove_all(_webDAVView->getCurrentEntry().localPath);
}
else
{
remove(_webDAVView->getCurrentEntry().localPath.c_str());
std::experimental::filesystem::remove(_webDAVView->getCurrentEntry().localPath);
}
vector<WebDAVItem> currentWebDAVItems = _sqllite.getItemsChildren(_currentPath);
updateItems(currentWebDAVItems);
@ -306,7 +302,7 @@ void EventHandler::contextMenuHandler(const int index)
}
else
{
Message(ICON_ERROR, "Error", "File is not available.", 1000);
Message(ICON_ERROR, "Error", "File is not available locally.", 1000);
_webDAVView->invertCurrentEntryColor();
}
break;