-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-grf.js
More file actions
47 lines (39 loc) · 1.23 KB
/
test-grf.js
File metadata and controls
47 lines (39 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const GrfNode = require("@chicowall/grf-loader").GrfNode;
const { openSync, existsSync } = require("fs");
const path = require("path");
const testGrfLoad = async () => {
// exemplo de diretorio dado pelo DATA.INI
const data_ini = "resources/data.grf";
const filePath = path.resolve(data_ini);
// Verifica se o arquivo existe no caminho especificado
if (existsSync(filePath)) {
try {
const getClientInfo = async () => {
const fd = openSync(filePath, "r");
const grf = new GrfNode(fd);
// Start parsing the grf.
await grf.load();
// exemplo de como pegar os arquivos dentro da grf 'data\\pasta\\pasta\\conteudo'
const exemplo =
"data\\texture\\À¯ÀúÀÎÅÍÆäÀ̽º\\swap_equipment\\btn_change2_over.bmp";
const { data, error } = await grf.getFile(exemplo);
if (error) {
console.error("Erro ao obter o arquivo:", error);
return;
}
return data.toString("utf8");
};
getClientInfo().then(console.log).catch(console.error);
} catch (err) {
console.error("Erro ao abrir o arquivo:", err);
}
} else {
console.error(
"Arquivo não encontrado no caminho especificado:",
filePath
);
}
};
testGrfLoad().catch((err) => {
console.error("Erro no teste:", err);
});