How to open a file for writing only if it does not exist in Perl 6?

According to open documents, there are adverbs for reading, writing and adding. It is wonderful and what I expect. I have a specific application that I use sysopenfor better management, and I tried to rewrite it in Perl 6. I know about NativeCall(as mentioned in my question aboutkill ), but is there something built-in that I am missing?

+6
source share
1 answer

This is incomplete documentation:

MoarVM has opensupported the more common POSIX flags since 2015, including O_EXCLthrough a named parameter :exclusive.

The flag combination you are looking for

my $fh = open "file", :mode<wo>, :create, :exclusive;

,

my $fh = open "file", :x;

, , , Perl 6 I/O Routines. . ; , :mode<pipe> ​​ JVM (, , , MoarVM).

+8

Source: https://habr.com/ru/post/1016536/


All Articles