目录

sysopen

描述 (Description)

此函数等效于底层C和操作系统调用open()。 打开FILENAME指定的文件,将其与FILEHANDLE相关联。 MODE参数指定应如何打开文件。 MODE的值取决于系统,但某些值是历史设置的。 值0,1和2分别表示只读,只写和读/写。 支持的值在Fcntl模块中可用,并总结在下表中。

请注意,FILENAME严格来说是文件名; 没有对内容的解释(与open不同),并且打开模式由MODE参数定义。

如果必须创建文件,并且已在MODE中指定了O_CREAT标志,则使用PERMS权限创建文件。 必须在传统的Unix风格的十六进制中指定PERMS的值。 如果未指定PERMS,则Perl使用默认模式0666(对用户/组/其他进行读/写)。

Flag		Description
O_RDONLY 	Read only.
O_WRONLY 	Write only.
O_RDWR 		Read and write.
O_CREAT		Create the file if it doesn.t already exist.
O_EXCL 		Fail if the file already exists.
O_APPEND 	Append to an existing file.
O_TRUNC 	Truncate the file before opening.
O_NONBLOCK 	Non-blocking mode.
O_NDELAY 	Equivalent of O_NONBLOCK.
O_EXLOCK 	Lock using flock and LOCK_EX.
O_SHLOCK 	Lock using flock and LOCK_SH.
O_DIRECTOPRY 	Fail if the file is not a directory.
O_NOFOLLOW 	Fail if the last path component is a symbolic link.
O_BINARY 	Open in binary mode (implies a call to binmode).
O_LARGEFILE 	Open with large (>2GB) file support.
O_SYNC 		Write data physically to the disk, instead of 
		write buffer.
O_NOCTTY 	Don't make the terminal file being opened 
	 	the processescontrolling terminal, even if you 
	 	don.t have one yet.

语法 (Syntax)

以下是此函数的简单语法 -

sysopen FILEHANDLE, FILENAME, MODE, PERMS
sysopen FILEHANDLE, FILENAME, MODE

返回值 (Return Value)

此函数在失败时返回0,在成功时返回1。

↑回到顶部↑
WIKI教程 @2018