file:write_file_info/2
修改一个文件的信息
用法:
write_file_info(Filename, FileInfo) -> ok | {error, Reason}
修改文件信息。如果成功修改,则返回 ok,否则返回 {error, Reason}。FileInfo 是一个 file_info 记录,定义在内核的头文件 file.hrl 里。调用该函数需要在模块里引入以下指令:
-include_lib("kernel/include/file.hrl").
{ok, FInfo} = file:read_file_info("test.txt"), file:write_file_info("test.log", FInfo#file_info{mode = 0}).