blob: a32743a584b47fcaafe5a9ff010ef4e505ba13d3 [file] [log] [blame]
Dees_Troya13d74f2013-03-24 08:54:55 -05001/*
2 Copyright 2012 bigbiff/Dees_Troy TeamWin
3 This file is part of TWRP/TeamWin Recovery Project.
4
5 TWRP is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 TWRP is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with TWRP. If not, see <http://www.gnu.org/licenses/>.
17*/
Dees_Troy51a0e822012-09-05 15:24:24 -040018
Dees_Troy51a0e822012-09-05 15:24:24 -040019#include <string.h>
Dees_Troy51a0e822012-09-05 15:24:24 -040020#include <sys/stat.h>
Dees_Troy51a0e822012-09-05 15:24:24 -040021#include <dirent.h>
Dees_Troy51a0e822012-09-05 15:24:24 -040022#include <algorithm>
mauronofrio27020942020-01-10 16:44:28 +010023#ifdef __ANDROID_API_M__
24#include <vector>
25#ifdef __ANDROID_API_N__
26#include <android-base/strings.h>
27#else
28#include <base/strings.h>
29#endif
30#else
31#endif
Dees_Troy51a0e822012-09-05 15:24:24 -040032extern "C" {
Dees_Troy2673cec2013-04-02 20:22:16 +000033#include "../twcommon.h"
Dees_Troy51a0e822012-09-05 15:24:24 -040034}
Ethan Yonkerfbb43532015-12-28 21:54:50 +010035#include "../minuitwrp/minui.h"
Dees_Troy51a0e822012-09-05 15:24:24 -040036
37#include "rapidxml.hpp"
38#include "objects.hpp"
39#include "../data.hpp"
Dees_Troy3ee47bc2013-01-25 21:47:37 +000040#include "../twrp-functions.hpp"
bigbiff bigbiff19fb79c2016-09-05 21:04:51 -040041#include "../adbbu/libtwadbbu.hpp"
Dees_Troy51a0e822012-09-05 15:24:24 -040042
Dees_Troy51a0e822012-09-05 15:24:24 -040043int GUIFileSelector::mSortOrder = 0;
44
Ethan Yonker0a3a98f2015-02-05 00:48:28 +010045GUIFileSelector::GUIFileSelector(xml_node<>* node) : GUIScrollList(node)
Dees_Troy51a0e822012-09-05 15:24:24 -040046{
47 xml_attribute<>* attr;
48 xml_node<>* child;
Dees_Troy51a0e822012-09-05 15:24:24 -040049
Ethan Yonker0a3a98f2015-02-05 00:48:28 +010050 mFolderIcon = mFileIcon = NULL;
Dees_Troy51a0e822012-09-05 15:24:24 -040051 mShowFolders = mShowFiles = mShowNavFolders = 1;
52 mUpdate = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -040053 mPathVar = "cwd";
Dees_Troyc0583f52013-02-28 11:19:57 -060054 updateFileList = false;
Dees_Troy51a0e822012-09-05 15:24:24 -040055
Ethan Yonker0a3a98f2015-02-05 00:48:28 +010056 // Load filter for filtering files (e.g. *.zip for only zips)
that72b90e32015-02-23 22:57:14 +010057 child = FindNode(node, "filter");
Ethan Yonker0a3a98f2015-02-05 00:48:28 +010058 if (child) {
Dees_Troy51a0e822012-09-05 15:24:24 -040059 attr = child->first_attribute("extn");
60 if (attr)
61 mExtn = attr->value();
62 attr = child->first_attribute("folders");
63 if (attr)
64 mShowFolders = atoi(attr->value());
65 attr = child->first_attribute("files");
66 if (attr)
67 mShowFiles = atoi(attr->value());
68 attr = child->first_attribute("nav");
69 if (attr)
70 mShowNavFolders = atoi(attr->value());
71 }
Ian Macdonald15430b62021-01-23 18:52:28 +010072 child = FindNode(node, "prfxfilter");
73 if (child) {
74 attr = child->first_attribute("prfx");
75 if (attr)
76 mPrfx = attr->value();
77 }
Dees_Troy51a0e822012-09-05 15:24:24 -040078
79 // Handle the path variable
that72b90e32015-02-23 22:57:14 +010080 child = FindNode(node, "path");
Ethan Yonker0a3a98f2015-02-05 00:48:28 +010081 if (child) {
Dees_Troy51a0e822012-09-05 15:24:24 -040082 attr = child->first_attribute("name");
83 if (attr)
84 mPathVar = attr->value();
85 attr = child->first_attribute("default");
Ethan Yonker21ff02a2015-02-18 14:35:00 -060086 if (attr) {
87 mPathDefault = attr->value();
Dees_Troy51a0e822012-09-05 15:24:24 -040088 DataManager::SetValue(mPathVar, attr->value());
Ethan Yonker21ff02a2015-02-18 14:35:00 -060089 }
Dees_Troy51a0e822012-09-05 15:24:24 -040090 }
91
92 // Handle the result variable
that72b90e32015-02-23 22:57:14 +010093 child = FindNode(node, "data");
Ethan Yonker0a3a98f2015-02-05 00:48:28 +010094 if (child) {
Dees_Troy51a0e822012-09-05 15:24:24 -040095 attr = child->first_attribute("name");
96 if (attr)
97 mVariable = attr->value();
98 attr = child->first_attribute("default");
99 if (attr)
100 DataManager::SetValue(mVariable, attr->value());
101 }
102
103 // Handle the sort variable
that72b90e32015-02-23 22:57:14 +0100104 child = FindNode(node, "sort");
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100105 if (child) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400106 attr = child->first_attribute("name");
107 if (attr)
108 mSortVariable = attr->value();
109 attr = child->first_attribute("default");
110 if (attr)
111 DataManager::SetValue(mSortVariable, attr->value());
112
113 DataManager::GetValue(mSortVariable, mSortOrder);
114 }
115
116 // Handle the selection variable
that72b90e32015-02-23 22:57:14 +0100117 child = FindNode(node, "selection");
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100118 if (child && (attr = child->first_attribute("name")))
119 mSelection = attr->value();
120 else
Dees_Troy51a0e822012-09-05 15:24:24 -0400121 mSelection = "0";
122
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100123 // Get folder and file icons if present
that72b90e32015-02-23 22:57:14 +0100124 child = FindNode(node, "icon");
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100125 if (child) {
thatf6ed8fc2015-02-14 20:23:16 +0100126 mFolderIcon = LoadAttrImage(child, "folder");
127 mFileIcon = LoadAttrImage(child, "file");
Vojtech Bocek7cc278b2013-02-24 01:40:19 +0100128 }
Ethan Yonker58f21322018-08-24 11:17:36 -0500129 int iconWidth = 0, iconHeight = 0;
130 if (mFolderIcon && mFolderIcon->GetResource() && mFileIcon && mFileIcon->GetResource()) {
131 iconWidth = std::max(mFolderIcon->GetWidth(), mFileIcon->GetWidth());
132 iconHeight = std::max(mFolderIcon->GetHeight(), mFileIcon->GetHeight());
133 } else if (mFolderIcon && mFolderIcon->GetResource()) {
134 iconWidth = mFolderIcon->GetWidth();
135 iconHeight = mFolderIcon->GetHeight();
136 } else if (mFileIcon && mFileIcon->GetResource()) {
137 iconWidth = mFileIcon->GetWidth();
138 iconHeight = mFileIcon->GetHeight();
139 }
thatf6ed8fc2015-02-14 20:23:16 +0100140 SetMaxIconSize(iconWidth, iconHeight);
Dees_Troy51a0e822012-09-05 15:24:24 -0400141
142 // Fetch the file/folder list
143 std::string value;
144 DataManager::GetValue(mPathVar, value);
Dees_Troy80a11d92013-01-25 16:36:07 +0000145 GetFileList(value);
Dees_Troy51a0e822012-09-05 15:24:24 -0400146}
147
148GUIFileSelector::~GUIFileSelector()
149{
Dees_Troy51a0e822012-09-05 15:24:24 -0400150}
151
152int GUIFileSelector::Update(void)
153{
Matt Mowera8a89d12016-12-30 18:10:37 -0600154 if (!isConditionTrue())
Vojtech Bocekede51c52014-02-07 23:58:09 +0100155 return 0;
156
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100157 GUIScrollList::Update();
158
159 // Update the file list if needed
160 if (updateFileList) {
161 string value;
162 DataManager::GetValue(mPathVar, value);
163 if (GetFileList(value) == 0) {
164 updateFileList = false;
Dees_Troy51a0e822012-09-05 15:24:24 -0400165 mUpdate = 1;
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100166 } else
167 return 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400168 }
169
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100170 if (mUpdate) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400171 mUpdate = 0;
172 if (Render() == 0)
173 return 2;
174 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400175 return 0;
176}
177
Vojtech Bocek07220562014-02-08 02:05:33 +0100178int GUIFileSelector::NotifyVarChange(const std::string& varName, const std::string& value)
Dees_Troy51a0e822012-09-05 15:24:24 -0400179{
thatfa30aca2015-02-13 01:22:22 +0100180 GUIScrollList::NotifyVarChange(varName, value);
181
Matt Mowera8a89d12016-12-30 18:10:37 -0600182 if (!isConditionTrue())
Vojtech Bocekede51c52014-02-07 23:58:09 +0100183 return 0;
184
Dees_Troy146d72a2013-03-11 17:46:19 +0000185 if (varName.empty()) {
186 // Always clear the data variable so we know to use it
187 DataManager::SetValue(mVariable, "");
188 }
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100189 if (varName == mPathVar || varName == mSortVariable) {
Dees_Troy4622cf92013-03-01 15:29:36 -0600190 if (varName == mSortVariable) {
191 DataManager::GetValue(mSortVariable, mSortOrder);
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100192 } else {
193 // Reset the list to the top
194 SetVisibleListLocation(0);
Ethan Yonker21ff02a2015-02-18 14:35:00 -0600195 if (value.empty())
196 DataManager::SetValue(mPathVar, mPathDefault);
Dees_Troyc0583f52013-02-28 11:19:57 -0600197 }
198 updateFileList = true;
Dees_Troy51a0e822012-09-05 15:24:24 -0400199 mUpdate = 1;
200 return 0;
201 }
202 return 0;
203}
204
Dees_Troy51a0e822012-09-05 15:24:24 -0400205bool GUIFileSelector::fileSort(FileData d1, FileData d2)
206{
207 if (d1.fileName == ".")
208 return -1;
209 if (d2.fileName == ".")
210 return 0;
thatc12a7f02016-01-28 20:52:16 +0100211 if (d1.fileName == "..")
Dees_Troy51a0e822012-09-05 15:24:24 -0400212 return -1;
thatc12a7f02016-01-28 20:52:16 +0100213 if (d2.fileName == "..")
Dees_Troy51a0e822012-09-05 15:24:24 -0400214 return 0;
Matt Mowerfb1c4ff2014-04-16 13:43:36 -0500215
Dees_Troy51a0e822012-09-05 15:24:24 -0400216 switch (mSortOrder) {
217 case 3: // by size largest first
218 if (d1.fileSize == d2.fileSize || d1.fileType == DT_DIR) // some directories report a different size than others - but this is not the size of the files inside the directory, so we just sort by name on directories
219 return (strcasecmp(d1.fileName.c_str(), d2.fileName.c_str()) < 0);
Dees_Troy6ef66352013-02-21 08:26:57 -0600220 return d1.fileSize < d2.fileSize;
Dees_Troy51a0e822012-09-05 15:24:24 -0400221 case -3: // by size smallest first
222 if (d1.fileSize == d2.fileSize || d1.fileType == DT_DIR) // some directories report a different size than others - but this is not the size of the files inside the directory, so we just sort by name on directories
223 return (strcasecmp(d1.fileName.c_str(), d2.fileName.c_str()) > 0);
Dees_Troy6ef66352013-02-21 08:26:57 -0600224 return d1.fileSize > d2.fileSize;
Dees_Troy51a0e822012-09-05 15:24:24 -0400225 case 2: // by last modified date newest first
226 if (d1.lastModified == d2.lastModified)
227 return (strcasecmp(d1.fileName.c_str(), d2.fileName.c_str()) < 0);
Dees_Troy6ef66352013-02-21 08:26:57 -0600228 return d1.lastModified < d2.lastModified;
Dees_Troy51a0e822012-09-05 15:24:24 -0400229 case -2: // by date oldest first
230 if (d1.lastModified == d2.lastModified)
231 return (strcasecmp(d1.fileName.c_str(), d2.fileName.c_str()) > 0);
Dees_Troy6ef66352013-02-21 08:26:57 -0600232 return d1.lastModified > d2.lastModified;
Dees_Troy51a0e822012-09-05 15:24:24 -0400233 case -1: // by name descending
234 return (strcasecmp(d1.fileName.c_str(), d2.fileName.c_str()) > 0);
235 default: // should be a 1 - sort by name ascending
236 return (strcasecmp(d1.fileName.c_str(), d2.fileName.c_str()) < 0);
237 }
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100238 return 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400239}
240
241int GUIFileSelector::GetFileList(const std::string folder)
242{
243 DIR* d;
244 struct dirent* de;
245 struct stat st;
246
247 // Clear all data
248 mFolderList.clear();
249 mFileList.clear();
250
251 d = opendir(folder.c_str());
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100252 if (d == NULL) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000253 LOGINFO("Unable to open '%s'\n", folder.c_str());
Dees_Troy80a11d92013-01-25 16:36:07 +0000254 if (folder != "/" && (mShowNavFolders != 0 || mShowFiles != 0)) {
255 size_t found;
256 found = folder.find_last_of('/');
257 if (found != string::npos) {
258 string new_folder = folder.substr(0, found);
259
260 if (new_folder.length() < 2)
261 new_folder = "/";
262 DataManager::SetValue(mPathVar, new_folder);
263 }
264 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400265 return -1;
266 }
267
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100268 while ((de = readdir(d)) != NULL) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400269 FileData data;
Ian Macdonald15430b62021-01-23 18:52:28 +0100270 bool match = false;
Dees_Troy51a0e822012-09-05 15:24:24 -0400271
272 data.fileName = de->d_name;
273 if (data.fileName == ".")
274 continue;
275 if (data.fileName == ".." && folder == "/")
276 continue;
thatc12a7f02016-01-28 20:52:16 +0100277
278 data.fileType = de->d_type;
Dees_Troy51a0e822012-09-05 15:24:24 -0400279
280 std::string path = folder + "/" + data.fileName;
281 stat(path.c_str(), &st);
282 data.protection = st.st_mode;
283 data.userId = st.st_uid;
284 data.groupId = st.st_gid;
285 data.fileSize = st.st_size;
286 data.lastAccess = st.st_atime;
287 data.lastModified = st.st_mtime;
288 data.lastStatChange = st.st_ctime;
289
Dees_Troy3ee47bc2013-01-25 21:47:37 +0000290 if (data.fileType == DT_UNKNOWN) {
291 data.fileType = TWFunc::Get_D_Type_From_Stat(path);
292 }
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100293 if (data.fileType == DT_DIR) {
thatc12a7f02016-01-28 20:52:16 +0100294 if (mShowNavFolders || (data.fileName != "." && data.fileName != ".."))
Dees_Troy51a0e822012-09-05 15:24:24 -0400295 mFolderList.push_back(data);
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100296 } else if (data.fileType == DT_REG || data.fileType == DT_LNK || data.fileType == DT_BLK) {
mauronofrio27020942020-01-10 16:44:28 +0100297#ifdef __ANDROID_API_M__
298 std::vector<std::string> mExtnResults = android::base::Split(mExtn, ";");
299 for (const std::string& mExtnElement : mExtnResults)
300 {
301 std::string mExtnName = android::base::Trim(mExtnElement);
Ian Macdonald15430b62021-01-23 18:52:28 +0100302 if (mExtnName.empty() || (data.fileName.length() >= mExtnName.length() && data.fileName.substr(data.fileName.length() - mExtnName.length()) == mExtnName)) {
mauronofrio27020942020-01-10 16:44:28 +0100303 if (mExtnName == ".ab" && twadbbu::Check_ADB_Backup_File(path))
304 mFolderList.push_back(data);
305 else
306 mFileList.push_back(data);
Ian Macdonald15430b62021-01-23 18:52:28 +0100307 match = true;
308 break;
309 }
mauronofrio27020942020-01-10 16:44:28 +0100310 }
Ian Macdonald15430b62021-01-23 18:52:28 +0100311
312 if (!match) {
313 std::vector<std::string> mPrfxResults = android::base::Split(mPrfx, ";");
314 for (const std::string& mPrfxElement : mPrfxResults)
315 {
316 std::string mPrfxName = android::base::Trim(mPrfxElement);
317 if (!mPrfxName.empty() && data.fileName.length() >= mPrfxName.length() && data.fileName.substr(0, mPrfxName.length()) == mPrfxName) {
318 mFileList.push_back(data);
319 }
mauronofrio27020942020-01-10 16:44:28 +0100320#else //On android 5.1 we can't use android::base::Trim and Split so just use the first extension written in the list
321 std::size_t seppos = mExtn.find_first_of(";");
322 std::string mExtnf;
323 if (seppos!=std::string::npos){
324 mExtnf = mExtn.substr(0, seppos);
325 } else {
Ian Macdonald15430b62021-01-23 18:52:28 +0100326 mExtnf = mExtn;
mauronofrio27020942020-01-10 16:44:28 +0100327 }
Ian Macdonald15430b62021-01-23 18:52:28 +0100328 if (mExtnf.empty() || (data.fileName.length() >= mExtnf.length() && data.fileName.substr(data.fileName.length() - mExtnf.length()) == mExtnf)) {
mauronofrio27020942020-01-10 16:44:28 +0100329 if (mExtnf == ".ab" && twadbbu::Check_ADB_Backup_File(path))
bigbiff bigbiff19fb79c2016-09-05 21:04:51 -0400330 mFolderList.push_back(data);
331 else
332 mFileList.push_back(data);
Ian Macdonald15430b62021-01-23 18:52:28 +0100333 match = true;
334 }
335
336 if (!match) {
337 std::size_t seppos = mPrfx.find_first_of(";");
338 std::string mPrfxf;
339 if (seppos!=std::string::npos){
340 mPrfxf = mPrfx.substr(0, seppos);
341 } else {
342 mPrfxf = mPrfx;
343 }
344 if (!mPrfxf.empty() && data.fileName.length() >= mPrfxf.length() && data.fileName.substr(0, mPrfxf.length()) == mPrfxf) {
345 mFileList.push_back(data);
mauronofrio27020942020-01-10 16:44:28 +0100346#endif
Ian Macdonald15430b62021-01-23 18:52:28 +0100347 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400348 }
349 }
350 }
351 closedir(d);
352
353 std::sort(mFolderList.begin(), mFolderList.end(), fileSort);
354 std::sort(mFileList.begin(), mFileList.end(), fileSort);
Dees_Troyc0583f52013-02-28 11:19:57 -0600355
Dees_Troy51a0e822012-09-05 15:24:24 -0400356 return 0;
357}
358
359void GUIFileSelector::SetPageFocus(int inFocus)
360{
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100361 GUIScrollList::SetPageFocus(inFocus);
362 if (inFocus) {
Ethan Yonker21ff02a2015-02-18 14:35:00 -0600363 std::string value;
364 DataManager::GetValue(mPathVar, value);
365 if (value.empty())
366 DataManager::SetValue(mPathVar, mPathDefault);
Dees_Troyc0583f52013-02-28 11:19:57 -0600367 updateFileList = true;
Dees_Troyc0583f52013-02-28 11:19:57 -0600368 mUpdate = 1;
Dees_Troy51a0e822012-09-05 15:24:24 -0400369 }
Dees_Troya13d74f2013-03-24 08:54:55 -0500370}
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100371
372size_t GUIFileSelector::GetItemCount()
373{
374 size_t folderSize = mShowFolders ? mFolderList.size() : 0;
375 size_t fileSize = mShowFiles ? mFileList.size() : 0;
376 return folderSize + fileSize;
377}
378
that0af77952015-02-25 08:52:19 +0100379void GUIFileSelector::RenderItem(size_t itemindex, int yPos, bool selected)
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100380{
381 size_t folderSize = mShowFolders ? mFolderList.size() : 0;
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100382
that0af77952015-02-25 08:52:19 +0100383 ImageResource* icon;
384 std::string text;
385
386 if (itemindex < folderSize) {
387 text = mFolderList.at(itemindex).fileName;
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100388 icon = mFolderIcon;
thatc12a7f02016-01-28 20:52:16 +0100389 if (text == "..")
390 text = gui_lookup("up_a_level", "(Up A Level)");
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100391 } else {
that0af77952015-02-25 08:52:19 +0100392 text = mFileList.at(itemindex - folderSize).fileName;
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100393 icon = mFileIcon;
394 }
that0af77952015-02-25 08:52:19 +0100395
396 RenderStdItem(yPos, selected, icon, text.c_str());
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100397}
398
399void GUIFileSelector::NotifySelect(size_t item_selected)
400{
401 size_t folderSize = mShowFolders ? mFolderList.size() : 0;
402 size_t fileSize = mShowFiles ? mFileList.size() : 0;
403
404 if (item_selected < folderSize + fileSize) {
405 // We've selected an item!
406 std::string str;
407 if (item_selected < folderSize) {
408 std::string cwd;
409
410 str = mFolderList.at(item_selected).fileName;
411 if (mSelection != "0")
412 DataManager::SetValue(mSelection, str);
413 DataManager::GetValue(mPathVar, cwd);
414
415 // Ignore requests to do nothing
416 if (str == ".") return;
thatc12a7f02016-01-28 20:52:16 +0100417 if (str == "..") {
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100418 if (cwd != "/") {
419 size_t found;
420 found = cwd.find_last_of('/');
421 cwd = cwd.substr(0,found);
422
423 if (cwd.length() < 2) cwd = "/";
424 }
425 } else {
426 // Add a slash if we're not the root folder
427 if (cwd != "/") cwd += "/";
428 cwd += str;
429 }
430
bigbiff bigbiff19fb79c2016-09-05 21:04:51 -0400431 if (mShowNavFolders == 0 && (mShowFiles == 0 || mExtn == ".ab")) {
432 // this is probably the restore list and we need to save chosen location to mVariable instead of mPathVar
Ethan Yonker0a3a98f2015-02-05 00:48:28 +0100433 DataManager::SetValue(mVariable, cwd);
434 } else {
435 // We are changing paths, so we need to set mPathVar
436 DataManager::SetValue(mPathVar, cwd);
437 }
438 } else if (!mVariable.empty()) {
439 str = mFileList.at(item_selected - folderSize).fileName;
440 if (mSelection != "0")
441 DataManager::SetValue(mSelection, str);
442
443 std::string cwd;
444 DataManager::GetValue(mPathVar, cwd);
445 if (cwd != "/")
446 cwd += "/";
447 DataManager::SetValue(mVariable, cwd + str);
448 }
449 }
450 mUpdate = 1;
451}