[−][src]Struct gdnative_bindings::directory::Directory
core class Directory
inherits Reference
(reference counted).
Official documentation
See the documentation of this class in the Godot engine's official documentation.
Memory management
The lifetime of this object is automatically managed through reference counting.
Class hierarchy
Directory inherits methods from:
Safety
All types in the Godot API have "interior mutability" in Rust parlance.
To enforce that the official thread-safety guidelines are
followed, the typestate pattern is used in the Ref
and TRef
smart pointers,
and the Instance
API. The typestate Access
in these types tracks whether the
access is unique, shared, or exclusive to the current thread. For more information,
see the type-level documentation on Ref
.
Implementations
impl Directory
[src]
pub fn new() -> Ref<Self, Unique>
[src]
Creates a new instance of this object.
This is a reference-counted type. The returned object is automatically managed
by Ref
.
pub fn change_dir(&self, todir: impl Into<GodotString>) -> GodotResult
[src]
Changes the currently opened directory to the one passed as an argument. The argument can be relative to the current directory (e.g. [code]newdir[/code] or [code]../newdir[/code]), or an absolute path (e.g. [code]/tmp/newdir[/code] or [code]res://somedir/newdir[/code]).
Returns one of the [enum Error] code constants ([code]OK[/code] on success).
pub fn copy(
&self,
from: impl Into<GodotString>,
to: impl Into<GodotString>
) -> GodotResult
[src]
&self,
from: impl Into<GodotString>,
to: impl Into<GodotString>
) -> GodotResult
Copies the [code]from[/code] file to the [code]to[/code] destination. Both arguments should be paths to files, either relative or absolute. If the destination file exists and is not access-protected, it will be overwritten.
Returns one of the [enum Error] code constants ([code]OK[/code] on success).
pub fn current_is_dir(&self) -> bool
[src]
Returns whether the current item processed with the last [method get_next] call is a directory ([code].[/code] and [code]..[/code] are considered directories).
pub fn dir_exists(&self, path: impl Into<GodotString>) -> bool
[src]
Returns whether the target directory exists. The argument can be relative to the current directory, or an absolute path.
pub fn file_exists(&self, path: impl Into<GodotString>) -> bool
[src]
Returns whether the target file exists. The argument can be relative to the current directory, or an absolute path.
pub fn get_current_dir(&self) -> GodotString
[src]
Returns the absolute path to the currently opened directory (e.g. [code]res://folder[/code] or [code]C:\tmp\folder[/code]).
pub fn get_current_drive(&self) -> i64
[src]
Returns the currently opened directory's drive index. See [method get_drive] to convert returned index to the name of the drive.
pub fn get_drive(&self, idx: i64) -> GodotString
[src]
On Windows, returns the name of the drive (partition) passed as an argument (e.g. [code]C:[/code]). On other platforms, or if the requested drive does not existed, the method returns an empty String.
pub fn get_drive_count(&self) -> i64
[src]
On Windows, returns the number of drives (partitions) mounted on the current filesystem. On other platforms, the method returns 0.
pub fn get_next(&self) -> GodotString
[src]
Returns the next element (file or directory) in the current directory (including [code].[/code] and [code]..[/code], unless [code]skip_navigational[/code] was given to [method list_dir_begin]).
The name of the file or directory is returned (and not its full path). Once the stream has been fully processed, the method returns an empty String and closes the stream automatically (i.e. [method list_dir_end] would not be mandatory in such a case).
pub fn get_space_left(&self) -> i64
[src]
On UNIX desktop systems, returns the available space on the current directory's disk. On other platforms, this information is not available and the method returns 0 or -1.
pub fn list_dir_begin(
&self,
skip_navigational: bool,
skip_hidden: bool
) -> GodotResult
[src]
&self,
skip_navigational: bool,
skip_hidden: bool
) -> GodotResult
Initializes the stream used to list all files and directories using the [method get_next] function, closing the current opened stream if needed. Once the stream has been processed, it should typically be closed with [method list_dir_end].
If [code]skip_navigational[/code] is [code]true[/code], [code].[/code] and [code]..[/code] are filtered out.
If [code]skip_hidden[/code] is [code]true[/code], hidden files are filtered out.
Default Arguments
skip_navigational
-false
skip_hidden
-false
pub fn list_dir_end(&self)
[src]
Closes the current stream opened with [method list_dir_begin] (whether it has been fully processed with [method get_next] or not does not matter).
pub fn make_dir(&self, path: impl Into<GodotString>) -> GodotResult
[src]
Creates a directory. The argument can be relative to the current directory, or an absolute path. The target directory should be placed in an already existing directory (to create the full path recursively, see [method make_dir_recursive]).
Returns one of the [enum Error] code constants ([code]OK[/code] on success).
pub fn make_dir_recursive(&self, path: impl Into<GodotString>) -> GodotResult
[src]
Creates a target directory and all necessary intermediate directories in its path, by calling [method make_dir] recursively. The argument can be relative to the current directory, or an absolute path.
Returns one of the [enum Error] code constants ([code]OK[/code] on success).
pub fn open(&self, path: impl Into<GodotString>) -> GodotResult
[src]
Opens an existing directory of the filesystem. The [code]path[/code] argument can be within the project tree ([code]res://folder[/code]), the user directory ([code]user://folder[/code]) or an absolute path of the user filesystem (e.g. [code]/tmp/folder[/code] or [code]C:\tmp\folder[/code]).
Returns one of the [enum Error] code constants ([code]OK[/code] on success).
pub fn remove(&self, path: impl Into<GodotString>) -> GodotResult
[src]
Deletes the target file or an empty directory. The argument can be relative to the current directory, or an absolute path. If the target directory is not empty, the operation will fail.
Returns one of the [enum Error] code constants ([code]OK[/code] on success).
pub fn rename(
&self,
from: impl Into<GodotString>,
to: impl Into<GodotString>
) -> GodotResult
[src]
&self,
from: impl Into<GodotString>,
to: impl Into<GodotString>
) -> GodotResult
Renames (move) the [code]from[/code] file to the [code]to[/code] destination. Both arguments should be paths to files, either relative or absolute. If the destination file exists and is not access-protected, it will be overwritten.
Returns one of the [enum Error] code constants ([code]OK[/code] on success).
Methods from Deref<Target = Reference>
pub fn init_ref(&self) -> bool
[src]
Initializes the internal reference counter. Use this only if you really know what you are doing.
Returns whether the initialization was successful.
Trait Implementations
impl Debug for Directory
[src]
impl Deref for Directory
[src]
impl DerefMut for Directory
[src]
impl GodotObject for Directory
[src]
type RefKind = RefCounted
The memory management kind of this type. This modifies the behavior of the
Ref
smart pointer. See its type-level documentation for more
information. Read more
fn class_name() -> &'static str
[src]
fn null() -> Null<Self>
[src]
fn new() -> Ref<Self, Unique> where
Self: Instanciable,
[src]
Self: Instanciable,
fn cast<T>(&self) -> Option<&T> where
T: GodotObject + SubClass<Self>,
[src]
T: GodotObject + SubClass<Self>,
fn upcast<T>(&self) -> &T where
Self: SubClass<T>,
T: GodotObject,
[src]
Self: SubClass<T>,
T: GodotObject,
unsafe fn assume_shared(&self) -> Ref<Self, Shared>
[src]
unsafe fn assume_thread_local(&self) -> Ref<Self, ThreadLocal> where
Self: GodotObject<RefKind = RefCounted>,
[src]
Self: GodotObject<RefKind = RefCounted>,
unsafe fn assume_unique(&self) -> Ref<Self, Unique>
[src]
impl Instanciable for Directory
[src]
impl Sealed for Directory
[src]
impl SubClass<Object> for Directory
[src]
impl SubClass<Reference> for Directory
[src]
Auto Trait Implementations
impl RefUnwindSafe for Directory
impl !Send for Directory
impl !Sync for Directory
impl Unpin for Directory
impl UnwindSafe for Directory
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SubClass<T> for T where
T: GodotObject,
[src]
T: GodotObject,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,