MSDOS::Attrib - Get or set MS-DOS file attributes
This document describes version 1.04 of MSDOS::Attrib, released May 3, 2008.
use MSDOS::Attrib qw(get_attribs set_attribs); $attribs = get_attribs($path); set_attribs($attribs, $path1, $path2, ...);
MSDOS::Attrib provides access to MS-DOS file attributes. While the read-only attribute can be handled by
stat, the hidden, system, and archive attributes cannot.
- $attribs = get_attribs($path)
Returns the attributes of
$path, or the empty string if
$pathdoes not exist. Attributes are returned as a five-character string in this format: "RHSAD". Each letter is replaced by an underscore (
_) if the file does not have the corresponding attribute. (This is the same format as a 4DOS directory listing.) The attributes are:
R The file is read-only (not writable) H The file is hidden (does not appear in directory listings) S The file is a system file (does not appear in directory listings) A The file needs to be archived (it has changed since last backup) D The file is a directory
- $count = set_attribs($attribs, $path1, [$path2, ...])
Sets the attributes of
$path2, etc. You can either specify the complete set of attributes, or add and subtract attributes by using
-. The case and order of the attributes is not important. For example, '-s+ra' will remove the system attribute and add the read-only and archive attributes. You should not use whitespace between attributes, although underscores are OK. See
get_attribsfor an explanation of the attribute values. You cannot change the directory attribute; if you specify it, it is ignored. Returns the number of files successfully changed.
The OS2::ExtAttr module provides access to extended attributes under OS/2.
The Win32::FileSecurity module provides access to Discretionary Access Control Lists under Windows NT.
Christopher J. Madsen
<perl AT cjmweb.net>
Please report any bugs or feature requests to
<bug-MSDOS-Attrib AT rt.cpan.org>, or through the web interface at http://rt.cpan.org/Public/Bug/Report.html?Queue=MSDOS-Attrib
Copyright 1996-2008 Christopher J. Madsen
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.