Files
ppsspp/Common/File/PathBrowser.h

69 lines
1.5 KiB
C
Raw Permalink Normal View History

2013-11-18 14:02:56 +01:00
#pragma once
#include <condition_variable>
#include <mutex>
2013-11-18 14:02:56 +01:00
#include <string>
#include <cstring>
#include <thread>
2013-11-18 14:02:56 +01:00
#include <vector>
#include <cstdlib>
2013-11-18 14:02:56 +01:00
#include "Common/File/DirListing.h"
#include "Common/File/Path.h"
2013-11-18 14:02:56 +01: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(const Path &path) { SetPath(path); }
~PathBrowser();
2013-11-18 14:02:56 +01:00
void SetPath(const Path &path);
bool IsListingReady();
bool GetListing(std::vector<File::FileInfo> &fileInfo, const char *filter = nullptr, bool *cancel = nullptr);
bool CanNavigateUp();
void NavigateUp();
2021-07-18 22:28:59 +02:00
void Navigate(const std::string &subdir);
2013-11-18 14:02:56 +01:00
2021-07-18 22:28:59 +02:00
const Path &GetPath() const {
return path_;
2013-11-18 14:02:56 +01:00
}
std::string GetFriendlyPath() const;
2013-11-18 14:02:56 +01:00
void SetUserAgent(const std::string &s) {
userAgent_ = s;
}
void SetRootAlias(const std::string &alias, const std::string &longValue) {
aliasDisplay_ = alias;
aliasMatch_ = longValue;
}
bool empty() const {
return path_.empty();
}
private:
void HandlePath();
void ResetPending();
Path path_;
Path pendingPath_;
std::string userAgent_;
std::string aliasDisplay_;
std::string aliasMatch_;
std::vector<File::FileInfo> pendingFiles_;
std::condition_variable pendingCond_;
std::mutex pendingLock_;
std::thread pendingThread_;
bool pendingActive_ = false;
bool pendingCancel_ = false;
bool pendingStop_ = false;
bool ready_ = false;
2013-11-18 14:02:56 +01:00
};