Thread Windows Dateiattribute abfragen (8 answers)
Opened by bianca at 2011-02-01 14:48

Linuxer
 2011-02-01 15:13
#145246 #145246
User since
2006-01-27
3876 Artikel
HausmeisterIn

user image
Win32::File funktioniert hier anstandslos:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#! /usr/bin/perl
use strict;
use warnings;

use Win32::File qw( ARCHIVE HIDDEN );

my $attrib;

if ( Win32::File::GetAttributes( $0, $attrib ) ) {
  print "$0 has to be archived.\n"    if $attrib & ARCHIVE;
  print "$0 is hidden.\n"             if $attrib & HIDDEN;
}
else {
  print "Could not get attributes for $0.\n";
}



Tested (WinXP SP3):
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
D:\temp>attrib archive.pl
A H D:\temp\archive.pl

D:\temp>perl archive.pl
archive.pl has to be archived.
archive.pl is hidden.

D:\temp>attrib -a archive.pl
Versteckte Datei wird nicht zurückgesetzt - D:\temp\archive.pl

D:\temp>perl archive.pl
archive.pl has to be archived.
archive.pl is hidden.

D:\temp>attrib -ha archive.pl
Unzulässige Option - -ha

D:\temp>attrib -h -a archive.pl

D:\temp>perl archive.pl

D:\temp>


Worin besteht das Problem?

edit: Code modified; check GetAttributes for succcess.
Last edited: 2011-02-01 15:19:39 +0100 (CET)
meine Beiträge: I.d.R. alle Angaben ohne Gewähr und auf Linux abgestimmt!
Die Sprache heisst Perl, nicht PERL. - Bitte Crossposts als solche kenntlich machen!

View full thread Windows Dateiattribute abfragen