summaryrefslogtreecommitdiffstats
path: root/perl-install/resize_fat/dir_entry.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/resize_fat/dir_entry.pm')
-rw-r--r--perl-install/resize_fat/dir_entry.pm29
1 files changed, 17 insertions, 12 deletions
diff --git a/perl-install/resize_fat/dir_entry.pm b/perl-install/resize_fat/dir_entry.pm
index fa5ebb344..b39c72094 100644
--- a/perl-install/resize_fat/dir_entry.pm
+++ b/perl-install/resize_fat/dir_entry.pm
@@ -1,10 +1,14 @@
-package resize_fat::dir_entry;
+package resize_fat::dir_entry; # $Id$
use diagnostics;
use strict;
my $DELETED_FLAG = 0xe5;
+
+my $READ_ONLY_ATTR = 0x01;
+my $HIDDEN_ATTR = 0x02;
+my $SYSTEM_ATTR = 0x04;
my $VOLUME_LABEL_ATTR = 0x08;
my $VFAT_ATTR = 0x0f;
my $DIRECTORY_ATTR = 0x10;
@@ -13,7 +17,7 @@ my $DIRECTORY_ATTR = 0x10;
sub get_cluster($) {
my ($entry) = @_;
- $entry->{first_cluster} + ($resize_fat::isFAT32 ? $entry->{first_cluster_high} * 65536 : 0);
+ $entry->{first_cluster} + ($resize_fat::isFAT32 ? $entry->{first_cluster_high} * (1 << 16) : 0);
}
sub set_cluster($$) {
my ($entry, $val) = @_;
@@ -21,14 +25,14 @@ sub set_cluster($$) {
$entry->{first_cluster_high} = $val >> 16 if $resize_fat::isFAT32;
}
-sub is_directory_raw($) {
+sub is_unmoveable($) {
my ($entry) = @_;
- !is_special_entry($entry) && $entry->{attributes} & $DIRECTORY_ATTR;
+ $entry->{attributes} & $HIDDEN_ATTR || $entry->{attributes} & $SYSTEM_ATTR;
}
sub is_directory($) {
my ($entry) = @_;
- is_directory_raw($entry) && $entry->{name} !~ /^\.\.? /;
+ $entry->{attributes} & $DIRECTORY_ATTR && $entry->{name} !~ /^\.\.? / && !is_special_entry($entry);
}
sub is_volume($) {
@@ -46,7 +50,7 @@ sub is_special_entry($) {
my ($entry) = @_;
my ($c) = unpack "C", $entry->{name};
- # skip empty slots, deleted files, and 0xF6?? (taken from kernel)
+ #- skip empty slots, deleted files, and 0xF6?? (taken from kernel)
$c == 0 || $c == $DELETED_FLAG || $c == 0xF6 and return 1;
$entry->{attributes} == $VFAT_ATTR and return 1;
@@ -54,18 +58,19 @@ sub is_special_entry($) {
}
-# return true if entry has been modified
+#- return true if entry has been modified
+#- curr_dir_name is added to contains current directory name, "" for root.
sub remap {
- my ($fat_remap, $entry) = @_;
-
+ my ($curr_dir_name, $entry) = @_;
+
is_special_entry($entry) and return;
my $cluster = get_cluster($entry);
- my $new_cluster = $fat_remap->[$cluster];
+ my $new_cluster = resize_fat::c_rewritten::fat_remap($cluster);
- #print "remapping cluster ", get_first_cluster($fs, $entry), " to $new_cluster";
+ #-print "remapping cluster ", get_cluster($entry), " to $new_cluster";
- $new_cluster == $cluster and return; # no need to modify
+ $new_cluster == $cluster and return; #- no need to modify
set_cluster($entry, $new_cluster);
1;