forked from sascha/godot
Merge pull request #76540 from reduz/redo-remote-filesystem
Redo how the remote filesystem works4.1
commit
491a437df5
@ -1,498 +0,0 @@
|
||||
/**************************************************************************/
|
||||
/* file_access_network.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "file_access_network.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/io/ip.h"
|
||||
#include "core/io/marshalls.h"
|
||||
#include "core/os/os.h"
|
||||
|
||||
//#define DEBUG_PRINT(m_p) print_line(m_p)
|
||||
//#define DEBUG_TIME(m_what) printf("MS: %s - %lli\n",m_what,OS::get_singleton()->get_ticks_usec());
|
||||
#define DEBUG_PRINT(m_p)
|
||||
#define DEBUG_TIME(m_what)
|
||||
|
||||
void FileAccessNetworkClient::lock_mutex() {
|
||||
mutex.lock();
|
||||
lockcount++;
|
||||
}
|
||||
|
||||
void FileAccessNetworkClient::unlock_mutex() {
|
||||
lockcount--;
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
void FileAccessNetworkClient::put_32(int p_32) {
|
||||
uint8_t buf[4];
|
||||
encode_uint32(p_32, buf);
|
||||
client->put_data(buf, 4);
|
||||
DEBUG_PRINT("put32: " + itos(p_32));
|
||||
}
|
||||
|
||||
void FileAccessNetworkClient::put_64(int64_t p_64) {
|
||||
uint8_t buf[8];
|
||||
encode_uint64(p_64, buf);
|
||||
client->put_data(buf, 8);
|
||||
DEBUG_PRINT("put64: " + itos(p_64));
|
||||
}
|
||||
|
||||
int FileAccessNetworkClient::get_32() {
|
||||
uint8_t buf[4];
|
||||
client->get_data(buf, 4);
|
||||
return decode_uint32(buf);
|
||||
}
|
||||
|
||||
int64_t FileAccessNetworkClient::get_64() {
|
||||
uint8_t buf[8];
|
||||
client->get_data(buf, 8);
|
||||
return decode_uint64(buf);
|
||||
}
|
||||
|
||||
void FileAccessNetworkClient::_thread_func() {
|
||||
client->set_no_delay(true);
|
||||
while (!quit) {
|
||||
DEBUG_PRINT("SEM WAIT - " + itos(sem->get()));
|
||||
sem.wait();
|
||||
DEBUG_TIME("sem_unlock");
|
||||
//DEBUG_PRINT("semwait returned "+itos(werr));
|
||||
DEBUG_PRINT("MUTEX LOCK " + itos(lockcount));
|
||||
lock_mutex();
|
||||
DEBUG_PRINT("MUTEX PASS");
|
||||
|
||||
{
|
||||
MutexLock lock(blockrequest_mutex);
|
||||
while (block_requests.size()) {
|
||||
put_32(block_requests.front()->get().id);
|
||||
put_32(FileAccessNetwork::COMMAND_READ_BLOCK);
|
||||
put_64(block_requests.front()->get().offset);
|
||||
put_32(block_requests.front()->get().size);
|
||||
block_requests.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_PRINT("THREAD ITER");
|
||||
|
||||
DEBUG_TIME("sem_read");
|
||||
int id = get_32();
|
||||
|
||||
int response = get_32();
|
||||
DEBUG_PRINT("GET RESPONSE: " + itos(response));
|
||||
|
||||
FileAccessNetwork *fa = nullptr;
|
||||
|
||||
if (response != FileAccessNetwork::RESPONSE_DATA) {
|
||||
if (!accesses.has(id)) {
|
||||
unlock_mutex();
|
||||
ERR_FAIL_COND(!accesses.has(id));
|
||||
}
|
||||
}
|
||||
|
||||
if (accesses.has(id)) {
|
||||
fa = accesses[id];
|
||||
}
|
||||
|
||||
switch (response) {
|
||||
case FileAccessNetwork::RESPONSE_OPEN: {
|
||||
DEBUG_TIME("sem_open");
|
||||
int status = get_32();
|
||||
if (status != OK) {
|
||||
fa->_respond(0, Error(status));
|
||||
} else {
|
||||
int64_t len = get_64();
|
||||
fa->_respond(len, Error(status));
|
||||
}
|
||||
|
||||
fa->sem.post();
|
||||
|
||||
} break;
|
||||
case FileAccessNetwork::RESPONSE_DATA: {
|
||||
int64_t offset = get_64();
|
||||
int32_t len = get_32();
|
||||
|
||||
Vector<uint8_t> resp_block;
|
||||
resp_block.resize(len);
|
||||
client->get_data(resp_block.ptrw(), len);
|
||||
|
||||
if (fa) { //may have been queued
|
||||
fa->_set_block(offset, resp_block);
|
||||
}
|
||||
|
||||
} break;
|
||||
case FileAccessNetwork::RESPONSE_FILE_EXISTS: {
|
||||
int status = get_32();
|
||||
fa->exists_modtime = status != 0;
|
||||
fa->sem.post();
|
||||
|
||||
} break;
|
||||
case FileAccessNetwork::RESPONSE_GET_MODTIME: {
|
||||
uint64_t status = get_64();
|
||||
fa->exists_modtime = status;
|
||||
fa->sem.post();
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
unlock_mutex();
|
||||
}
|
||||
}
|
||||
|
||||
void FileAccessNetworkClient::_thread_func(void *s) {
|
||||
FileAccessNetworkClient *self = static_cast<FileAccessNetworkClient *>(s);
|
||||
|
||||
self->_thread_func();
|
||||
}
|
||||
|
||||
Error FileAccessNetworkClient::connect(const String &p_host, int p_port, const String &p_password) {
|
||||
IPAddress ip;
|
||||
|
||||
if (p_host.is_valid_ip_address()) {
|
||||
ip = p_host;
|
||||
} else {
|
||||
ip = IP::get_singleton()->resolve_hostname(p_host);
|
||||
}
|
||||
|
||||
DEBUG_PRINT("IP: " + String(ip) + " port " + itos(p_port));
|
||||
Error err = client->connect_to_host(ip, p_port);
|
||||
ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot connect to host with IP: " + String(ip) + " and port: " + itos(p_port));
|
||||
while (client->get_status() == StreamPeerTCP::STATUS_CONNECTING) {
|
||||
//DEBUG_PRINT("trying to connect....");
|
||||
OS::get_singleton()->delay_usec(1000);
|
||||
}
|
||||
|
||||
if (client->get_status() != StreamPeerTCP::STATUS_CONNECTED) {
|
||||
return ERR_CANT_CONNECT;
|
||||
}
|
||||
|
||||
CharString cs = p_password.utf8();
|
||||
put_32(cs.length());
|
||||
client->put_data((const uint8_t *)cs.ptr(), cs.length());
|
||||
|
||||
int e = get_32();
|
||||
|
||||
if (e != OK) {
|
||||
return ERR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
thread.start(_thread_func, this);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
FileAccessNetworkClient *FileAccessNetworkClient::singleton = nullptr;
|
||||
|
||||
FileAccessNetworkClient::FileAccessNetworkClient() {
|
||||
singleton = this;
|
||||
client.instantiate();
|
||||
}
|
||||
|
||||
FileAccessNetworkClient::~FileAccessNetworkClient() {
|
||||
quit = true;
|
||||
sem.post();
|
||||
thread.wait_to_finish();
|
||||
}
|
||||
|
||||
void FileAccessNetwork::_set_block(uint64_t p_offset, const Vector<uint8_t> &p_block) {
|
||||
int32_t page = p_offset / page_size;
|
||||
ERR_FAIL_INDEX(page, pages.size());
|
||||
if (page < pages.size() - 1) {
|
||||
ERR_FAIL_COND(p_block.size() != page_size);
|
||||
} else {
|
||||
ERR_FAIL_COND((uint64_t)p_block.size() != total_size % page_size);
|
||||
}
|
||||
|
||||
{
|
||||
MutexLock lock(buffer_mutex);
|
||||
pages.write[page].buffer = p_block;
|
||||
pages.write[page].queued = false;
|
||||
}
|
||||
|
||||
if (waiting_on_page == page) {
|
||||
waiting_on_page = -1;
|
||||
page_sem.post();
|
||||
}
|
||||
}
|
||||
|
||||
void FileAccessNetwork::_respond(uint64_t p_len, Error p_status) {
|
||||
DEBUG_PRINT("GOT RESPONSE - len: " + itos(p_len) + " status: " + itos(p_status));
|
||||
response = p_status;
|
||||
if (response != OK) {
|
||||
return;
|
||||
}
|
||||
opened = true;
|
||||
total_size = p_len;
|
||||
int32_t pc = ((total_size - 1) / page_size) + 1;
|
||||
pages.resize(pc);
|
||||
}
|
||||
|
||||
Error FileAccessNetwork::open_internal(const String &p_path, int p_mode_flags) {
|
||||
ERR_FAIL_COND_V(p_mode_flags != READ, ERR_UNAVAILABLE);
|
||||
_close();
|
||||
|
||||
FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
|
||||
DEBUG_PRINT("open: " + p_path);
|
||||
|
||||
DEBUG_TIME("open_begin");
|
||||
|
||||
nc->lock_mutex();
|
||||
nc->put_32(id);
|
||||
nc->accesses[id] = this;
|
||||
nc->put_32(COMMAND_OPEN_FILE);
|
||||
CharString cs = p_path.utf8();
|
||||
nc->put_32(cs.length());
|
||||
nc->client->put_data((const uint8_t *)cs.ptr(), cs.length());
|
||||
pos = 0;
|
||||
eof_flag = false;
|
||||
last_page = -1;
|
||||
last_page_buff = nullptr;
|
||||
|
||||
//buffers.clear();
|
||||
nc->unlock_mutex();
|
||||
DEBUG_PRINT("OPEN POST");
|
||||
DEBUG_TIME("open_post");
|
||||
nc->sem.post(); //awaiting answer
|
||||
DEBUG_PRINT("WAIT...");
|
||||
sem.wait();
|
||||
DEBUG_TIME("open_end");
|
||||
DEBUG_PRINT("WAIT ENDED...");
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
void FileAccessNetwork::_close() {
|
||||
if (!opened) {
|
||||
return;
|
||||
}
|
||||
|
||||
FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
|
||||
|
||||
DEBUG_PRINT("CLOSE");
|
||||
nc->lock_mutex();
|
||||
nc->put_32(id);
|
||||
nc->put_32(COMMAND_CLOSE);
|
||||
pages.clear();
|
||||
opened = false;
|
||||
nc->unlock_mutex();
|
||||
}
|
||||
|
||||
bool FileAccessNetwork::is_open() const {
|
||||
return opened;
|
||||
}
|
||||
|
||||
void FileAccessNetwork::seek(uint64_t p_position) {
|
||||
ERR_FAIL_COND_MSG(!opened, "File must be opened before use.");
|
||||
|
||||
eof_flag = p_position > total_size;
|
||||
|
||||
if (p_position >= total_size) {
|
||||
p_position = total_size;
|
||||
}
|
||||
|
||||
pos = p_position;
|
||||
}
|
||||
|
||||
void FileAccessNetwork::seek_end(int64_t p_position) {
|
||||
seek(total_size + p_position);
|
||||
}
|
||||
|
||||
uint64_t FileAccessNetwork::get_position() const {
|
||||
ERR_FAIL_COND_V_MSG(!opened, 0, "File must be opened before use.");
|
||||
return pos;
|
||||
}
|
||||
|
||||
uint64_t FileAccessNetwork::get_length() const {
|
||||
ERR_FAIL_COND_V_MSG(!opened, 0, "File must be opened before use.");
|
||||
return total_size;
|
||||
}
|
||||
|
||||
bool FileAccessNetwork::eof_reached() const {
|
||||
ERR_FAIL_COND_V_MSG(!opened, false, "File must be opened before use.");
|
||||
return eof_flag;
|
||||
}
|
||||
|
||||
uint8_t FileAccessNetwork::get_8() const {
|
||||
uint8_t v;
|
||||
get_buffer(&v, 1);
|
||||
return v;
|
||||
}
|
||||
|
||||
void FileAccessNetwork::_queue_page(int32_t p_page) const {
|
||||
if (p_page >= pages.size()) {
|
||||
return;
|
||||
}
|
||||
if (pages[p_page].buffer.is_empty() && !pages[p_page].queued) {
|
||||
FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
|
||||
{
|
||||
MutexLock lock(nc->blockrequest_mutex);
|
||||
|
||||
FileAccessNetworkClient::BlockRequest br;
|
||||
br.id = id;
|
||||
br.offset = (uint64_t)p_page * page_size;
|
||||
br.size = page_size;
|
||||
nc->block_requests.push_back(br);
|
||||
pages.write[p_page].queued = true;
|
||||
}
|
||||
DEBUG_PRINT("QUEUE PAGE POST");
|
||||
nc->sem.post();
|
||||
DEBUG_PRINT("queued " + itos(p_page));
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t FileAccessNetwork::get_buffer(uint8_t *p_dst, uint64_t p_length) const {
|
||||
ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
|
||||
|
||||
if (pos + p_length > total_size) {
|
||||
eof_flag = true;
|
||||
}
|
||||
if (pos + p_length >= total_size) {
|
||||
p_length = total_size - pos;
|
||||
}
|
||||
|
||||
uint8_t *buff = last_page_buff;
|
||||
|
||||
for (uint64_t i = 0; i < p_length; i++) {
|
||||
int32_t page = pos / page_size;
|
||||
|
||||
if (page != last_page) {
|
||||
buffer_mutex.lock();
|
||||
if (pages[page].buffer.is_empty()) {
|
||||
waiting_on_page = page;
|
||||
for (int32_t j = 0; j < read_ahead; j++) {
|
||||
_queue_page(page + j);
|
||||
}
|
||||
buffer_mutex.unlock();
|
||||
DEBUG_PRINT("wait");
|
||||
page_sem.wait();
|
||||
DEBUG_PRINT("done");
|
||||
} else {
|
||||
for (int32_t j = 0; j < read_ahead; j++) {
|
||||
_queue_page(page + j);
|
||||
}
|
||||
buffer_mutex.unlock();
|
||||
}
|
||||
|
||||
buff = pages.write[page].buffer.ptrw();
|
||||
last_page_buff = buff;
|
||||
last_page = page;
|
||||
}
|
||||
|
||||
p_dst[i] = buff[pos - uint64_t(page) * page_size];
|
||||
pos++;
|
||||
}
|
||||
|
||||
return p_length;
|
||||
}
|
||||
|
||||
Error FileAccessNetwork::get_error() const {
|
||||
return pos == total_size ? ERR_FILE_EOF : OK;
|
||||
}
|
||||
|
||||
void FileAccessNetwork::flush() {
|
||||
ERR_FAIL();
|
||||
}
|
||||
|
||||
void FileAccessNetwork::store_8(uint8_t p_dest) {
|
||||
ERR_FAIL();
|
||||
}
|
||||
|
||||
bool FileAccessNetwork::file_exists(const String &p_path) {
|
||||
FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
|
||||
nc->lock_mutex();
|
||||
nc->put_32(id);
|
||||
nc->put_32(COMMAND_FILE_EXISTS);
|
||||
CharString cs = p_path.utf8();
|
||||
nc->put_32(cs.length());
|
||||
nc->client->put_data((const uint8_t *)cs.ptr(), cs.length());
|
||||
nc->unlock_mutex();
|
||||
DEBUG_PRINT("FILE EXISTS POST");
|
||||
nc->sem.post();
|
||||
sem.wait();
|
||||
|
||||
return exists_modtime != 0;
|
||||
}
|
||||
|
||||
uint64_t FileAccessNetwork::_get_modified_time(const String &p_file) {
|
||||
FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
|
||||
nc->lock_mutex();
|
||||
nc->put_32(id);
|
||||
nc->put_32(COMMAND_GET_MODTIME);
|
||||
CharString cs = p_file.utf8();
|
||||
nc->put_32(cs.length());
|
||||
nc->client->put_data((const uint8_t *)cs.ptr(), cs.length());
|
||||
nc->unlock_mutex();
|
||||
DEBUG_PRINT("MODTIME POST");
|
||||
nc->sem.post();
|
||||
sem.wait();
|
||||
|
||||
return exists_modtime;
|
||||
}
|
||||
|
||||
uint32_t FileAccessNetwork::_get_unix_permissions(const String &p_file) {
|
||||
ERR_PRINT("Getting UNIX permissions from network drives is not implemented yet");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Error FileAccessNetwork::_set_unix_permissions(const String &p_file, uint32_t p_permissions) {
|
||||
ERR_PRINT("Setting UNIX permissions on network drives is not implemented yet");
|
||||
return ERR_UNAVAILABLE;
|
||||
}
|
||||
|
||||
void FileAccessNetwork::configure() {
|
||||
GLOBAL_DEF(PropertyInfo(Variant::INT, "network/remote_fs/page_size", PROPERTY_HINT_RANGE, "1,65536,1,or_greater"), 65536); // Is used as denominator and can't be zero
|
||||
GLOBAL_DEF(PropertyInfo(Variant::INT, "network/remote_fs/page_read_ahead", PROPERTY_HINT_RANGE, "0,8,1,or_greater"), 4);
|
||||
}
|
||||
|
||||
void FileAccessNetwork::close() {
|
||||
_close();
|
||||
|
||||
FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
|
||||
nc->lock_mutex();
|
||||
nc->accesses.erase(id);
|
||||
nc->unlock_mutex();
|
||||
}
|
||||
|
||||
FileAccessNetwork::FileAccessNetwork() {
|
||||
FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
|
||||
nc->lock_mutex();
|
||||
id = nc->last_id++;
|
||||
nc->accesses[id] = this;
|
||||
nc->unlock_mutex();
|
||||
page_size = GLOBAL_GET("network/remote_fs/page_size");
|
||||
read_ahead = GLOBAL_GET("network/remote_fs/page_read_ahead");
|
||||
}
|
||||
|
||||
FileAccessNetwork::~FileAccessNetwork() {
|
||||
_close();
|
||||
|
||||
FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
|
||||
nc->lock_mutex();
|
||||
nc->accesses.erase(id);
|
||||
nc->unlock_mutex();
|
||||
}
|
||||
@ -1,167 +0,0 @@
|
||||
/**************************************************************************/
|
||||
/* file_access_network.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef FILE_ACCESS_NETWORK_H
|
||||
#define FILE_ACCESS_NETWORK_H
|
||||
|
||||
#include "core/io/file_access.h"
|
||||
#include "core/io/stream_peer_tcp.h"
|
||||
#include "core/os/semaphore.h"
|
||||
#include "core/os/thread.h"
|
||||
|
||||
class FileAccessNetwork;
|
||||
|
||||
class FileAccessNetworkClient {
|
||||
struct BlockRequest {
|
||||
int32_t id;
|
||||
uint64_t offset;
|
||||
int32_t size;
|
||||
};
|
||||
|
||||
List<BlockRequest> block_requests;
|
||||
|
||||
Semaphore sem;
|
||||
Thread thread;
|
||||
bool quit = false;
|
||||
Mutex mutex;
|
||||
Mutex blockrequest_mutex;
|
||||
HashMap<int, FileAccessNetwork *> accesses;
|
||||
Ref<StreamPeerTCP> client;
|
||||
int32_t last_id = 0;
|
||||
int32_t lockcount = 0;
|
||||
|
||||
Vector<uint8_t> block;
|
||||
|
||||
void _thread_func();
|
||||
static void _thread_func(void *s);
|
||||
|
||||
void put_32(int32_t p_32);
|
||||
void put_64(int64_t p_64);
|
||||
int32_t get_32();
|
||||
int64_t get_64();
|
||||
void lock_mutex();
|
||||
void unlock_mutex();
|
||||
|
||||
friend class FileAccessNetwork;
|
||||
static FileAccessNetworkClient *singleton;
|
||||
|
||||
public:
|
||||
static FileAccessNetworkClient *get_singleton() { return singleton; }
|
||||
|
||||
Error connect(const String &p_host, int p_port, const String &p_password = "");
|
||||
|
||||
FileAccessNetworkClient();
|
||||
~FileAccessNetworkClient();
|
||||
};
|
||||
|
||||
class FileAccessNetwork : public FileAccess {
|
||||
Semaphore sem;
|
||||
Semaphore page_sem;
|
||||
Mutex buffer_mutex;
|
||||
bool opened = false;
|
||||
uint64_t total_size = 0;
|
||||
mutable uint64_t pos = 0;
|
||||
int32_t id = -1;
|
||||
mutable bool eof_flag = false;
|
||||
mutable int32_t last_page = -1;
|
||||
mutable uint8_t *last_page_buff = nullptr;
|
||||
|
||||
int32_t page_size = 0;
|
||||
int32_t read_ahead = 0;
|
||||
|
||||
mutable int waiting_on_page = -1;
|
||||
|
||||
struct Page {
|
||||
int activity = 0;
|
||||
bool queued = false;
|
||||
Vector<uint8_t> buffer;
|
||||
};
|
||||
|
||||
mutable Vector<Page> pages;
|
||||
|
||||
mutable Error response;
|
||||
|
||||
uint64_t exists_modtime = 0;
|
||||
|
||||
friend class FileAccessNetworkClient;
|
||||
void _queue_page(int32_t p_page) const;
|
||||
void _respond(uint64_t p_len, Error p_status);
|
||||
void _set_block(uint64_t p_offset, const Vector<uint8_t> &p_block);
|
||||
void _close();
|
||||
|
||||
public:
|
||||
enum Command {
|
||||
COMMAND_OPEN_FILE,
|
||||
COMMAND_READ_BLOCK,
|
||||
COMMAND_CLOSE,
|
||||
COMMAND_FILE_EXISTS,
|
||||
COMMAND_GET_MODTIME,
|
||||
};
|
||||
|
||||
enum Response {
|
||||
RESPONSE_OPEN,
|
||||
RESPONSE_DATA,
|
||||
RESPONSE_FILE_EXISTS,
|
||||
RESPONSE_GET_MODTIME,
|
||||
};
|
||||
|
||||
virtual Error open_internal(const String &p_path, int p_mode_flags) override; ///< open a file
|
||||
virtual bool is_open() const override; ///< true when file is open
|
||||
|
||||
virtual void seek(uint64_t p_position) override; ///< seek to a given position
|
||||
virtual void seek_end(int64_t p_position = 0) override; ///< seek from the end of file
|
||||
virtual uint64_t get_position() const override; ///< get position in the file
|
||||
virtual uint64_t get_length() const override; ///< get size of the file
|
||||
|
||||
virtual bool eof_reached() const override; ///< reading passed EOF
|
||||
|
||||
virtual uint8_t get_8() const override; ///< get a byte
|
||||
virtual uint64_t get_buffer(uint8_t *p_dst, uint64_t p_length) const override;
|
||||
|
||||
virtual Error get_error() const override; ///< get last error
|
||||
|
||||
virtual void flush() override;
|
||||
virtual void store_8(uint8_t p_dest) override; ///< store a byte
|
||||
|
||||
virtual bool file_exists(const String &p_path) override; ///< return true if a file exists
|
||||
|
||||
virtual uint64_t _get_modified_time(const String &p_file) override;
|
||||
virtual uint32_t _get_unix_permissions(const String &p_file) override;
|
||||
virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) override;
|
||||
|
||||
virtual void close() override;
|
||||
|
||||
static void configure();
|
||||
|
||||
FileAccessNetwork();
|
||||
~FileAccessNetwork();
|
||||
};
|
||||
|
||||
#endif // FILE_ACCESS_NETWORK_H
|
||||
@ -0,0 +1,329 @@
|
||||
/**************************************************************************/
|
||||
/* remote_filesystem_client.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "remote_filesystem_client.h"
|
||||
|
||||
#include "core/io/dir_access.h"
|
||||
#include "core/io/file_access.h"
|
||||
#include "core/io/stream_peer_tcp.h"
|
||||
#include "core/string/string_builder.h"
|
||||
|
||||
#define FILESYSTEM_CACHE_VERSION 1
|
||||
#define FILESYSTEM_PROTOCOL_VERSION 1
|
||||
#define PASSWORD_LENGTH 32
|
||||
|
||||
#define FILES_SUBFOLDER "remote_filesystem_files"
|
||||
#define FILES_CACHE_FILE "remote_filesystem.cache"
|
||||
|
||||
Vector<RemoteFilesystemClient::FileCache> RemoteFilesystemClient::_load_cache_file() {
|
||||
Ref<FileAccess> fa = FileAccess::open(cache_path.path_join(FILES_CACHE_FILE), FileAccess::READ);
|
||||
if (!fa.is_valid()) {
|
||||
return Vector<FileCache>(); // No cache, return empty
|
||||
}
|
||||
|
||||
int version = fa->get_line().to_int();
|
||||
if (version != FILESYSTEM_CACHE_VERSION) {
|
||||
return Vector<FileCache>(); // Version mismatch, ignore everything.
|
||||
}
|
||||
|
||||
String file_path = cache_path.path_join(FILES_SUBFOLDER);
|
||||
|
||||
Vector<FileCache> file_cache;
|
||||
|
||||
while (!fa->eof_reached()) {
|
||||
String l = fa->get_line();
|
||||
Vector<String> fields = l.split("::");
|
||||
if (fields.size() != 3) {
|
||||
break;
|
||||
}
|
||||
FileCache fc;
|
||||
fc.path = fields[0];
|
||||
fc.server_modified_time = fields[1].to_int();
|
||||
fc.modified_time = fields[2].to_int();
|
||||
|
||||
String full_path = file_path.path_join(fc.path);
|
||||
if (!FileAccess::exists(full_path)) {
|
||||
continue; // File is gone.
|
||||
}
|
||||
|
||||
if (FileAccess::get_modified_time(full_path) != fc.modified_time) {
|
||||
DirAccess::remove_absolute(full_path); // Take the chance to remove this file and assume we no longer have it.
|
||||
continue;
|
||||
}
|
||||
|
||||
file_cache.push_back(fc);
|
||||
}
|
||||
|
||||
return file_cache;
|
||||
}
|
||||
|
||||
Error RemoteFilesystemClient::_store_file(const String &p_path, const LocalVector<uint8_t> &p_file, uint64_t &modified_time) {
|
||||
modified_time = 0;
|
||||
String full_path = cache_path.path_join(FILES_SUBFOLDER).path_join(p_path);
|
||||
String base_file_dir = full_path.get_base_dir();
|
||||
|
||||
if (!validated_directories.has(base_file_dir)) {
|
||||
// Verify that path exists before writing file, but only verify once for performance.
|
||||
DirAccess::make_dir_recursive_absolute(base_file_dir);
|
||||
validated_directories.insert(base_file_dir);
|
||||
}
|
||||
|
||||
Ref<FileAccess> f = FileAccess::open(full_path, FileAccess::WRITE);
|
||||
ERR_FAIL_COND_V_MSG(f.is_null(), ERR_FILE_CANT_OPEN, "Unable to open file for writing to remote filesystem cache: " + p_path);
|
||||
f->store_buffer(p_file.ptr(), p_file.size());
|
||||
Error err = f->get_error();
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
f.unref(); // Unref to ensure file is not locked and modified time can be obtained.
|
||||
|
||||
modified_time = FileAccess::get_modified_time(full_path);
|
||||
return OK;
|
||||
}
|
||||
|
||||
Error RemoteFilesystemClient::_remove_file(const String &p_path) {
|
||||
return DirAccess::remove_absolute(cache_path.path_join(FILES_SUBFOLDER).path_join(p_path));
|
||||
}
|
||||
Error RemoteFilesystemClient::_store_cache_file(const Vector<FileCache> &p_cache) {
|
||||
String full_path = cache_path.path_join(FILES_CACHE_FILE);
|
||||
String base_file_dir = full_path.get_base_dir();
|
||||
Error err = DirAccess::make_dir_recursive_absolute(base_file_dir);
|
||||
ERR_FAIL_COND_V_MSG(err != OK && err != ERR_ALREADY_EXISTS, err, "Unable to create base directory to store cache file: " + base_file_dir);
|
||||
|
||||
Ref<FileAccess> f = FileAccess::open(full_path, FileAccess::WRITE);
|
||||
ERR_FAIL_COND_V_MSG(f.is_null(), ERR_FILE_CANT_OPEN, "Unable to open the remote cache file for writing: " + full_path);
|
||||
f->store_line(itos(FILESYSTEM_CACHE_VERSION));
|
||||
for (int i = 0; i < p_cache.size(); i++) {
|
||||
String l = p_cache[i].path + "::" + itos(p_cache[i].server_modified_time) + "::" + itos(p_cache[i].modified_time);
|
||||
f->store_line(l);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
Error RemoteFilesystemClient::synchronize_with_server(const String &p_host, int p_port, const String &p_password, String &r_cache_path) {
|
||||
Error err = _synchronize_with_server(p_host, p_port, p_password, r_cache_path);
|
||||
// Ensure no memory is kept
|
||||
validated_directories.reset();
|
||||
cache_path = String();
|
||||
return err;
|
||||
}
|
||||
|
||||
void RemoteFilesystemClient::_update_cache_path(String &r_cache_path) {
|
||||
r_cache_path = cache_path.path_join(FILES_SUBFOLDER);
|
||||
}
|
||||
|
||||
Error RemoteFilesystemClient::_synchronize_with_server(const String &p_host, int p_port, const String &p_password, String &r_cache_path) {
|
||||
cache_path = r_cache_path;
|
||||
{
|
||||
Ref<DirAccess> dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||
dir->change_dir(cache_path);
|
||||
cache_path = dir->get_current_dir();
|
||||
}
|
||||
|
||||
Ref<StreamPeerTCP> tcp_client;
|
||||
tcp_client.instantiate();
|
||||
|
||||
IPAddress ip = p_host.is_valid_ip_address() ? IPAddress(p_host) : IP::get_singleton()->resolve_hostname(p_host);
|
||||
ERR_FAIL_COND_V_MSG(!ip.is_valid(), ERR_INVALID_PARAMETER, "Unable to resolve remote filesystem server hostname: " + p_host);
|
||||
print_verbose(vformat("Remote Filesystem: Connecting to host %s, port %d.", ip, p_port));
|
||||
Error err = tcp_client->connect_to_host(ip, p_port);
|
||||
ERR_FAIL_COND_V_MSG(err != OK, err, "Unable to open connection to remote file server (" + String(p_host) + ", port " + itos(p_port) + ") failed.");
|
||||
|
||||
while (tcp_client->get_status() == StreamPeerTCP::STATUS_CONNECTING) {
|
||||
tcp_client->poll();
|
||||
OS::get_singleton()->delay_usec(100);
|
||||
}
|
||||
|
||||
if (tcp_client->get_status() != StreamPeerTCP::STATUS_CONNECTED) {
|
||||
ERR_FAIL_V_MSG(ERR_CANT_CONNECT, "Connection to remote file server (" + String(p_host) + ", port " + itos(p_port) + ") failed.");
|
||||
}
|
||||
|
||||
// Connection OK, now send the current file state.
|
||||
print_verbose("Remote Filesystem: Connection OK.");
|
||||
|
||||
// Header (GRFS) - Godot Remote File System
|
||||
print_verbose("Remote Filesystem: Sending header");
|
||||
tcp_client->put_u8('G');
|
||||
tcp_client->put_u8('R');
|
||||
tcp_client->put_u8('F');
|
||||
tcp_client->put_u8('S');
|
||||
// Protocol version
|
||||
tcp_client->put_32(FILESYSTEM_PROTOCOL_VERSION);
|
||||
print_verbose("Remote Filesystem: Sending password");
|
||||
uint8_t password[PASSWORD_LENGTH]; // Send fixed size password, since it's easier and safe to validate.
|
||||
for (int i = 0; i < PASSWORD_LENGTH; i++) {
|
||||
if (i < p_password.length()) {
|
||||
password[i] = p_password[i];
|
||||
} else {
|
||||
password[i] = 0;
|
||||
}
|
||||
}
|
||||
tcp_client->put_data(password, PASSWORD_LENGTH);
|
||||
print_verbose("Remote Filesystem: Tags.");
|
||||
Vector<String> tags;
|
||||
{
|
||||
tags.push_back(OS::get_singleton()->get_identifier());
|
||||
switch (OS::get_singleton()->get_preferred_texture_format()) {
|
||||
case OS::PREFERRED_TEXTURE_FORMAT_S3TC_BPTC: {
|
||||
tags.push_back("bptc");
|
||||
tags.push_back("s3tc");
|
||||
} break;
|
||||
case OS::PREFERRED_TEXTURE_FORMAT_ETC2_ASTC: {
|
||||
tags.push_back("etc2");
|
||||
tags.push_back("astc");
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
tcp_client->put_32(tags.size());
|
||||
for (int i = 0; i < tags.size(); i++) {
|
||||
tcp_client->put_utf8_string(tags[i]);
|
||||
}
|
||||
// Size of compressed list of files
|
||||
print_verbose("Remote Filesystem: Sending file list");
|
||||
|
||||
Vector<FileCache> file_cache = _load_cache_file();
|
||||
|
||||
// Encode file cache to send it via network.
|
||||
Vector<uint8_t> file_cache_buffer;
|
||||
if (file_cache.size()) {
|
||||
StringBuilder sbuild;
|
||||
for (int i = 0; i < file_cache.size(); i++) {
|
||||
sbuild.append(file_cache[i].path);
|
||||
sbuild.append("::");
|
||||
sbuild.append(itos(file_cache[i].server_modified_time));
|
||||
sbuild.append("\n");
|
||||
}
|
||||
String s = sbuild.as_string();
|
||||
CharString cs = s.utf8();
|
||||
file_cache_buffer.resize(Compression::get_max_compressed_buffer_size(cs.length(), Compression::MODE_ZSTD));
|
||||
int res_len = Compression::compress(file_cache_buffer.ptrw(), (const uint8_t *)cs.ptr(), cs.length(), Compression::MODE_ZSTD);
|
||||
file_cache_buffer.resize(res_len);
|
||||
|
||||
tcp_client->put_32(cs.length()); // Size of buffer uncompressed
|
||||
tcp_client->put_32(file_cache_buffer.size()); // Size of buffer compressed
|
||||
tcp_client->put_data(file_cache_buffer.ptr(), file_cache_buffer.size()); // Buffer
|
||||
} else {
|
||||
tcp_client->put_32(0); // No file cache buffer
|
||||
}
|
||||
|
||||
tcp_client->poll();
|
||||
ERR_FAIL_COND_V_MSG(tcp_client->get_status() != StreamPeerTCP::STATUS_CONNECTED, ERR_CONNECTION_ERROR, "Remote filesystem server disconnected after sending header.");
|
||||
|
||||
uint32_t file_count = tcp_client->get_32();
|
||||
|
||||
ERR_FAIL_COND_V_MSG(tcp_client->get_status() != StreamPeerTCP::STATUS_CONNECTED, ERR_CONNECTION_ERROR, "Remote filesystem server disconnected while waiting for file list");
|
||||
|
||||
LocalVector<uint8_t> file_buffer;
|
||||
|
||||
Vector<FileCache> temp_file_cache;
|
||||
|
||||
HashSet<String> files_processed;
|
||||
for (uint32_t i = 0; i < file_count; i++) {
|
||||
String file = tcp_client->get_utf8_string();
|
||||
ERR_FAIL_COND_V_MSG(file == String(), ERR_CONNECTION_ERROR, "Invalid file name received from remote filesystem.");
|
||||
uint64_t server_modified_time = tcp_client->get_u64();
|
||||
ERR_FAIL_COND_V_MSG(tcp_client->get_status() != StreamPeerTCP::STATUS_CONNECTED, ERR_CONNECTION_ERROR, "Remote filesystem server disconnected while waiting for file info.");
|
||||
|
||||
FileCache fc;
|
||||
fc.path = file;
|
||||
fc.server_modified_time = server_modified_time;
|
||||
temp_file_cache.push_back(fc);
|
||||
|
||||
files_processed.insert(file);
|
||||
}
|
||||
|
||||
Vector<FileCache> new_file_cache;
|
||||
|
||||
// Get the actual files. As a robustness measure, if the connection is interrupted here, any file not yet received will be considered removed.
|
||||
// Since the file changed anyway, this makes it the easiest way to keep robustness.
|
||||
|
||||
bool server_disconnected = false;
|
||||
for (uint32_t i = 0; i < file_count; i++) {
|
||||
String file = temp_file_cache[i].path;
|
||||
|
||||
if (temp_file_cache[i].server_modified_time == 0 || server_disconnected) {
|
||||
// File was removed, or server disconnected before tranferring it. Since it's no longer valid, remove anyway.
|
||||
_remove_file(file);
|
||||
continue;
|
||||
}
|
||||
|
||||
uint64_t file_size = tcp_client->get_u64();
|
||||
file_buffer.resize(file_size);
|
||||
|
||||
err = tcp_client->get_data(file_buffer.ptr(), file_size);
|
||||
if (err != OK) {
|
||||
ERR_PRINT("Error retrieving file from remote filesystem: " + file);
|
||||
server_disconnected = true;
|
||||
}
|
||||
|
||||
if (tcp_client->get_status() != StreamPeerTCP::STATUS_CONNECTED) {
|
||||
// Early disconnect, stop accepting files.
|
||||
server_disconnected = true;
|
||||
}
|
||||
|
||||
if (server_disconnected) {
|
||||
// No more server, transfer is invalid, remove this file.
|
||||
_remove_file(file);
|
||||
continue;
|
||||
}
|
||||
|
||||
uint64_t modified_time = 0;
|
||||
err = _store_file(file, file_buffer, modified_time);
|
||||
if (err != OK) {
|
||||
server_disconnected = true;
|
||||
continue;
|
||||
}
|
||||
FileCache fc = temp_file_cache[i];
|
||||
fc.modified_time = modified_time;
|
||||
new_file_cache.push_back(fc);
|
||||
}
|
||||
|
||||
print_verbose("Remote Filesystem: Updating the cache file.");
|
||||
|
||||
// Go through the list of local files read initially (file_cache) and see which ones are
|
||||
// unchanged (not sent again from the server).
|
||||
// These need to be re-saved in the new list (new_file_cache).
|
||||
|
||||
for (int i = 0; i < file_cache.size(); i++) {
|
||||
if (files_processed.has(file_cache[i].path)) {
|
||||
continue; // This was either added or removed, so skip.
|
||||
}
|
||||
new_file_cache.push_back(file_cache[i]);
|
||||
}
|
||||
|
||||
err = _store_cache_file(new_file_cache);
|
||||
ERR_FAIL_COND_V_MSG(err != OK, ERR_FILE_CANT_OPEN, "Error writing the remote filesystem file cache.");
|
||||
|
||||
print_verbose("Remote Filesystem: Update success.");
|
||||
|
||||
_update_cache_path(r_cache_path);
|
||||
return OK;
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
/**************************************************************************/
|
||||
/* remote_filesystem_client.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef REMOTE_FILESYSTEM_CLIENT_H
|
||||
#define REMOTE_FILESYSTEM_CLIENT_H
|
||||
|
||||
#include "core/io/ip_address.h"
|
||||
#include "core/string/ustring.h"
|
||||
#include "core/templates/hash_set.h"
|
||||
#include "core/templates/local_vector.h"
|
||||
|
||||
class RemoteFilesystemClient {
|
||||
String cache_path;
|
||||
HashSet<String> validated_directories;
|
||||
|
||||
protected:
|
||||
String _get_cache_path() { return cache_path; }
|
||||
struct FileCache {
|
||||
String path; // Local path (as in "folder/to/file.png")
|
||||
uint64_t server_modified_time; // MD5 checksum.
|
||||
uint64_t modified_time;
|
||||
};
|
||||
virtual bool _is_configured() { return !cache_path.is_empty(); }
|
||||
// Can be re-implemented per platform. If so, feel free to ignore get_cache_path()
|
||||
virtual Vector<FileCache> _load_cache_file();
|
||||
virtual Error _store_file(const String &p_path, const LocalVector<uint8_t> &p_file, uint64_t &modified_time);
|
||||
virtual Error _remove_file(const String &p_path);
|
||||
virtual Error _store_cache_file(const Vector<FileCache> &p_cache);
|
||||
virtual Error _synchronize_with_server(const String &p_host, int p_port, const String &p_password, String &r_cache_path);
|
||||
|
||||
virtual void _update_cache_path(String &r_cache_path);
|
||||
|
||||
public:
|
||||
Error synchronize_with_server(const String &p_host, int p_port, const String &p_password, String &r_cache_path);
|
||||
virtual ~RemoteFilesystemClient() {}
|
||||
};
|
||||
|
||||
#endif // REMOTE_FILESYSTEM_CLIENT_H
|
||||
Loading…
Reference in New Issue