remote_filesystem_client.h 3.5 KB

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