File

Struct File 

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

A file is defined as a set of information that has been created on, or has existed on a filesystem.

File objects can be associated with host events, network events, and/or file events (e.g., those produced by File Integrity Monitoring [FIM] products or services). File fields provide details about the affected file associated with the event or metric.

Implementations§

Source§

impl File

Source

pub fn get_name(&self) -> Option<&String>

Name of the file including the extension, without the directory.

Source

pub fn set_name(&mut self, name_arg: String)

Name of the file including the extension, without the directory.

§Example

example.png

Source

pub fn get_attributes(&self) -> &Vec<String>

Array of file attributes.

Attributes names will vary by platform. Here’s a non-exhaustive list of values that are expected in this field: archive, compressed, directory, encrypted, execute, hidden, read, readonly, system, write.

Source

pub fn add_attribute(&mut self, attribute_arg: String)

Array of file attributes.

Attributes names will vary by platform. Here’s a non-exhaustive list of values that are expected in this field: archive, compressed, directory, encrypted, execute, hidden, read, readonly, system, write.

§Example

["readonly", "system"]

Source

pub fn get_directory(&self) -> Option<&String>

Directory where the file is located. It should include the drive letter, when appropriate.

Source

pub fn set_directory(&mut self, directory_arg: String)

Directory where the file is located. It should include the drive letter, when appropriate.

§Example

/home/alice

Source

pub fn get_drive_letter(&self) -> Option<&String>

Drive letter where the file is located. This field is only relevant on Windows.

The value should be uppercase, and not include the colon.

Source

pub fn set_drive_letter(&mut self, drive_letter_arg: String)

Drive letter where the file is located. This field is only relevant on Windows.

The value should be uppercase, and not include the colon.

§Example

C

Source

pub fn get_path(&self) -> Option<&String>

Full path to the file, including the file name. It should include the drive letter, when appropriate.

Source

pub fn set_path(&mut self, path_arg: String)

Full path to the file, including the file name. It should include the drive letter, when appropriate.

§Example

/home/alice/example.png

Source

pub fn get_target_path(&self) -> Option<&String>

Target path for symlinks.

Source

pub fn set_target_path(&mut self, target_path_arg: String)

Target path for symlinks.

Source

pub fn get_extension(&self) -> Option<&String>

File extension, excluding the leading dot.

Note that when the file name has multiple extensions (example.tar.gz), only the last one should be captured (“gz”, not “tar.gz”).

Source

pub fn set_extension(&mut self, extension_arg: String)

File extension, excluding the leading dot.

Note that when the file name has multiple extensions (example.tar.gz), only the last one should be captured (“gz”, not “tar.gz”).

§Example

png

Source

pub fn get_type(&self) -> Option<&String>

File type (file, dir, or symlink).

Source

pub fn set_type(&mut self, type_arg: String)

File type (file, dir, or symlink).

§Example

file

Source

pub fn get_device(&self) -> Option<&String>

Device that is the source of the file.

Source

pub fn set_device(&mut self, device_arg: String)

Device that is the source of the file.

§Example

sda

Source

pub fn get_inode(&self) -> Option<&String>

Inode representing the file in the filesystem.

Source

pub fn set_inode(&mut self, inode_arg: String)

Inode representing the file in the filesystem.

§Example

256383

Source

pub fn get_uid(&self) -> Option<&String>

The user ID (UID) or security identifier (SID) of the file owner.

Source

pub fn set_uid(&mut self, uid_arg: String)

The user ID (UID) or security identifier (SID) of the file owner.

§Example

1001

Source

pub fn get_owner(&self) -> Option<&String>

File owner’s username.

Source

pub fn set_owner(&mut self, owner_arg: String)

File owner’s username.

§Example

alice

Source

pub fn get_gid(&self) -> Option<&String>

Primary group ID (GID) of the file.

Source

pub fn set_gid(&mut self, gid_arg: String)

Primary group ID (GID) of the file.

§Example

1001

Source

