|
@@ -33,6 +33,7 @@
|
|
#if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED)
|
|
#if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED)
|
|
|
|
|
|
#include "core/os/memory.h"
|
|
#include "core/os/memory.h"
|
|
|
|
+#include "core/os/os.h"
|
|
#include "core/string/print_string.h"
|
|
#include "core/string/print_string.h"
|
|
#include "core/templates/list.h"
|
|
#include "core/templates/list.h"
|
|
|
|
|
|
@@ -212,10 +213,11 @@ static bool _filter_drive(struct mntent *mnt) {
|
|
#endif
|
|
#endif
|
|
|
|
|
|
static void _get_drives(List<String> *list) {
|
|
static void _get_drives(List<String> *list) {
|
|
|
|
+ // Add root.
|
|
list->push_back("/");
|
|
list->push_back("/");
|
|
|
|
|
|
#if defined(HAVE_MNTENT) && defined(X11_ENABLED)
|
|
#if defined(HAVE_MNTENT) && defined(X11_ENABLED)
|
|
- // Check /etc/mtab for the list of mounted partitions
|
|
|
|
|
|
+ // Check /etc/mtab for the list of mounted partitions.
|
|
FILE *mtab = setmntent("/etc/mtab", "r");
|
|
FILE *mtab = setmntent("/etc/mtab", "r");
|
|
if (mtab) {
|
|
if (mtab) {
|
|
struct mntent mnt;
|
|
struct mntent mnt;
|
|
@@ -235,7 +237,7 @@ static void _get_drives(List<String> *list) {
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
- // Add $HOME
|
|
|
|
|
|
+ // Add $HOME.
|
|
const char *home = getenv("HOME");
|
|
const char *home = getenv("HOME");
|
|
if (home) {
|
|
if (home) {
|
|
// Only add if it's not a duplicate
|
|
// Only add if it's not a duplicate
|
|
@@ -244,7 +246,8 @@ static void _get_drives(List<String> *list) {
|
|
list->push_back(home_name);
|
|
list->push_back(home_name);
|
|
}
|
|
}
|
|
|
|
|
|
- // Check $HOME/.config/gtk-3.0/bookmarks
|
|
|
|
|
|
+ // Check GTK+3 bookmarks for both XDG locations (Documents, Downloads, etc.)
|
|
|
|
+ // and potential user-defined bookmarks.
|
|
char path[1024];
|
|
char path[1024];
|
|
snprintf(path, 1024, "%s/.config/gtk-3.0/bookmarks", home);
|
|
snprintf(path, 1024, "%s/.config/gtk-3.0/bookmarks", home);
|
|
FILE *fd = fopen(path, "r");
|
|
FILE *fd = fopen(path, "r");
|
|
@@ -253,7 +256,7 @@ static void _get_drives(List<String> *list) {
|
|
while (fgets(string, 1024, fd)) {
|
|
while (fgets(string, 1024, fd)) {
|
|
// Parse only file:// links
|
|
// Parse only file:// links
|
|
if (strncmp(string, "file://", 7) == 0) {
|
|
if (strncmp(string, "file://", 7) == 0) {
|
|
- // Strip any unwanted edges on the strings and push_back if it's not a duplicate
|
|
|
|
|
|
+ // Strip any unwanted edges on the strings and push_back if it's not a duplicate.
|
|
String fpath = String::utf8(string + 7).strip_edges().split_spaces()[0].uri_decode();
|
|
String fpath = String::utf8(string + 7).strip_edges().split_spaces()[0].uri_decode();
|
|
if (!list->find(fpath)) {
|
|
if (!list->find(fpath)) {
|
|
list->push_back(fpath);
|
|
list->push_back(fpath);
|
|
@@ -263,6 +266,12 @@ static void _get_drives(List<String> *list) {
|
|
|
|
|
|
fclose(fd);
|
|
fclose(fd);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // Add Desktop dir.
|
|
|
|
+ String dpath = OS::get_singleton()->get_system_dir(OS::SystemDir::SYSTEM_DIR_DESKTOP);
|
|
|
|
+ if (dpath.length() > 0 && !list->find(dpath)) {
|
|
|
|
+ list->push_back(dpath);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
list->sort();
|
|
list->sort();
|