summaryrefslogtreecommitdiffstats
path: root/perl-install/resize_fat/directory.pm
diff options
context:
space:
mode:
authordamien <damien@mandriva.com>2000-11-28 16:56:52 +0000
committerdamien <damien@mandriva.com>2000-11-28 16:56:52 +0000
commit0880c7ba8ce88e87fa600aeb367a8f88a3ae71e7 (patch)
tree33f7ac905998f9ad6d85090f777ee4c0d0c67032 /perl-install/resize_fat/directory.pm
parentd5c526273db473a7d87a26000585900fc10dda7d (diff)
downloaddrakx-backup-do-not-use-topic/unlabeled-1.1.1.tar
drakx-backup-do-not-use-topic/unlabeled-1.1.1.tar.gz
drakx-backup-do-not-use-topic/unlabeled-1.1.1.tar.bz2
drakx-backup-do-not-use-topic/unlabeled-1.1.1.tar.xz
drakx-backup-do-not-use-topic/unlabeled-1.1.1.zip
branch to build the firewall install.topic/unlabeled-1.1.1
Diffstat (limited to 'perl-install/resize_fat/directory.pm')
-rw-r--r--perl-install/resize_fat/directory.pm45
1 files changed, 23 insertions, 22 deletions
diff --git a/perl-install/resize_fat/directory.pm b/perl-install/resize_fat/directory.pm
index ab8ec5328..beb780bcf 100644
--- a/perl-install/resize_fat/directory.pm
+++ b/perl-install/resize_fat/directory.pm
@@ -1,4 +1,4 @@
-package resize_fat::directory;
+package resize_fat::directory; # $Id$
use diagnostics;
use strict;
@@ -14,35 +14,36 @@ my @fields = (
'extension',
'attributes',
'is_upper_case_name',
- 'creation_time_low', # milliseconds
+ 'creation_time_low', #- milliseconds
'creation_time_high',
'creation_date',
'access_date',
- 'first_cluster_high', # for FAT32
+ 'first_cluster_high', #- for FAT32
'time',
'date',
'first_cluster',
'length',
);
+my $psizeof_format = psizeof($format);
1;
-sub entry_size { psizeof($format) }
+sub entry_size { $psizeof_format }
-# call `f' for each entry of the directory
-# if f return true, then modification in the entry are taken back
+#- call `f' for each entry of the directory
+#- if f return true, then modification in the entry are taken back
sub traverse($$$) {
- my ($fs, $directory, $f) = @_;
+ my ($directory, $curr_dir_name, $f) = @_;
- for (my $i = 0; 1; $i++) {
- my $raw = \substr($directory, $i * psizeof($format), psizeof($format));
+ for (my $i = 0;; $i++) {
+ my $raw = \substr($directory, $i * $psizeof_format, $psizeof_format);
- # empty entry means end of directory
+ #- empty entry means end of directory
$$raw =~ /^\0*$/ and return $directory;
my $entry; @{$entry}{@fields} = unpack $format, $$raw;
- &$f($entry)
+ &$f($curr_dir_name, $entry)
and $$raw = pack $format, @{$entry}{@fields};
}
$directory;
@@ -52,27 +53,27 @@ sub traverse_all($$) {
my ($fs, $f) = @_;
my $traverse_all; $traverse_all = sub {
- my ($entry) = @_;
+ my ($curr_dir_name, $entry) = @_;
- &$f($entry);
+ &$f($curr_dir_name, $entry);
- resize_fat::dir_entry::is_directory($entry)
- and traverse($fs, resize_fat::io::read_file($fs, resize_fat::dir_entry::get_cluster($entry)), $traverse_all);
+ resize_fat::dir_entry::is_directory($entry)
+ and traverse(resize_fat::io::read_file($fs, resize_fat::dir_entry::get_cluster($entry)), "$curr_dir_name/$entry->{name}", $traverse_all);
- undef; # no need to write back (cf traverse)
+ undef; #- no need to write back (cf traverse)
};
my $directory = $resize_fat::isFAT32 ?
resize_fat::io::read_file($fs, $fs->{fat32_root_dir_cluster}) :
resize_fat::io::read($fs, $fs->{root_dir_offset}, $fs->{root_dir_size});
- traverse($fs, $directory, $traverse_all);
+ traverse($directory, "", $traverse_all);
+ undef $traverse_all; #- circular reference is no good for perl's poor GC :(
}
-# function used by construct_dir_tree to translate the `cluster' fields in each
-# directory entry
-sub remap {
+#- function used by construct_dir_tree to translate the `cluster' fields in each
+#- directory entry
+sub remap($$) {
my ($fs, $directory) = @_;
-
- traverse($fs->{fat_remap}, $directory, sub { resize_fat::dir_entry::remap($fs->{fat_remap}, $_[0]) });
+ traverse($directory, "", \&resize_fat::dir_entry::remap);
}