mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Now shows the filename, and also there's a delay mode where they'll only be visible if the download takes more than a second, plus they can be named.
39 lines
715 B
C++
39 lines
715 B
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <functional>
|
|
|
|
#include "Common/Buffer.h"
|
|
|
|
namespace net {
|
|
|
|
class RequestProgress {
|
|
public:
|
|
RequestProgress() {}
|
|
explicit RequestProgress(bool *c) : cancelled(c) {}
|
|
|
|
void Update(float newProgress) {
|
|
progress = newProgress;
|
|
if (callback) {
|
|
callback(newProgress);
|
|
}
|
|
}
|
|
|
|
float progress = 0.0f;
|
|
float kBps = 0.0f;
|
|
bool *cancelled = nullptr;
|
|
std::function<void(float)> callback;
|
|
};
|
|
|
|
class Buffer : public ::Buffer {
|
|
public:
|
|
bool FlushSocket(uintptr_t sock, double timeout, bool *cancelled = nullptr);
|
|
|
|
bool ReadAllWithProgress(int fd, int knownSize, RequestProgress *progress);
|
|
|
|
// < 0: error
|
|
// >= 0: number of bytes read
|
|
int Read(int fd, size_t sz);
|
|
};
|
|
|
|
}
|