/**************************************************************************/1/* dir_access_unix.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#if defined(UNIX_ENABLED)3334#include "core/io/dir_access.h"3536#include <dirent.h>37#include <sys/stat.h>38#include <sys/types.h>39#include <unistd.h>4041class DirAccessUnix : public DirAccess {42GDSOFTCLASS(DirAccessUnix, DirAccess);43DIR *dir_stream = nullptr;4445bool _cisdir = false;46bool _cishidden = false;4748protected:49String current_dir;50virtual String fix_unicode_name(const char *p_name) const { return String::utf8(p_name); }51virtual bool is_hidden(const String &p_name);52virtual String fix_path(const String &p_path) const override;5354public:55typedef void (*RemoveNotificationFunc)(const String &p_file);56static RemoveNotificationFunc remove_notification_func;5758virtual Error list_dir_begin() override; ///< This starts dir listing59virtual String get_next() override;60virtual bool current_is_dir() const override;61virtual bool current_is_hidden() const override;6263virtual void list_dir_end() override; ///<6465virtual int get_drive_count() override;66virtual String get_drive(int p_drive) override;67virtual int get_current_drive() override;68virtual bool drives_are_shortcuts() override;6970virtual Error change_dir(String p_dir) override; ///< can be relative or absolute, return false on success71virtual String get_current_dir(bool p_include_drive = true) const override; ///< return current dir location72virtual Error make_dir(String p_dir) override;7374virtual bool file_exists(String p_file) override;75virtual bool dir_exists(String p_dir) override;76virtual bool is_readable(String p_dir) override;77virtual bool is_writable(String p_dir) override;7879virtual uint64_t get_modified_time(String p_file);8081virtual Error rename(String p_path, String p_new_path) override;82virtual Error remove(String p_path) override;8384virtual bool is_link(String p_file) override;85virtual String read_link(String p_file) override;86virtual Error create_link(String p_source, String p_target) override;8788virtual bool is_case_sensitive(const String &p_path) const override;89virtual bool is_equivalent(const String &p_path_a, const String &p_path_b) const override;9091virtual uint64_t get_space_left() override;9293virtual String get_filesystem_type() const override;9495DirAccessUnix();96~DirAccessUnix();97};9899#endif // UNIX_ENABLED100101102