Files
ppsspp/Common/File/PathBrowser.h

78 lines
1.6 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();
2013-11-18 14:02:56 +01:00
void SetPath(const Path &path);
void Refresh() {
HandlePath();
}
2024-09-17 15:13:13 +02:00
bool IsListingReady() const {
return ready_;
}
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 Path &rootPath) {
aliasDisplay_ = alias;
aliasMatch_ = rootPath;
}
void RestrictToRoot(const Path &root);
bool empty() const {
return path_.empty();
}
2024-05-10 10:39:58 +02:00
bool Success() const {
return success_;
}
private:
void HandlePath();
void ResetPending();
void ApplyRestriction();
Path path_;
Path pendingPath_;
Path restrictedRoot_;
std::string userAgent_;
std::string aliasDisplay_;
Path 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;
2024-05-10 10:39:58 +02:00
bool success_ = true;
2013-11-18 14:02:56 +01:00
};