Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 3765

Show
Ignore:
Timestamp:
07/20/08 08:37:32 (4 months ago)
Author:
larsivi
Message:

Make sure native and absolute paths are handled properly, closes #1189

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/io/compress/Zip.d

    r3729 r3765  
    4141 
    4242import Path = tango.io.Path; 
     43import PathUtil = tango.util.PathUtil; 
    4344import Integer = tango.text.convert.Integer; 
    4445 
     
    13311332            char[] file_name) 
    13321333    { 
     1334        auto f_name = PathUtil.normalize(file_name); 
     1335        auto p = Path.parse(f_name); 
     1336 
    13331337        // Compute Zip version 
    13341338        if( data.extract_version == data.extract_version.max ) 
    13351339        { 
     1340 
    13361341            ushort zipver = 10; 
    13371342            void minver(ushort v) { zipver = v>zipver ? v : zipver; } 
     
    13481353 
    13491354                // File is a folder 
    1350                 if( file_name.length > 0 && file_name[$-1] == '/' 
    1351                         || file_name[$-1] == '\\' ) 
     1355                if( f_name.length > 0 && f_name[$-1] == '/' ) 
    13521356                    // Is a directory, not a real file 
    13531357                    minver(20); 
     
    13691373        LocalFileHeader header; 
    13701374        header.data = data; 
    1371         header.file_name = file_name; 
     1375        if (p.isAbsolute) 
     1376            f_name = f_name[p.root.length+1..$];  
     1377        header.file_name = Path.native(f_name); 
    13721378 
    13731379        // Write out the header and the filename 
     
    13811387        Entry entry; 
    13821388        entry.data.fromLocal(header.data); 
    1383         entry.filename = file_name; 
     1389        entry.filename = header.file_name; 
    13841390        entry.header_position = header_pos; 
    13851391        entry.data.relative_offset_of_local_header = cast(int) header_pos; 
     
    17791785    { 
    17801786        // Skip directories 
    1781         if( entry.info.name[$-1] == '/' ) continue; 
     1787        if( entry.info.name[$-1] == '/' || 
     1788            entry.info.name[$-1] == '\\') continue; 
    17821789 
    17831790        auto path = Path.join(dest, entry.info.name); 
     1791        path = Path.native(path); 
    17841792        scope fout = new FileConduit(path, FileConduit.WriteCreate); 
    17851793        fout.output.copy(entry.open);