ЭЛЕКТРОННАЯ БИБЛИОТЕКА КОАПП |
Сборники Художественной, Технической, Справочной, Английской, Нормативной, Исторической, и др. литературы. |
13.4 Modifying PermissionsThe permissions on a file or directory define who (in broad categories) can do what (more or less) to that file or directory. Under UNIX, the typical way to change permissions on a file is with the chmod command. As a Windows user, you may be more used to the attrib command. Perl changes permissions with the chmod(0666,"fred","barney"); In short, the UNIX (and Perl) concept of file permissions consists of a bit for read, write, and execute rights for the user, the user's group, and everyone else. These bits are combined to create the mode. Because Win32 systems have a significantly different concept of permissions, you don't need to worry about all of the different possible values for the mode. Table 13.1 presents a couple of key values.
Win32 systems determine whether or not a file is executable based on the file extension, so we're not going to worry about the execute bits. Furthermore, even though some Windows NT filesystems support advanced user/group rights, the current Perl implementation doesn't support access to these rights via The return value of foreach $file ("fred","barney") { unless chmod (0666,$file) { warn "hmm... couldn't chmod $file.$!"; } } The
To combine attributes, use the bitwise or operator |. Here's an example of how to make a file read-only, without changing its other attributes: use Win32::File; Win32::File::GetAttributes("foo.txt", $attrib) || die $!; Win32::File::SetAttributes("foo.txt", $attrib | READONLY) || die $!; Although we won't get to references until Chapter 18, CGI Programming, the To set user permissions on NTFS filesystems, use either the |