Skip to content

Commit

Permalink
Merge branch 'master' into t8
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaguiar authored Dec 5, 2023
2 parents 0df0e1e + 326faa2 commit c652c0c
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 129 deletions.
3 changes: 2 additions & 1 deletion js/owrap.format.js
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,8 @@ OpenWrap.format.prototype.syms = function() {
lCross : '╳',
patternLight : '░',
patternMedium: '▒',
patternDark : '▓'
patternDark : '▓',
blockH : '━'
}
}

Expand Down
41 changes: 41 additions & 0 deletions src/openaf/plugins/ZIP.java
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,47 @@ public void streamRemoveFile(String aFilePath, String name, boolean useTempFile)
}
}

/**
* <odoc>
* <key>ZIP.streamCreate(aFilePath)</key>
* Creates an empty ZIP file on aFilePath.
* </odoc>
*/
@JSFunction
public void streamCreate(String aFilePath) throws IOException {
ZIP z = new ZIP();
z.generate2File(aFilePath, null, true);
z.close();
}

/**
* <odoc>
* <key>ZIP.streamCreateFolder(aFilePath, aFolder) : boolean</key>
* Creates aFolder on aFilePath ZIP file. Returns true if the folder was created or false if it already existed.
* </odoc>
*/
@JSFunction
public boolean streamCreateFolder(String aFilePath, String aFolder) throws IOException {
URI uri = URI.create("jar:" + Paths.get(aFilePath).toUri());
Map<String, String> env = new HashMap<>();
env.put("create", "true");
FileSystem fs = null;
try {
fs = FileSystems.newFileSystem(uri, env);
Path nf = fs.getPath(aFolder);
if (Files.notExists(nf)) {
Files.createDirectory(nf);
return true;
} else {
return false;
}
} finally {
if (fs != null) {
fs.close();
}
}
}

/**
* <odoc>
* <key>ZIP.generate(aMapOfOptions, dontReload) : anArrayOfBytes</key>
Expand Down
Loading

0 comments on commit c652c0c

Please sign in to comment.