NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
file_info类 参考

文件属性与时间管理类 更多...

#include <file_info.hpp>

Public 类型

using native_handle_type = _NEFORCE native_handle_type
 原生文件句柄类型
using size_type = size_t
 大小类型

Public 成员函数

 file_info (native_handle_type handle) noexcept
 构造函数
NEFORCE_NODISCARD file_attri attributes () const noexcept
 获取文件属性
bool set_attributes (file_attri attr) noexcept
 设置文件属性
NEFORCE_NODISCARD size_type size () const noexcept
 获取文件大小
NEFORCE_NODISCARD uint64_t size64 () const noexcept
 获取文件大小
bool size (size_type &out_size) const noexcept
 获取文件大小
NEFORCE_NODISCARD datetime last_access_time () const noexcept
 获取最后访问时间
bool set_last_access_time (const datetime &dt) noexcept
 设置最后访问时间
NEFORCE_NODISCARD datetime last_write_time () const noexcept
 获取最后修改时间
bool set_last_write_time (const datetime &dt) noexcept
 设置最后修改时间
bool set_all_times (const datetime &access, const datetime &write) noexcept
 同时设置访问和修改时间

详细描述

文件属性与时间管理类

查询和修改已打开文件的属性、权限及时间戳。

注解
不持有文件句柄所有权,句柄生命周期由调用方保证。

在文件 file_info.hpp30 行定义.

构造及析构函数说明

◆ file_info()

file_info::file_info ( native_handle_type handle)
explicitnoexcept

构造函数

参数
handle已打开的文件句柄

关联指定的文件句柄。

引用了 file_info() , 以及 handle().

被这些函数引用 file_info().

成员函数说明

◆ attributes()

NEFORCE_NODISCARD file_attri file_info::attributes ( ) const
noexcept

获取文件属性

返回
文件属性标志

返回文件的属性信息。 如果获取失败,返回file_attri::OTHERS。

◆ last_access_time()

NEFORCE_NODISCARD datetime file_info::last_access_time ( ) const
noexcept

获取最后访问时间

返回
最后访问时间

返回文件最后一次被读取或执行的时间。 如果获取失败,返回epoch时间。

引用了 last_access_time().

被这些函数引用 last_access_time().

◆ last_write_time()

NEFORCE_NODISCARD datetime file_info::last_write_time ( ) const
noexcept

获取最后修改时间

返回
最后修改时间

返回文件内容最后一次被修改的时间。 如果获取失败,返回epoch时间。

引用了 last_write_time().

被这些函数引用 last_write_time().

◆ set_all_times()

bool file_info::set_all_times ( const datetime & access,
const datetime & write )
noexcept

同时设置访问和修改时间

参数
access最后访问时间
write最后修改时间
返回
设置成功返回true,失败返回false

一次性设置文件的访问时间和修改时间。

被这些函数引用 set_last_write_time().

◆ set_attributes()

bool file_info::set_attributes ( file_attri attr)
noexcept

设置文件属性

参数
attr要设置的属性标志
返回
设置成功返回true,失败返回false
注解
可能需要权限。

引用了 set_attributes().

被这些函数引用 set_attributes().

◆ set_last_access_time()

bool file_info::set_last_access_time ( const datetime & dt)
noexcept

设置最后访问时间

参数
dt要设置的时间
返回
设置成功返回true,失败返回false

修改文件的最后访问时间。

注解
可能需要权限。

引用了 set_last_access_time().

被这些函数引用 set_last_access_time().

◆ set_last_write_time()

bool file_info::set_last_write_time ( const datetime & dt)
noexcept

设置最后修改时间

参数
dt要设置的时间
返回
设置成功返回true,失败返回false

修改文件的最后修改时间。

注解
可能需要权限。

引用了 set_all_times() , 以及 set_last_write_time().

被这些函数引用 set_last_write_time().

◆ size() [1/2]

NEFORCE_NODISCARD size_type file_info::size ( ) const
noexcept

获取文件大小

返回
文件大小(字节),如果文件超过4GB则返回0

获取文件大小,适用于小于4GB的文件。 对于大文件,建议使用size64()方法。

引用了 size().

被这些函数引用 size() , 以及 size().

◆ size() [2/2]

bool file_info::size ( size_type & out_size) const
noexcept

获取文件大小

参数
out_size输出文件大小
返回
成功返回true,失败返回false

获取文件大小并返回操作状态,可检测文件是否超过32位范围。 对于超过32位范围的文件,返回false。

引用了 size().

◆ size64()

NEFORCE_NODISCARD uint64_t file_info::size64 ( ) const
noexcept

获取文件大小

返回
文件大小(字节),支持超过4GB的大文件

获取文件大小的64位版本,支持大文件处理。

引用了 size64().

被这些函数引用 size64().


该类的文档由以下文件生成: