本文简要介绍ruby语言中 Fcntl模块
的用法。
Fcntl
加载系统的
要执行 fcntl(2) 操作,请使用 IO::fcntl。
要执行 open(2) 操作,请使用 IO::sysopen
。
可用的操作和常量集取决于特定的操作系统。您的系统可能不支持下面列出的某些值。
有关完整的详细信息,请参见 fcntl(2) 手册页。
打开 /tmp/tempfile 作为 write-only 文件,如果它不存在则创建:
require 'fcntl'
fd = IO.sysopen('/tmp/tempfile',
Fcntl::O_WRONLY | Fcntl::O_EXCL | Fcntl::O_CREAT)
f = IO.open(fd)
f.syswrite("TEMP DATA")
f.close
获取文件 s
上的标志:
m = s.fcntl(Fcntl::F_GETFL, 0)
Set
除了 m
中的现有标志之外,f
上的非阻塞标志。
f.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK|m)
相关用法
- Ruby Float arg()用法及代码示例
- Ruby File.identical?用法及代码示例
- Ruby Fiber.schedule用法及代码示例
- Ruby Float fdiv()用法及代码示例
- Ruby Float quo()用法及代码示例
- Ruby Float angle()用法及代码示例
- Ruby FileUtils.mkdir用法及代码示例
- Ruby Float divmod()用法及代码示例
- Ruby Float.self - other用法及代码示例
- Ruby Float.rationalize用法及代码示例
- Ruby Float.truncate用法及代码示例
- Ruby FileUtils.compare_file用法及代码示例
- Ruby FileUtils.options_of用法及代码示例
- Ruby File.dirname用法及代码示例
- Ruby Formatter.random_bytes用法及代码示例
- Ruby Float prev_float()用法及代码示例
- Ruby FileUtils.ln_s用法及代码示例
- Ruby Float round()用法及代码示例
- Ruby Float denominator()用法及代码示例
- Ruby Float numerator()用法及代码示例
- Ruby Float absolute()用法及代码示例
- Ruby Float to_i()用法及代码示例
- Ruby Fiddle.dlwrap用法及代码示例
- Ruby Float nan?()用法及代码示例
- Ruby File.directory?用法及代码示例
注:本文由纯净天空筛选整理自ruby-lang.org大神的英文原创作品 Fcntl模块。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。