diff options
author | Dees_Troy <dees_troy@teamw.in> | 2013-01-25 22:47:37 +0100 |
---|---|---|
committer | Dees_Troy <dees_troy@teamw.in> | 2013-01-28 16:20:03 +0100 |
commit | 3ee47bc2ab41e5bf10774fc7f06ae6ca43d7e78e (patch) | |
tree | aecfd88ef42f1e696c788ab2ff1110ac009b3807 | |
parent | Remove thread logging from actions.cpp (diff) | |
download | android_bootable_recovery-3ee47bc2ab41e5bf10774fc7f06ae6ca43d7e78e.tar android_bootable_recovery-3ee47bc2ab41e5bf10774fc7f06ae6ca43d7e78e.tar.gz android_bootable_recovery-3ee47bc2ab41e5bf10774fc7f06ae6ca43d7e78e.tar.bz2 android_bootable_recovery-3ee47bc2ab41e5bf10774fc7f06ae6ca43d7e78e.tar.lz android_bootable_recovery-3ee47bc2ab41e5bf10774fc7f06ae6ca43d7e78e.tar.xz android_bootable_recovery-3ee47bc2ab41e5bf10774fc7f06ae6ca43d7e78e.tar.zst android_bootable_recovery-3ee47bc2ab41e5bf10774fc7f06ae6ca43d7e78e.zip |
Diffstat (limited to '')
-rw-r--r-- | gui/fileselector.cpp | 11 | ||||
-rw-r--r-- | twrp-functions.cpp | 21 | ||||
-rw-r--r-- | twrp-functions.hpp | 1 |
3 files changed, 31 insertions, 2 deletions
diff --git a/gui/fileselector.cpp b/gui/fileselector.cpp index aecdd253c..38eaadd20 100644 --- a/gui/fileselector.cpp +++ b/gui/fileselector.cpp @@ -31,6 +31,7 @@ extern "C" { #include "rapidxml.hpp" #include "objects.hpp" #include "../data.hpp" +#include "../twrp-functions.hpp" #define TW_FILESELECTOR_UP_A_LEVEL "(Up A Level)" @@ -787,9 +788,12 @@ int GUIFileSelector::GetFileList(const std::string folder) continue; if (data.fileName == ".." && folder == "/") continue; - if (data.fileName == "..") + if (data.fileName == "..") { data.fileName = TW_FILESELECTOR_UP_A_LEVEL; - data.fileType = de->d_type; + data.fileType = DT_DIR; + } else { + data.fileType = de->d_type; + } std::string path = folder + "/" + data.fileName; stat(path.c_str(), &st); @@ -801,6 +805,9 @@ int GUIFileSelector::GetFileList(const std::string folder) data.lastModified = st.st_mtime; data.lastStatChange = st.st_ctime; + if (data.fileType == DT_UNKNOWN) { + data.fileType = TWFunc::Get_D_Type_From_Stat(path); + } if (data.fileType == DT_DIR) { if (mShowNavFolders || (data.fileName != "." && data.fileName != TW_FILESELECTOR_UP_A_LEVEL)) diff --git a/twrp-functions.cpp b/twrp-functions.cpp index edf4898b1..5473c8d66 100644 --- a/twrp-functions.cpp +++ b/twrp-functions.cpp @@ -453,3 +453,24 @@ int TWFunc::copy_file(string src, string dst, int mode) { dstfile.close(); return 0; } + +unsigned int TWFunc::Get_D_Type_From_Stat(string Path) { + struct stat st; + + stat(Path.c_str(), &st); + if (st.st_mode & S_IFDIR) + return DT_DIR; + else if (st.st_mode & S_IFBLK) + return DT_BLK; + else if (st.st_mode & S_IFCHR) + return DT_CHR; + else if (st.st_mode & S_IFIFO) + return DT_FIFO; + else if (st.st_mode & S_IFLNK) + return DT_LNK; + else if (st.st_mode & S_IFREG) + return DT_REG; + else if (st.st_mode & S_IFSOCK) + return DT_SOCK; + return DT_UNKNOWN; +}
\ No newline at end of file diff --git a/twrp-functions.hpp b/twrp-functions.hpp index 7cef37f31..8cd344557 100644 --- a/twrp-functions.hpp +++ b/twrp-functions.hpp @@ -39,6 +39,7 @@ public: static int Exec_Cmd(string cmd, string &result); //execute a command and return the result as a string by reference static int removeDir(const string path, bool removeParent); //recursively remove a directory static int copy_file(string src, string dst, int mode); //copy file from src to dst with mode permissions + static unsigned int Get_D_Type_From_Stat(string Path); // Returns a dirent dt_type value using stat instead of dirent private: static void check_and_fclose(FILE *fp, const char *name); |