pub fn get_group(&self) -> Option<&String>

Primary group name of the file.

Source

pub fn set_group(&mut self, group_arg: String)

Primary group name of the file.

§Example

alice

Source

pub fn get_mode(&self) -> Option<&String>

Mode of the file in octal representation.

Source

pub fn set_mode(&mut self, mode_arg: String)

Mode of the file in octal representation.

§Example

0640

Source

pub fn get_size(&self) -> Option<&u64>

File size in bytes.

Only relevant when file.type is “file”.

Source

pub fn set_size(&mut self, size_arg: u64)

File size in bytes.

Only relevant when file.type is “file”.

§Example

16384

Source

pub fn get_mtime(&self) -> Option<&Timestamp>

Last time the file content was modified.

Source

pub fn set_mtime(&mut self, mtime_arg: Timestamp)

Last time the file content was modified.

Source

pub fn get_ctime(&self) -> Option<&Timestamp>

Last time the file attributes or metadata changed.

Note that changes to the file content will update mtime. This implies ctime will be adjusted at the same time, since mtime is an attribute of the file.

Source

pub fn set_ctime(&mut self, ctime_arg: Timestamp)

Last time the file attributes or metadata changed.

Note that changes to the file content will update mtime. This implies ctime will be adjusted at the same time, since mtime is an attribute of the file.

Source

pub fn get_created(&self) -> Option<&Timestamp>

File creation time.

Note that not all filesystems store the creation time.

Source

pub fn set_created(&mut self, created_arg: Timestamp)

File creation time.

Note that not all filesystems store the creation time.

Source

pub fn get_accessed(&self) -> Option<&Timestamp>

Last time the file was accessed.

Note that not all filesystems keep track of access time.

Source

pub fn set_accessed(&mut self, accessed_arg: Timestamp)

Last time the file was accessed.

Note that not all filesystems keep track of access time.

Source

pub fn get_mime_type(&self) -> Option<&String>

MIME type should identify the format of the file or stream of bytes using IANA official types, where possible. When more than one type is applicable, the most specific type should be used.

Source

pub fn set_mime_type(&mut self, mime_type_arg: String)

MIME type should identify the format of the file or stream of bytes using IANA official types, where possible. When more than one type is applicable, the most specific type should be used.

Source

pub fn get_fork_name(&self) -> Option<&String>

A fork is additional data associated with a filesystem object.

On Linux, a resource fork is used to store additional data with a filesystem object. A file always has at least one fork for the data portion, and additional forks may exist.

On NTFS, this is analogous to an Alternate Data Stream (ADS), and the default data stream for a file is just called $DATA. Zone.Identifier is commonly used by Windows to track contents downloaded from the Internet. An ADS is typically of the form: C:\path\to\filename.extension:some_fork_name, and some_fork_name is the value that should populate fork_name. filename.extension should populate file.name, and extension should populate file.extension. The full path, file.path, will include the fork name.

Source

pub fn set_fork_name(&mut self, fork_name_arg: String)

A fork is additional data associated with a filesystem object.

On Linux, a resource fork is used to store additional data with a filesystem object. A file always has at least one fork for the data portion, and additional forks may exist.

On NTFS, this is analogous to an Alternate Data Stream (ADS), and the default data stream for a file is just called $DATA. Zone.Identifier is commonly used by Windows to track contents downloaded from the Internet. An ADS is typically of the form: C:\path\to\filename.extension:some_fork_name, and some_fork_name is the value that should populate fork_name. filename.extension should populate file.name, and extension should populate file.extension. The full path, file.path, will include the fork name.

§Example

Zone.Identifer

Trait Implementations§

Source§

impl Clone for File

Source§

fn clone(&self) -> File

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for File

Source§

fn default() -> File

Returns the “default value” for a type. Read more
Source§

impl Serialize for File

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for File

§

impl RefUnwindSafe for File

§

impl Send for File

§

impl Sync for File

§

impl Unpin for File

§

impl UnwindSafe for File

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.