@@ -4,7 +4,7 @@ import * as errors from './errors';
44import * as utils from './utils' ;
55import * as constants from './constants' ;
66
7- // Computes the checksum by adding the value of every single byte in the header
7+ // Computes the checksum by summing up all the bytes in the header
88function computeChecksum ( header : Buffer ) : number {
99 if ( ! header . subarray ( 148 , 156 ) . every ( ( byte ) => byte === 32 ) ) {
1010 throw new errors . ErrorVirtualTarInvalidHeader (
@@ -80,7 +80,7 @@ function createHeader(
8080 utils . splitFileName ( filePath , 0 , HeaderSize . FILE_NAME ) ,
8181 HeaderOffset . FILE_NAME ,
8282 HeaderSize . FILE_NAME ,
83- constants . HEADER_ENCODING ,
83+ constants . TEXT_ENCODING ,
8484 ) ;
8585
8686 // The file permissions, or the mode, is stored in the next chunk. This is
@@ -89,23 +89,23 @@ function createHeader(
8989 utils . pad ( stat . mode ?? '' , HeaderSize . FILE_MODE , '0' , '\0' ) ,
9090 HeaderOffset . FILE_MODE ,
9191 HeaderSize . FILE_MODE ,
92- constants . HEADER_ENCODING ,
92+ constants . TEXT_ENCODING ,
9393 ) ;
9494
9595 // The owner UID is stored in this chunk
9696 header . write (
9797 utils . pad ( stat . uid ?? '' , HeaderSize . OWNER_UID , '0' , '\0' ) ,
9898 HeaderOffset . OWNER_UID ,
9999 HeaderSize . OWNER_UID ,
100- constants . HEADER_ENCODING ,
100+ constants . TEXT_ENCODING ,
101101 ) ;
102102
103103 // The owner GID is stored in this chunk
104104 header . write (
105105 utils . pad ( stat . gid ?? '' , HeaderSize . OWNER_GID , '0' , '\0' ) ,
106106 HeaderOffset . OWNER_GID ,
107107 HeaderSize . OWNER_GID ,
108- constants . HEADER_ENCODING ,
108+ constants . TEXT_ENCODING ,
109109 ) ;
110110
111111 // The file size is stored in this chunk. The file size must be zero for
@@ -114,7 +114,7 @@ function createHeader(
114114 utils . pad ( size ?? '' , HeaderSize . FILE_SIZE , '0' , '\0' ) ,
115115 HeaderOffset . FILE_SIZE ,
116116 HeaderSize . FILE_SIZE ,
117- constants . HEADER_ENCODING ,
117+ constants . TEXT_ENCODING ,
118118 ) ;
119119
120120 // The file mtime is stored in this chunk. As the mtime is not modified when
@@ -124,7 +124,7 @@ function createHeader(
124124 utils . pad ( time , HeaderSize . FILE_MTIME , '0' , '\0' ) ,
125125 HeaderOffset . FILE_MTIME ,
126126 HeaderSize . FILE_MTIME ,
127- constants . HEADER_ENCODING ,
127+ constants . TEXT_ENCODING ,
128128 ) ;
129129
130130 // The checksum is calculated as the sum of all bytes in the header. It is
@@ -133,15 +133,15 @@ function createHeader(
133133 utils . pad ( '' , HeaderSize . CHECKSUM , ' ' ) ,
134134 HeaderOffset . CHECKSUM ,
135135 HeaderSize . CHECKSUM ,
136- constants . HEADER_ENCODING ,
136+ constants . TEXT_ENCODING ,
137137 ) ;
138138
139139 // The type of file is written as a single byte in the header.
140140 header . write (
141141 type ,
142142 HeaderOffset . TYPE_FLAG ,
143143 HeaderSize . TYPE_FLAG ,
144- constants . HEADER_ENCODING ,
144+ constants . TEXT_ENCODING ,
145145 ) ;
146146
147147 // File owner name will be null, as regular stat-ing cannot extract that
@@ -153,15 +153,15 @@ function createHeader(
153153 constants . USTAR_NAME ,
154154 HeaderOffset . USTAR_NAME ,
155155 HeaderSize . USTAR_NAME ,
156- constants . HEADER_ENCODING ,
156+ constants . TEXT_ENCODING ,
157157 ) ;
158158
159159 // This chunk stores the version of USTAR, which is '00' in this case.
160160 header . write (
161161 constants . USTAR_VERSION ,
162162 HeaderOffset . USTAR_VERSION ,
163163 HeaderSize . USTAR_VERSION ,
164- constants . HEADER_ENCODING ,
164+ constants . TEXT_ENCODING ,
165165 ) ;
166166
167167 // Owner user name will be null, as regular stat-ing cannot extract this
@@ -186,7 +186,7 @@ function createHeader(
186186 ) ,
187187 HeaderOffset . FILE_NAME_EXTRA ,
188188 HeaderSize . FILE_NAME_EXTRA ,
189- constants . HEADER_ENCODING ,
189+ constants . TEXT_ENCODING ,
190190 ) ;
191191
192192 // Updating with the new checksum
@@ -199,7 +199,7 @@ function createHeader(
199199 utils . pad ( checksum , HeaderSize . CHECKSUM , '0' , '\0 ' ) ,
200200 HeaderOffset . CHECKSUM ,
201201 HeaderSize . CHECKSUM ,
202- constants . HEADER_ENCODING ,
202+ constants . TEXT_ENCODING ,
203203 ) ;
204204
205205 return header ;
0 commit comments