Obtain and modify file attributes in Perl (Win32 System)

Source: Internet
Author: User

Sometimes we need to process some attributes of the file, such as read-only and hidden,

Here I will explain how to obtain and modify the attributes of a file in Win32.

Required: Use Win32: file;

Use the following method:

My $ set;

# Retrieving file attributes
Win32: file: getattributes ($ name, $ set );

# Setting file attributes
Win32: file: setattributes ($ name, archive );

In perldoc, the attributes that can be set are as follows:

archive archive file 32
compressed compressed file 2048
directory directory file 16
hidden hides file 2
normal normal file 128
offline offline file 4096
readonly Read-Only file 1
System System File 4
temporary temporary file 256
For the sake of understanding, I In the Program , the corresponding values of each option are printed and attached to the backend,
Each option occupies only one place, so we can use or | to apply multiple attributes at the same time, as shown below:
Win32: file: setattributes ($ name, archive | hidden );
In this way, you will find that your files are hidden and archived at the same time. ^_^
Retained the following information:
author (author): smilelance
time: 2006.08.11
Source (from): http://blog.csdn.net/smilelance
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.