@@ -41,6 +41,10 @@ export class AbstractFolder {
4141 _namedict : { [ key : string ] : Uint8Array } ;
4242 _maindict : { [ name : string ] : FileOrFolder } ;
4343
44+ crdate : number ;
45+ mddate : number ;
46+ bkdate : number ;
47+
4448 constructor ( ) {
4549 this . _namedict = { } ; // key string to raw name
4650 this . _maindict = { } ; // key string to contents
@@ -86,28 +90,37 @@ export class AbstractFolder {
8690 return res ;
8791 }
8892
89- dumpToZip ( zipDir : ZipDirectoryEntry , lang : Language , puny : boolean , forceMacBinary : boolean , log : ( string ) => void ) : void {
93+ dumpToZip ( zipDir : ZipDirectoryEntry , lang : Language , puny : boolean , forceMacBinary : boolean , log : ( string ) => void ) : ZipDirectoryEntry {
9094 for ( const [ name , child ] of this . items ( ) ) {
9195 const encodedName = encodeFileName ( name , lang , puny , log ) ;
9296 if ( child instanceof AbstractFolder ) {
93- child . dumpToZip ( zipDir . addDirectory ( encodedName ) , lang , puny , forceMacBinary , log ) ;
97+ child . dumpToZip ( zipDir . addDirectory ( encodedName , {
98+ lastModDate : hfs_ts_to_date ( child . mddate ) ,
99+ } ) , lang , puny , forceMacBinary , log ) ;
94100 } else {
95- zipDir . addUint8Array ( encodedName , forceMacBinary ? child . toMacBinary ( name ) : child . toBinary ( name ) ) ;
101+ zipDir . addUint8Array ( encodedName , forceMacBinary ? child . toMacBinary ( name ) : child . toBinary ( name ) , {
102+ lastModDate : hfs_ts_to_date ( child . mddate ) ,
103+ } ) ;
96104 }
97105 }
106+ return zipDir ;
98107 }
99108}
100109
110+ function hfs_ts_to_date ( hfs_ts ) {
111+ const HFS_UTC_OFFSET = 2082844800 ;
112+ if ( ! hfs_ts ) {
113+ return new Date ( ) ;
114+ }
115+ return new Date ( ( hfs_ts - HFS_UTC_OFFSET ) * 1000 ) ;
116+ }
117+
101118
102119export class MacFolder extends AbstractFolder {
103120 flags : number ;
104121 x : number ;
105122 y : number ;
106123
107- crdate : number ;
108- mddate : number ;
109- bkdate : number ;
110-
111124 constructor ( ) {
112125 super ( ) ;
113126
0 commit comments