-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
500 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"tabWidth": 4, | ||
"trailingComma": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
const fs = require('fs'); | ||
const { JagArchive } = require('./src'); | ||
import fs from 'fs/promises'; | ||
import { JagArchive } from './src/index.js'; | ||
|
||
const archive = new JagArchive(); | ||
await archive.init(); | ||
archive.readArchive(await fs.readFile('./cache/sounds1.mem')); | ||
|
||
let rawJag = fs.readFileSync('./data204/sounds1.mem'); | ||
let archive = new JagArchive(); | ||
archive.readArchive(rawJag); | ||
console.log(`cache has ${archive.entries.size} files`); | ||
fs.writeFileSync('death.pcm', archive.getEntry('death.pcm')); | ||
|
||
const testArchive = new JagArchive(); | ||
testArchive.putEntry('test.txt', Buffer.from('test string')); | ||
fs.writeFileSync('./data204/test.jag', testArchive.toArchive(true)); | ||
// get death.pcm from the archive and write it to disk | ||
await fs.writeFile('death.pcm', archive.getEntry('death.pcm')); | ||
|
||
// create a new archive and add a text file to it | ||
archive.entries.clear(); | ||
archive.putEntry('test.txt', Buffer.from('test string')); | ||
await fs.writeFile('./cache/test.jag', archive.toArchive(true)); | ||
|
||
// read the new archive and retrive the file from it | ||
archive.readArchive(await fs.readFile('./cache/test.jag')) | ||
|
||
rawJag = fs.readFileSync('./data204/test.jag'); | ||
archive = new JagArchive(); | ||
archive.readArchive(rawJag); | ||
console.log(`cache has ${archive.entries.size} files`); | ||
console.log(archive.getEntry('test.txt').toString()); | ||
console.log(Buffer.from(archive.getEntry('test.txt')).toString()); |
Oops, something went wrong.