File tree 3 files changed +21
-1
lines changed
3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,16 @@ export class FileSystem {
145
145
return atomicallyRead ( file , { encoding : "utf8" } ) ;
146
146
}
147
147
148
+ /**
149
+ * Reads a file as raw data and returns the contents as a Buffer.
150
+ *
151
+ * @param file The file path to read.
152
+ * @returns A promise that resolves with the raw file contents as a Buffer.
153
+ */
154
+ public readRaw ( file : string ) : Promise < Buffer > {
155
+ return atomicallyRead ( file ) ;
156
+ }
157
+
148
158
/**
149
159
* Writes data to a file, overwriting if the file already exists. If the parent directory does not exist, it's
150
160
* created. File must be a file path (a buffer or a file descriptor is not allowed).
Original file line number Diff line number Diff line change @@ -143,6 +143,16 @@ export class FileSystemSync {
143
143
return atomicallyReadSync ( file , { encoding : "utf8" } ) ;
144
144
}
145
145
146
+ /**
147
+ * Reads a file as raw data and returns the contents as a Buffer.
148
+ *
149
+ * @param file The file path to read.
150
+ * @returns The raw file contents as a Buffer.
151
+ */
152
+ public readRaw ( file : string ) : Buffer {
153
+ return atomicallyReadSync ( file ) ;
154
+ }
155
+
146
156
/**
147
157
* Writes data to a file, overwriting if the file already exists. If the parent directory does not exist, it's
148
158
* created. File must be a file path (a buffer or a file descriptor is not allowed).
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ export class HashUtil {
38
38
}
39
39
40
40
public generateCRC32ForFile ( filePath : string ) : number {
41
- return crc32 ( this . fileSystemSync . read ( filePath ) ) ;
41
+ return crc32 ( this . fileSystemSync . readRaw ( filePath ) ) ;
42
42
}
43
43
/**
44
44
* Create a hash for the data parameter
You can’t perform that action at this time.
0 commit comments