Debian Codegraph @

core/io/remote_filesystem_client.h

raw symbols SCIP
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 #pragma once
32
33 #include "core/string/ustring.h"
34 #include "core/templates/hash_set.h"
35 #include "core/templates/local_vector.h"
36
37 class RemoteFilesystemClient {
38 String cache_path;
39 HashSet<String> validated_directories;
40
41 protected:
42 String _get_cache_path() { return cache_path; }
43 struct FileCache {
44 String path; // Local path (as in "folder/to/file.png")
45 uint64_t server_modified_time = 0; // MD5 checksum.
46 uint64_t modified_time = 0;
47 };
48 virtual bool _is_configured() { return !cache_path.is_empty(); }
49 // Can be re-implemented per platform. If so, feel free to ignore get_cache_path()
50 virtual Vector<FileCache> _load_cache_file();
51 virtual Error _store_file(const String &p_path, const LocalVector<uint8_t> &p_file, uint64_t &modified_time);
52 virtual Error _remove_file(const String &p_path);
53 virtual Error _store_cache_file(const Vector<FileCache> &p_cache);
54 virtual Error _synchronize_with_server(const String &p_host, int p_port, const String &p_password, String &r_cache_path);
55
56 virtual void _update_cache_path(String &r_cache_path);
57
58 public:
59 Error synchronize_with_server(const String &p_host, int p_port, const String &p_password, String &r_cache_path);
60 virtual ~RemoteFilesystemClient() {}
61 };