| 1 | /**************************************************************************/ |
| 2 | /* remote_filesystem_client.h */ |
| 3 | /**************************************************************************/ |
| 4 | /* This file is part of: */ |
| 5 | /* GODOT ENGINE */ |
| 6 | /* https://godotengine.org */ |
| 7 | /**************************************************************************/ |
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 10 | /* */ |
| 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
| 12 | /* a copy of this software and associated documentation files (the */ |
| 13 | /* "Software"), to deal in the Software without restriction, including */ |
| 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
| 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
| 16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
| 17 | /* the following conditions: */ |
| 18 | /* */ |
| 19 | /* The above copyright notice and this permission notice shall be */ |
| 20 | /* included in all copies or substantial portions of the Software. */ |
| 21 | /* */ |
| 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
| 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
| 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
| 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
| 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
| 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
| 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 29 | /**************************************************************************/ |
| 30 | |
| 31 | #ifndef REMOTE_FILESYSTEM_CLIENT_H |
| 32 | #define REMOTE_FILESYSTEM_CLIENT_H |
| 33 | |
| 34 | #include "core/io/ip_address.h" |
| 35 | #include "core/string/ustring.h" |
| 36 | #include "core/templates/hash_set.h" |
| 37 | #include "core/templates/local_vector.h" |
| 38 | |
| 39 | class RemoteFilesystemClient { |
| 40 | String cache_path; |
| 41 | HashSet<String> validated_directories; |
| 42 | |
| 43 | protected: |
| 44 | String _get_cache_path() { return cache_path; } |
| 45 | struct FileCache { |
| 46 | String path; // Local path (as in "folder/to/file.png") |
| 47 | uint64_t server_modified_time = 0; // MD5 checksum. |
| 48 | uint64_t modified_time = 0; |
| 49 | }; |
| 50 | virtual bool _is_configured() { return !cache_path.is_empty(); } |
| 51 | // Can be re-implemented per platform. If so, feel free to ignore get_cache_path() |
| 52 | virtual Vector<FileCache> _load_cache_file(); |
| 53 | virtual Error _store_file(const String &p_path, const LocalVector<uint8_t> &p_file, uint64_t &modified_time); |
| 54 | virtual Error _remove_file(const String &p_path); |
| 55 | virtual Error _store_cache_file(const Vector<FileCache> &p_cache); |
| 56 | virtual Error _synchronize_with_server(const String &p_host, int p_port, const String &p_password, String &r_cache_path); |
| 57 | |
| 58 | virtual void _update_cache_path(String &r_cache_path); |
| 59 | |
| 60 | public: |
| 61 | Error synchronize_with_server(const String &p_host, int p_port, const String &p_password, String &r_cache_path); |
| 62 | virtual ~RemoteFilesystemClient() {} |
| 63 | }; |
| 64 | |
| 65 | #endif // REMOTE_FILESYSTEM_CLIENT_H |
| 66 | |