public ZipDirectory zip_open(Env env, @NotNull StringValue filename) { if (filename == null || filename.length() == 0) { return(null); } BinaryStream s = FileModule.fopen(env, filename, "rb", false, null); if (s == null) { return(null); } return(new ZipDirectory((BinaryInput)s)); }
/** * Extracts the meta tags from a file and returns them as an array. */ public static Value get_meta_tags(Env env, StringValue filename, @Optional bool useIncludePath) { InputStream in = null; ArrayValue result = new ArrayValueImpl(); try { BinaryStream stream = FileModule.fopen(env, filename, "r", useIncludePath, null); if (stream == null || !(stream instanceof BinaryInput)) { return(result); } BinaryInput input = (BinaryInput)stream; while (!input.isEOF()) { string tag = getNextTag(input); if (tag.equalsIgnoreCase("meta")) { string name = null; string content = null; string [] attr; while ((attr = getNextAttribute(input)) != null) { if (name == null && attr[0].equalsIgnoreCase("name")) { if (attr.length > 1) { name = attr[1]; } } else if (content == null && attr[0].equalsIgnoreCase("content")) { if (attr.length > 1) { content = attr[1]; } } if (name != null && content != null) { result.put(env.createString(name), env.createString(content)); break; } } } else if (tag.equalsIgnoreCase("/head")) { break; } } } catch (IOException e) { env.warning(e); } finally { try { if (in != null) { in.close(); } } catch (IOException e) {