/**************************************************************************/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);5253public:54typedef void (*RemoveNotificationFunc)(const String &p_file);55static RemoveNotificationFunc remove_notification_func;5657virtual Error list_dir_begin() override; ///< This starts dir listing58virtual String get_next() override;59virtual bool current_is_dir() const override;60virtual bool current_is_hidden() const override;6162virtual void list_dir_end() override; ///<6364virtual int get_drive_count() override;65virtual String get_drive(int p_drive) override;66virtual int get_current_drive() override;67virtual bool drives_are_shortcuts() override;6869virtual Error change_dir(String p_dir) override; ///< can be relative or absolute, return false on success70virtual String get_current_dir(bool p_include_drive = true) const override; ///< return current dir location71virtual Error make_dir(String p_dir) override;7273virtual bool file_exists(String p_file) override;74virtual bool dir_exists(String p_dir) override;75virtual bool is_readable(String p_dir) override;76virtual bool is_writable(String p_dir) override;7778virtual uint64_t get_modified_time(String p_file);7980virtual Error rename(String p_path, String p_new_path) override;81virtual Error remove(String p_path) override;8283virtual bool is_link(String p_file) override;84virtual String read_link(String p_file) override;85virtual Error create_link(String p_source, String p_target) override;8687virtual bool is_case_sensitive(const String &p_path) const override;88virtual bool is_equivalent(const String &p_path_a, const String &p_path_b) const override;8990virtual uint64_t get_space_left() override;9192virtual String get_filesystem_type() const override;9394DirAccessUnix();95~DirAccessUnix();96};9798#endif // UNIX_ENABLED99100101