pub struct File { /* private fields */ }
Expand description

Represents a path to a file or directory.

Constructing a File object

File can be constructed either with a path or a URL. The following URL schemes are supported:

  • file:
  • app: file in the application installation directory
  • app-storage: file in the application private directory

The File constructor performs implicit normalization of the given path argument.

Implementations

Constructs a new File object.

The last portion of this path.

The last portion of this path, excluding the given suffix.

The filename extension. This includes the dot.

Returns a reference to the application installation directory. This is equivalent to the URL app://.

Returns a reference to the application private directory. This is equivalent to the URL app-storage://.

The URL for this file path.

The full path in the host operating system representation.

Resolves relative path.

Relative path from the File object to another File object.

The user downloads directory.

The user documents directory.

The executable directory.

The user pictures directory.

The user videos directory.

The application’s working directory (used primarily for command-line applications).

Native path of the File object. If the File object was constructed from app: or app-storage: scheme, then its path is resolved to the internal application directory.

Determines whether the referenced path exists.s

Determines whether the referenced path is a directory.

Determines whether the referenced path is a file.

Determines whether the referenced path is a symbolic link.

The directory that contains the file or directory referenced by the File object.

This property is identical to the return value of resolve_path("..") except that the parent of a root directory is None.

The host operating system’s path component separator character.

Returns a canonicalization of the File path.

Returns a canonicalization of the File path.

Copies the file at the location specified by the File object to the location specified by the new_location parameter.

This method will overwrite the contents of new_location.

Copies the file at the location specified by the File object to the location specified by the new_location parameter.

This method will overwrite the contents of new_location.

Creates the specified directory and any necessary parent directories. If the directory already exists, no action is taken.

Creates the specified directory and any necessary parent directories. If the directory already exists, no action is taken.

Read file contents as bytes.

Read file contents as bytes.

Read file contents as UTF-8 string.

Read file contents as UTF-8 string.

Returns a vector of File objects corresponding to files and directories in the directory represented by the File object.

Deletes empty directory.

Deletes empty directory.

Deletes directory after deleting all its contents.

Deletes directory after deleting all its contents.

Deletes file.

Deletes file.

Rename a file or directory to a new name specified by the to parameter, replacing the original file if to already exists.

Rename a file or directory to a new name specified by the to parameter, replacing the original file if to already exists.

Writes bytes to a file.

Writes bytes to a file.

Creation date.

Creation date.

Modification date.

Modification date.

Size of the file in bytes.

Size of the file in bytes.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.