package transfugdrake; use strict; use warnings; use common; sub get_insensitive_path { my ($prefix, $path) = @_; my $full_path = $prefix; my @path_l = split("/", $path); foreach my $i (@path_l) { my $e = find { lc($_) eq lc($i) } all($full_path) or return; $full_path .= "/" . $e; } return $full_path; } sub get_windows_system_path { my ($prefix, $suffix) = @_; foreach my $system (qw(WINDOWS WINNT)) { my $p = get_insensitive_path($prefix, join("/", $system, $suffix)); return $p if $p; } } sub get_windows_disk() { require fs; require fs::type; my $all_hds = fsedit::get_hds(); fs::get_raw_hds('', $all_hds); fs::get_info_from_fstab($all_hds); my $fstab = [ fs::get::fstab($all_hds) ]; fs::merge_info_from_mtab($fstab); my @win_devices = grep { fs::type::isFat_or_NTFS($_) && fs::type::isMounted($_) } @$fstab; find { get_windows_system_path($_, "system32/config/software"); } map { $_->{mntpoint} } @win_devices; } sub list_windows_users { my ($win_prefix) = @_; my @users = chomp_(split(/,\s*/, run_program::get_stdout("ma-search-users", "windowsxp", $win_prefix))); my ($standard, $admin) = partition { $_ ne "Administrator" } @users; sort(@$standard), @$admin; } sub list_windows_items { my ($win_prefix, $win_user) = @_; chomp_(split(/,\s*/, run_program::get_stdout("ma-search-items", "--ostype=windowsxp", "--path=$win_prefix", "--user=$win_user"))); } sub import_target { my ($win_prefix, $win_user, $linux_user, $target) = @_; my $lc_target = lc($target); $lc_target =~ s/\s//g; run_program::raw({ timeout => "never" }, "ma-import", "--fromuser=$win_user", "--frompath=$win_prefix", "--touser=$linux_user", "--topath=/", "--target=$lc_target", "--ostype=windowsxp", ); } 1;