Cari di Perl 
    Perl User Manual
Daftar Isi
(Sebelumnya) Open a file, pipe, or descriptorRemove one link to a file (Berikutnya)
Functions for filehandles, files, or directories

Set file creation mode mask

Daftar Isi

  • umask EXPR

  • umask

    Sets the umask for the process to EXPR and returns the previous value.If EXPR is omitted, merely returns the current umask.

    The Unix permission rwxr-x--- is represented as three sets of threebits, or three octal digits: 0750 (the leading 0 indicates octaland isn't one of the digits). The umask value is such a numberrepresenting disabled permissions bits. The permission (or "mode")values you pass mkdir or sysopen are modified by your umask, soeven if you tell sysopen to create a file with permissions 0777,if your umask is 0022, then the file will actually be created withpermissions 0755. If your umask were 0027 (group can'twrite; others can't read, write, or execute), then passingsysopen 0666 would create a file with mode 0640 (because 0666 &~ 027 is 0640).

    Here's some advice: supply a creation mode of 0666 for regularfiles (in sysopen) and one of 0777 for directories (inmkdir) and executable files. This gives users the freedom ofchoice: if they want protected files, they might choose process umasksof 022, 027, or even the particularly antisocial mask of 077.Programs should rarely if ever make policy decisions better left tothe user. The exception to this is when writing files that should bekept private: mail files, web browser cookies, .rhosts files, andso on.

    If umask(2) is not implemented on your system and you are trying torestrict access for yourself (i.e., (EXPR & 0700) > 0), raises an exception. If umask(2) is not implemented and you arenot trying to restrict access for yourself, returns undef.

    Remember that a umask is a number, usually given in octal; it is not astring of octal digits. See also oct, if all you have is a string.

    Portability issues: umask in perlport.

 
Source : perldoc.perl.org - Official documentation for the Perl programming language
Site maintained by Jon Allen (JJ)     See the project page for more details
Documentation maintained by the Perl 5 Porters
(Sebelumnya) Open a file, pipe, or descriptorRemove one link to a file (Berikutnya)