Changeset 4925

Show
Ignore:
Timestamp:
10/29/09 08:48:20 (4 weeks ago)
Author:
asawada
Message:

Fixed Backup/Restore can't handle multibyte named file. bugzid:102920.

Location:
branches/greyhound/lib/MT
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/greyhound/lib/MT/FileMgr/Local.pm

    r4196 r4925  
    2020 
    2121sub _syserr { 
    22     return $_[0] if $^O ne 'MSWin32'; 
    23     return Encode::decode('Shift_JIS', $_[0]) unless Encode::is_utf8($_[0]); 
    24     $_[0]; 
     22    if ( $^O eq 'MSWin32' ) { 
     23        return Encode::is_utf8($_[0]) ? $_[0] 
     24                                      : Encode::decode('Shift_JIS', $_[0]) 
     25                                      ; 
     26    } 
     27    else { 
     28        return Encode::is_utf8($_[0]) ? $_[0] 
     29                                      : Encode::decode_utf8($_[0]) 
     30                                      ; 
     31    } 
    2532} 
    2633 
  • branches/greyhound/lib/MT/Util/Archive/Tgz.pm

    r4726 r4925  
    117117    $path ||= MT->config->TempDir; 
    118118    for my $file ( $obj->files ) { 
    119         my $file_enc = MT::FileMgr::Local::_syserr( $file ); 
     119        my $file_enc = Encode::decode_utf8( $file ); 
    120120        my $f = File::Spec->catfile( $path, $file_enc ); 
    121121        $obj->{_arc}->extract_file( $file, MT::FileMgr::Local::_local( $f ) ); 
     
    129129    return $obj->error(MT->translate('Can\'t write to the object')) 
    130130        if 'r' eq $obj->{_mode}; 
     131    $file_path = Encode::encode_utf8($file_path) 
     132        if Encode::is_utf8($file_path); 
    131133    my $filename = 
    132134        File::Spec->catfile( $path, $file_path ); 
  • branches/greyhound/lib/MT/Util/Archive/Zip.pm

    r4726 r4925  
    2121    return $pkg->error(MT->translate('Type must be zip')) 
    2222        unless $type eq ARCHIVE_TYPE; 
    23      
     23 
    2424    my $zip = Archive::Zip->new; 
    2525    my $obj = { _flushed => 0, _arc => $zip }; 
     
    101101    $path ||= MT->config->TempDir; 
    102102    for my $file ( $obj->files ) { 
    103         my $file_enc = MT::FileMgr::Local::_syserr( $file ); 
     103        my $file_enc = Encode::decode('Shift_JIS', $file ); 
    104104        my $f = File::Spec->catfile( $path, $file_enc ); 
    105105        $obj->{_arc}->extractMember( $file, MT::FileMgr::Local::_local( $f ) ); 
     
    115115    my $filename = 
    116116        File::Spec->catfile( $path, $file_path ); 
     117    $file_path = Encode::encode('Shift_JIS', $file_path) 
     118        if Encode::is_utf8($file_path); 
    117119    $obj->{_arc}->addFile( $filename, $file_path ); 
    118120} 
     
    125127    return $obj->error(MT->translate('Both data and file name must be specified.')) 
    126128        unless $string && $file_name; 
    127  
     129    $file_name = Encode::encode('Shift_JIS', $file_name) 
     130        if Encode::is_utf8($file_name); 
    128131    $obj->{_arc}->addString($string, $file_name); 
    129132}