ppsspp/Common/File/PathBrowser.h

54 lines
1.2 KiB
C
Raw Normal View History

2013-11-18 13:02:56 +00:00
#pragma once
#include <condition_variable>
#include <mutex>
2013-11-18 13:02:56 +00:00
#include <string>
#include <cstring>
#include <thread>
2013-11-18 13:02:56 +00:00
#include <vector>
#include <cstdlib>
2013-11-18 13:02:56 +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); }
~PathBrowser();
2013-11-18 13:02:56 +00:00
void SetPath(const std::string &path);
bool IsListingReady();
bool GetListing(std::vector<File::FileInfo> &fileInfo, const char *filter = nullptr, bool *cancel = nullptr);
bool CanNavigateUp();
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 "";
}
std::string GetFriendlyPath() const;
2013-11-18 13:02:56 +00:00
private:
void HandlePath();
void ResetPending();
2013-11-18 13:02:56 +00:00
std::string path_;
std::string pendingPath_;
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 13:02:56 +00:00
};