encoding-tools 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/encoding-tools ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+
3
+ // SPDX-License-Identifier: AGPL-3.0-or-later
4
+
5
+ /** ------------------------------------------------------------------
6
+ * Copyright ©
7
+ * Pellegrino Prevete
8
+ * 2024, 2025, 2026
9
+ *
10
+ * All rights reserved
11
+ * ------------------------------------------------------------------
12
+ *
13
+ * This program is free software: you can redistribute it and/or
14
+ * modify it under the terms of the GNU General Public License as
15
+ * published by the Free Software Foundation, either version 3 of
16
+ * the License, or (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program.
25
+ * If not, see <https://www.gnu.org/licenses/>.
26
+ */
27
+
28
+ const
29
+ _bin2txt_module =
30
+ require(
31
+ "./libbin2txt");
32
+ // const
33
+ // _libtxt2bin =
34
+ // require(
35
+ // "./txt2bin");
36
+
37
+ module.exports = {
38
+ _bin2txt:
39
+ _bin2txt_module._bin2txt
40
+ // _txt2bin:
41
+ // _txt2bin
42
+ };
package/libbin2txt CHANGED
@@ -30,13 +30,19 @@
30
30
  const
31
31
  _libcrash =
32
32
  require(
33
- 'crash-js');
33
+ "crash-js");
34
+ const
35
+ _dirname =
36
+ _libcrash._dirname;
34
37
  const
35
38
  _error_display =
36
39
  _libcrash._error_display;
37
40
  const
38
41
  _ext_rm =
39
42
  _libcrash._ext_rm;
43
+ const
44
+ _file_exists =
45
+ _libcrash._file_exists;
40
46
  const
41
47
  _file_read =
42
48
  _libcrash._file_read;
@@ -61,12 +67,46 @@ const
61
67
  const
62
68
  _msg_error =
63
69
  _libcrash._msg_error;
64
- const
65
- _split =
66
- _libcrash._split;
67
70
  const
68
71
  _stat =
69
72
  _libcrash._stat;
73
+ const
74
+ _tmcsplit =
75
+ require(
76
+ "tmcsplit");
77
+ const
78
+ _split =
79
+ _tmcsplit._split;
80
+
81
+ async function
82
+ _blocks_find(
83
+ _pattern) {
84
+ let
85
+ _dir,
86
+ _dir_content,
87
+ _msg;
88
+ _msg =
89
+ "Looking for files " +
90
+ `respecting pattern '^${_pattern}*.`;
91
+ _msg_info(
92
+ _msg);
93
+ _dir =
94
+ _dirname(
95
+ _pattern);
96
+ console.log(_dir);
97
+ _dir_content =
98
+ _ls(
99
+ _dir);
100
+ for ( _file of _dir_content ) {
101
+ if ( _file.startsWith(
102
+ _pattern)) {
103
+ }
104
+ }
105
+ console.log(
106
+ typeof(_dir_content));
107
+ console.log(
108
+ _dir_content);
109
+ }
70
110
 
71
111
  async function
72
112
  _buffer_prepare(
@@ -75,38 +115,56 @@ async function
75
115
  _buffer_size_bytes) {
76
116
  let
77
117
  _in_size_bytes,
118
+ _size_max,
78
119
  _split_opts,
79
120
  _msg;
80
- _split_opts =
81
- [];
82
- console.log(
83
- _stat);
84
- console.log(
85
- _in);
121
+ _size_max =
122
+ 0;
123
+ if ( ! _file_exists(
124
+ _in) ) {
125
+ _msg =
126
+ `File '${_in}' does ` +
127
+ 'not exist.';
128
+ _msg_error(
129
+ _msg,
130
+ 1);
131
+ }
132
+ // console.log(
133
+ // _in);
134
+ _in_size_bytes =
135
+ _stat(
136
+ _in).size;
137
+ _msg =
138
+ `File '${_in}' has size ` +
139
+ `'${_in_size_bytes}' bytes.`;
140
+ _msg_info(
141
+ _msg);
86
142
  console.log(
87
- _out);
88
- // _in_size_bytes="$( \
89
- // du \
90
- // -bs \
91
- // "${_in}" | \
92
- // awk \
93
- // '{print $1}')"
94
- // _msg=(
95
- // "File '${_in}' has size"
96
- // "'${_in_size_bytes}' bytes."
97
- // )
98
- // _msg_info \
99
- // "${_msg[*]}"
100
- // _blocks_total="$(( \
101
- // _in_size_bytes / _buffer_size_bytes + 1))"
102
- // split \
103
- // -n \
104
- // "l/${_blocks_total}" \
105
- // --numeric-suffixes="1" \
106
- // "${_in}" \
107
- // "${_out}.block."
108
- // _blocks_find \
109
- // "${_out}.block"
143
+ typeof(
144
+ _in_size_bytes));
145
+ _blocks_total =
146
+ Math.ceil(
147
+ _in_size_bytes /
148
+ _buffer_size_bytes);
149
+ console.log(_in_size_bytes);
150
+ console.log(_buffer_size_bytes);
151
+ console.log(_blocks_total);
152
+ _split_opts = [
153
+ _in,
154
+ `${_out}.block.`,
155
+ _blocks_total,
156
+ _size_max
157
+ ];
158
+ await _split.apply(
159
+ null,
160
+ _split_opts);
161
+ _blocks_find(
162
+ `${_out}.sf-part`);
163
+ // console.log(
164
+ // _stat(
165
+ // _in).size / 1000);
166
+ // console.log(
167
+ // _out);
110
168
  }
111
169
 
112
170
  async function
@@ -141,14 +199,6 @@ async function
141
199
  _in,
142
200
  _out,
143
201
  _buffer_size_bytes);
144
- // _split(
145
- // "",
146
- // 2);
147
- // _split(
148
- // _input_file,
149
- // _output_prefix,
150
- // _chunks_amount,
151
- // _size_max) {
152
202
  // console.log(
153
203
  // _split
154
204
  // );