Skip to content

Commit 24aed0b

Browse files
committed
Merge pull request #29 from TeskeVirtualSystem/DeltaRead
Partial Load of files inside JPAK
2 parents a591782 + 59ec2e3 commit 24aed0b

3 files changed

Lines changed: 43 additions & 19 deletions

File tree

dist/jpak.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,12 +2953,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29532953
return def.promise;
29542954
};
29552955

2956-
Loader.prototype.getFileArrayBuffer = function(path, type) {
2956+
Loader.prototype.getFileArrayBuffer = function(path, type, offset, len) {
29572957
var def = Q.defer();
29582958

29592959
switch (this.jpakType) {
2960-
case "JPAK1": return this._p_jpak1_getFile(path, type);
2961-
case "JMS": return this._p_jms1_getFile(path, type);
2960+
case "JPAK1": return this._p_jpak1_getFile(path, type, offset, len);
2961+
case "JMS": return this._p_jms1_getFile(path, type, offset, len);
29622962
default: def.reject("Not a valid jpak file!");
29632963
}
29642964

@@ -3058,16 +3058,22 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30583058
});
30593059
};
30603060

3061-
Loader.prototype._p_jpak1_getFile = function(path, type) {
3061+
Loader.prototype._p_jpak1_getFile = function(path, type, offset, len) {
30623062
var def = Q.defer();
30633063
var file = this.findFileEntry(path);
30643064
type = type || 'application/octet-binary';
30653065

3066+
if (file === null || file === undefined)
3067+
def.reject("File does not exists!");
3068+
3069+
offset = offset || 0;
3070+
len = len || file.size;
3071+
30663072
var fileLoader = new JPAK.Tools.DataLoader({
30673073
url: this.jpakfile,
30683074
partial: true,
3069-
partialFrom: file.offset,
3070-
partialTo: file.offset + file.size -1
3075+
partialFrom: file.offset + offset,
3076+
partialTo: file.offset + len -1
30713077
});
30723078

30733079
fileLoader.start().then(function(data) {
@@ -3139,18 +3145,24 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31393145
});
31403146
};
31413147

3142-
Loader.prototype._p_jms1_getFile = function(path, type) {
3148+
Loader.prototype._p_jms1_getFile = function(path, type, offset, len) {
31433149
var def = Q.defer();
31443150
var file = this.findFileEntry(path);
31453151
type = type || 'application/octet-binary';
31463152

3153+
offset = offset || 0;
3154+
len = len || file.size;
3155+
3156+
if (file === null || file === undefined)
3157+
def.reject("File does not exists!");
3158+
31473159
if (file.volume in this.volumeTable) {
31483160
var volumePath = this.volumeTable[file.volume].filename;
31493161
var fileLoader = new JPAK.Tools.DataLoader({
31503162
url: volumePath,
31513163
partial: true,
3152-
partialFrom: file.offset,
3153-
partialTo: file.offset + file.size -1
3164+
partialFrom: file.offset + offset,
3165+
partialTo: file.offset + len -1
31543166
});
31553167

31563168
fileLoader.start().then(function(data) {

0 commit comments

Comments
 (0)