forked from hrydgard/ppsspp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStorageFolderBrowser.h
70 lines (51 loc) · 1.36 KB
/
StorageFolderBrowser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once
#pragma once
#include "pch.h"
#include <thread>
#include <mutex>
#include <condition_variable>
#include <queue>
#include <string>
#include "Common/CommonTypes.h"
#include "Core/Loaders.h"
// This thing is a terrible abomination that wraps asynchronous file access behind a synchronous interface,
// completely defeating MS' design goals for StorageFile. But hey, you gotta do what you gotta do.
// This opens a stream attached to the passed-in file. Multiple of these can be created against one StorageFile.
class StorageFolderBrowser {
public:
StorageFolderBrowser(Windows::Storage::StorageFolder ^folder);
~StorageFolderBrowser();
std::string Path() const {
return path_;
}
std::string DisplayName() const {
return displayName_;
}
private:
void threadfunc();
enum class OpType {
NONE,
LIST_DIRECTORY,
CHANGE_FOLDER,
};
struct Operation {
OpType type;
};
struct Response {
};
std::string path_;
std::string displayName_;
bool active_ = false;
std::unique_ptr<std::thread> thread_;
Windows::Storage::StorageFolder ^folder_;
bool operationRequested_ = false;
Operation operation_{ OpType::NONE };
std::condition_variable cond_;
std::mutex mutex_;
bool operationFailed_ = false;
bool responseAvailable_ = false;
Response response_;
std::condition_variable condResponse_;
std::mutex mutexResponse_;
int64_t seekPos_ = 0;
};