Add more docs in a cynical attempt to get into Googles ranking for a vaguely relevant query 8-)
#! /usr/bin/perl -w
$vsn = q$Id: W9x_unrecycle.pl,v 1.2 2002/06/21 23:56:12 mca1001 Exp $;
use strict;
use vars qw($vsn);
=head1 NAME
W9x_unrecycle.pl - read a Win95/Win98 recycle bin info file and write a
batch file to restore the deleted files
=head1 SYNOPSIS
W9x_unrecycle /mnt/dos/recycled/info | grep IOSUBSYS | grep -v iomega > /mnt/dos/restore.bat
=head1 DESCRIPTION
When Windows 95 or 98 send files to the recycle bin, the files get
renamed 'dcNN.ext', and an entry is added to the index file, usually
called 'info' (maybe it's info2 under 98?)
This program reads the index file and writes lines suitable for
copying all the files back to their original locations. It's up to you
to do something useful with the output.
=head1 WHY YOU MIGHT NEED THIS
If you're messing about with recycled files from outside Windows, eg.
your Linux or BSD partition. In this case a batch file may not be what
you want, but it should tell you what you need to know.
If you've deleted some device drivers from Windows and you can't boot
the GUI (normal user interface) to restore them from the bitbucket. In
this case your best bet is to
=over 4
=item - copy c:\recycled\info onto a floppy
=item - transfer it to somewhere you can run Perl
=item - write the .bat file back to the floppy
=item - run the .bat file under DOS
=back
=head1 WHY I MIGHT WRITE THIS
To get Craig out of a spot of trouble after he broke his Iomega Zip
drivers. I think something got a bit upset because the SCSI subsystem
suddenly disappeared without being uninstalled.
=head1 WHAT DOES THAT BATCH FILE DO?
It will attempt to copy the "deleted" file back to its original
location. Sorry, I don't remember what flags DOS "copy" uses or what
they do. This program doesn't add any, but you could add a "/p" or
whatever in the print statement at the bottom of the perl script.
=head1 BUGS
=over 4
=item . It doesn't understand deleted directory items. Also, they
might screw up the 'dc' numbering.
=item .
It doesn't look at the deleted date or file permissions.
=item .
It doesn't look at the header on the index, which may contain some
useful data.
=item .
It doesn't quote spaces in destination filenames.
=item .
You can't use it easily under Win95 because the warnings on
STDERR will get mixed up with the batchfile that comes out of STDOUT.
Get a proper OS, or even Windows NT.
=back
This is not an undelete system!
=head1 AUTHOR
Copyright (C) 2001 Matthew Astley, all rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
=cut
# Everyone knows what the GPL is these days. The lawyers can argue
# about where you get the terms and conditions, this program's quite
# big enough without 17k of extra guff.
die "Syntax: $0 infofile
The info file is often found at c:\\recycled\\info or similar
You may use forward slashes instead of backslashes, even under DOS\n"
unless @ARGV == 1;
my $fn = $ARGV[0];
open INF, "<$fn" or die "Reading $fn: $!";
binmode INF; my $inf = join "", <INF>; # tmtowtdi
close INF;
# Records appear to be 280 long, with 20 bytes of junk before the
# start of the first
# Presumably this tells how many there are .. I didn't bother looking
my $junk = substr($inf, 0, 20, "");
my $item = 0;
while ($inf ne "") {
my $l = length($inf);
warn "Only $l bytes remain" unless $l >= 280;
my $rec = substr($inf, 0, 280, "");
$rec =~ s/^(.+?)\x00// || die "Bogus file path at $item (from 0)";
my $path = $1;
# $rec =~ s/^(.+?)\x00// || die "Bogus leaf name at $item (from 0)";
# my $leaf = $1;
my $ext = $path =~ m@(\.\w+)$@ ? $1 : "";
warn "Couldn't get the extension for dc$item" if $ext eq "";
# presumably the rest has file perms & dates, plus padding to 280
print "copy dc$item$ext $path\n";
$item ++;
}
|
Repository owner Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |