file:read_file_info/1
获取一个文件信息
用法:
read_file_info(Filename) -> {ok, FileInfo} | {error, Reason}
获取文件 Filename 的文件信息 FileInfo,例如文件的大小,创建时间,最后修改时间。FileInfo 其实是一个 file_info 的 record 记录,记录字段信息如下:
-record(file_info,
{size :: non_neg_integer(), % Size of file in bytes.
type :: 'device' | 'directory' | 'other' | 'regular' | 'symlink',
Access :: 'read' | 'write' | 'read_write' | 'none',
atime :: file:date_time() | non_neg_integer(),
% The local time the file was last read:
% {{Year, Mon, Day}, {Hour, Min, Sec}}.
% atime, ctime, mtime may also be unix epochs()
mtime :: file:date_time() | non_neg_integer(),
% The local time the file was last written.
ctime :: file:date_time() | non_neg_integer(),
% The interpretation of this time field
% is dependent on operating system.
% On Unix it is the last time the file
% or the inode was changed. On Windows,
% it is the creation time.
mode :: non_neg_integer(), % File permissions. On Windows,
% the owner permissions will be
% duplicated for group and user.
links :: non_neg_integer(),
% Number of links to the file (1 if the
% filesystem doesn't support links).
major_device :: non_neg_integer(),
% Identifies the file system (Unix),
% or the drive number (A: = 0, B: = 1)
% (Windows).
%% The following are Unix specific.
%% They are set to zero on other operating systems.
minor_device :: non_neg_integer(), % Only valid for devices.
inode :: non_neg_integer(), % Inode number for file.
uid :: non_neg_integer(), % User id for owner.
gid :: non_neg_integer()}). % Group id for owner.
file:read_file_info("./rebar.config").