aboutsummaryrefslogtreecommitdiff
path: root/lib/zipfile.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/zipfile.js')
-rw-r--r--lib/zipfile.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/zipfile.js b/lib/zipfile.js
index 7c534c7..ae51310 100644
--- a/lib/zipfile.js
+++ b/lib/zipfile.js
@@ -3,6 +3,8 @@ var JSZip = require("jszip");
var promises = require("./promises");
exports.openArrayBuffer = openArrayBuffer;
+exports.splitPath = splitPath;
+exports.joinPath = joinPath;
function openArrayBuffer(arrayBuffer) {
var zipFile = new JSZip(arrayBuffer);
@@ -35,3 +37,21 @@ function openArrayBuffer(arrayBuffer) {
toBuffer: toBuffer
};
}
+
+function splitPath(path) {
+ var lastIndex = path.lastIndexOf("/");
+ if (lastIndex === -1) {
+ return {dirname: "", basename: path};
+ } else {
+ return {
+ dirname: path.substring(0, lastIndex),
+ basename: path.substring(lastIndex + 1)
+ };
+ }
+}
+
+function joinPath() {
+ return Array.prototype.filter.call(arguments, function(path) {
+ return path;
+ }).join("/");
+}