2013-11-18 13:02:56 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-10-06 18:49:35 +00:00
|
|
|
#include <condition_variable>
|
|
|
|
#include <mutex>
|
2013-11-18 13:02:56 +00:00
|
|
|
#include <string>
|
2020-10-03 22:25:21 +00:00
|
|
|
#include <cstring>
|
2019-10-06 18:49:35 +00:00
|
|
|
#include <thread>
|
2013-11-18 13:02:56 +00:00
|
|
|
#include <vector>
|
2020-10-04 18:48:47 +00:00
|
|
|
#include <cstdlib>
|
2013-11-18 13:02:56 +00:00
|
|
|
|
2020-10-04 18:48:47 +00:00
|
|
|
#include "Common/File/DirListing.h"
|
2013-11-18 13:02:56 +00:00
|
|
|
|
|
|
|
// Abstraction above path that lets you navigate easily.
|
|
|
|
// "/" is a special path that means the root of the file system. On Windows,
|
|
|
|
// listing this will yield drives.
|
|
|
|
class PathBrowser {
|
|
|
|
public:
|
|
|
|
PathBrowser() {}
|
|
|
|
PathBrowser(std::string path) { SetPath(path); }
|
2019-10-06 18:49:35 +00:00
|
|
|
~PathBrowser();
|
2013-11-18 13:02:56 +00:00
|
|
|
|
|
|
|
void SetPath(const std::string &path);
|
2019-10-06 18:49:35 +00:00
|
|
|
bool IsListingReady();
|
2021-04-25 18:38:22 +00:00
|
|
|
bool GetListing(std::vector<File::FileInfo> &fileInfo, const char *filter = nullptr, bool *cancel = nullptr);
|
2020-12-19 23:41:28 +00:00
|
|
|
|
2020-12-20 00:38:45 +00:00
|
|
|
bool CanNavigateUp();
|
2020-12-19 23:41:28 +00:00
|
|
|
void NavigateUp();
|
2013-11-18 13:02:56 +00:00
|
|
|
void Navigate(const std::string &path);
|
|
|
|
|
2013-12-08 21:38:31 +00:00
|
|
|
std::string GetPath() const {
|
2013-11-18 13:02:56 +00:00
|
|
|
if (path_ != "/")
|
|
|
|
return path_;
|
|
|
|
else
|
|
|
|
return "";
|
|
|
|
}
|
2020-12-20 00:00:07 +00:00
|
|
|
std::string GetFriendlyPath() const;
|
2013-11-18 13:02:56 +00:00
|
|
|
|
2019-10-06 18:49:35 +00:00
|
|
|
private:
|
|
|
|
void HandlePath();
|
2021-02-17 08:29:39 +00:00
|
|
|
void ResetPending();
|
2019-10-06 18:49:35 +00:00
|
|
|
|
2013-11-18 13:02:56 +00:00
|
|
|
std::string path_;
|
2019-10-06 18:49:35 +00:00
|
|
|
std::string pendingPath_;
|
2021-04-25 18:38:22 +00:00
|
|
|
std::vector<File::FileInfo> pendingFiles_;
|
2019-10-06 18:49:35 +00:00
|
|
|
std::condition_variable pendingCond_;
|
|
|
|
std::mutex pendingLock_;
|
|
|
|
std::thread pendingThread_;
|
2021-02-17 08:29:39 +00:00
|
|
|
bool pendingActive_ = false;
|
2019-10-06 18:49:35 +00:00
|
|
|
bool pendingCancel_ = false;
|
|
|
|
bool pendingStop_ = false;
|
|
|
|
bool ready_ = false;
|
2013-11-18 13:02:56 +00:00
|
|
|
};
|
|
|
|
|