Here are some code snippets that may be of use:

    %AttrCodes = ('A' => ARCHIVE,
                  'C' => COMPRESSED,
                  'D' => DIRECTORY,
                  'H' => HIDDEN,
                  'N' => NORMAL,
                  'O' => OFFLINE,
                  'R' => READONLY,
                  'S' => SYSTEM,
                  'T' => TEMPORARY);


sub GetAttr($)
{
    my $Self = shift;
    unless (-e $Self) {warn("GetAttr: File $Self does not exist");
return(undef)}
    my $Attr   = 0;
    my $RetVar = '';
    unless (GetAttributes($Self,$Attr)) {warn("GetAttr: Cannot get
attributes for $Self"); return(undef)}
    foreach (keys %AttrCodes) {if ($Attr & $AttrCodes{$_}) {$RetVar .= $_}}
    return($RetVar);
}

sub SetAttr($$)
{
    my $File = shift;
    unless (-e $File) {warn("SetAttr: File $File does not exist");
return(0)}
    my $Flags   = shift;
    my $CurAttr = 0;
    my $NewAttr;
    unless (GetAttributes($File,$CurAttr)) {warn("SetAttr: Cannot get
attributes for $File"); return(0)}
    $NewAttr = $CurAttr;
    if ($Flags =~ /A/) {unless ($CurAttr & 32) {$NewAttr += ARCHIVE}}
    if ($Flags =~ /S/) {unless ($CurAttr &  4) {$NewAttr += SYSTEM}}
    if ($Flags =~ /H/) {unless ($CurAttr &  2) {$NewAttr += HIDDEN}}
    if ($Flags =~ /R/) {unless ($CurAttr &  1) {$NewAttr += READONLY}}
    if ($Flags =~ /a/) {if ($CurAttr & 32)     {$NewAttr -= ARCHIVE}}
    if ($Flags =~ /s/) {if ($CurAttr &  4)     {$NewAttr -= SYSTEM}}
    if ($Flags =~ /h/) {if ($CurAttr &  2)     {$NewAttr -= HIDDEN}}
    if ($Flags =~ /r/) {if ($CurAttr &  1)     {$NewAttr -= READONLY}}
    unless (SetAttributes($File,$NewAttr)) {warn("SetAttr: Cannot set
attributes for $File"); return(0)}
    return(1);
}

#--------------------------------------------------------------------------#
# Set the file modification date/time for the specified file.              #
#--------------------------------------------------------------------------#
sub RenameFiles($)
{
    # Declare local variables.
    my $Attr;
    my $File = $_[0];
    my $RenameFile;
    our $opt_s;

    # Skip directories.
    if (-d $File) {return(1)}

    # Get the file attributes.
    $Attr = GetAttr($File);

    # Files that have the read-only file attribute set cannot be renamed.
    if ($Attr =~/R/) {print("$File is read-only\n"); return(0)}

    # Rename the current filename to a lower-case version.
    $RenameFile = lc($File);
    if (rename($File,$RenameFile))
    {
        $Ctr++;
        # Set the archive file attribute.
        SetAttr($RenameFile,'A');
        if (not defined $opt_s) {print("$RenameFile\n")}
    }
    else {print("$File cannot be renamed\n")}

    return(1);
}

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc
----- Original Message -----
From: "Matthew Bartlett" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, May 28, 2002 05:11
Subject: Hidden Files


> Hi there,
> I am having trouble with hidden PDF files.
>
> The Story: Our company runs a piece of software that uses Adobe Acrobat to
> look at and pull text from PDF files. As with many a things this software
is
> prone to crashing. When this occurs then the PDF files that are currently
> open get hidden (company policy denies users the ability to see or unhide
> files). As you can see this becomes a problem as they can no longer work
on
> the files.
> I have written a small script below to unhide these files which work fine
> when files are hidden normally. Yet when the files get hidden from this
> application crash when run the script does not unhide the files but
returns
> the line "Parameter format not correct -". I have been un-able to find out
> why the hidden parameter that is attached to the file is invalid. Is there
> any way that this can be done using Perl code instead of a system call?
>


_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to