Skip to content

Commit 6db54d7

Browse files
committed
Fixed two bugs
* Fix #11 by not using the Array.prototype.clean anymore * Fix #10 by forcing writeSync position
1 parent 2efaed6 commit 6db54d7

6 files changed

Lines changed: 9 additions & 9 deletions

File tree

jssrc/alpha.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ var JPAK = {
6969
/**
7070
* Clean all deletedValue from array
7171
*/
72-
Array.prototype.clean = function(deleteValue) {
73-
for (var i = 0; i < this.length; i++) {
74-
if (this[i] === deleteValue) {
75-
this.splice(i, 1);
72+
JPAK.Tools.cleanArray = function(array, deleteValue) {
73+
for (var i = 0; i < array.length; i++) {
74+
if (array[i] === deleteValue) {
75+
array.splice(i, 1);
7676
i--;
7777
}
7878
}
79-
return this;
79+
return array;
8080
};
8181

8282
/*

jssrc/jds.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7676
while ( c < size ) {
7777
var chunk = size - c > this.CHUNK ? this.CHUNK : size - c;
7878
fs.readSync(newFd, data, 0, chunk);
79-
fs.writeSync(this.fd, data, 0, chunk);
79+
fs.writeSync(this.fd, data, 0, chunk, this.currentPosition);
8080
c += chunk;
8181
this.currentPosition += chunk;
8282
}

jssrc/webloader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
109109
var base = this.fileTable;
110110
if(this.tableLoaded) {
111111
if(path !== "/") {
112-
path = path.split("/").clean("");
112+
path = JPAK.Tools.cleanArray(path.split("/"), "");
113113
var dir = "", ok = true;
114114
for(var i=0;i<path.length;i++) {
115115
dir = path[i];
@@ -132,7 +132,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
132132
* Returns null if not found
133133
*/
134134
Loader.prototype.findFileEntry = function(path) {
135-
var pathblock = path.split("/").clean("");
135+
var pathblock = JPAK.Tools.cleanArray(path.split("/"), "");
136136
var filename = pathblock[pathblock.length-1];
137137
path = path.replace(filename,"");
138138
var base = this.findDirectoryEntry(path);

test/packtest.jpak

982 Bytes
Binary file not shown.

tools/extpacker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/nodejs
22

33
var fs = require("fs");
4-
var jpaktool = require("../dist/jpak.min").JPAK;
4+
var jpaktool = require("../dist/jpak").JPAK;
55
var fs = require("fs");
66
var path = require("path");
77

tools/packtest.jpak

-10.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)