Erlang中文手册(Erldoc.com)  »  file  »  read_file_info/1
Erlang并发编程 Erlang/OTP设计原理 Erlang/OTP[pdf] Mnesia用户手册[pdf] Erlang完整手册[en] 官网手册[en] 模块列表 方法列表 随机 Erlang中文社区(BBS) 美女图库

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").
阿里云 - 最高1000元通用代金券立即可用
沪ICP备13037221号-9