# Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license # found at http://www.opensource.org/licenses/mit-license.html ................ root ? # value: ? .getPath() # value: "/" a directory ? def home := [interp.getProps()["e.home"]]; null a file in the directory ? def runeScriptFile := home["clrune"]; null check print ? def `` := E.toQuote(runeScriptFile); null ? runeScriptFile.getPath().replaceAll(homeFragment, "") # value: "//clrune" ? runeScriptFile.getPlatformPath().replaceAll(homeFragment, "") # value: "//clrune" ? runeScriptFile.getName() # value: "clrune" ? runeScriptFile.getTwine().split("\n")[0] # value: "#!/bin/bash" ? E.toQuote(runeScriptFile.getTwine().split("\n")[0].getOptSpan()).replaceAll(homeFragment, "") # value: "/clrune#:span::1:0::1:10>" directory listing ? for name ? (name !~ `.@_`) => subfile in home["jlib"] { > println(`$name ${E.toQuote(subfile).replaceAll(homeFragment, "")}`) } # stdout: parseEToSExpression.emaker /jlib/parseEToSExpression.emaker> # exists and getOpt ? home.exists() # value: true ? runeScriptFile.exists() # value: true ? home["nonexistent"].exists() # value: false ? home.getOpt("clrune").getPath() == runeScriptFile.getPath() # value: true ? [home.getOpt("nonexistent")] # value: [null] readOnly ? def droHome := home.deepReadOnly(); null ? def sroHome := home.shallowReadOnly(); null x ? E.toQuote(droHome).replaceAll(homeFragment, "") x # value: ">.deepReadOnly()" ? droHome.exists() # value: true ? sroHome.exists() # value: true ? droHome.__respondsTo("setText", 1) # value: false ? sroHome.__respondsTo("setText", 1) # value: false ? droHome.getPath() == home.getPath() # value: true ? sroHome.getPath() == home.getPath() # value: true ? droHome.getPlatformPath() == home.getPlatformPath() # value: true ? sroHome.getPlatformPath() == home.getPlatformPath() # value: true ? droHome.getName() == home.getName() # value: true ? sroHome.getName() == home.getName() # value: true ? droHome.deepReadOnly() == droHome # value: true ? sroHome.deepReadOnly() == sroHome # value: true ? droHome.shallowReadOnly() == droHome # value: true ? sroHome.shallowReadOnly() == sroHome # value: true ? sroHome.deepReadOnly() == droHome # value: false XXX test getting subdirs of readonly file, and deep vs. shallow writability distinction createNewFile, setText safety: if this file does not exist, the rest cannot access it because the variable isn't bound ' ? def writable ? !writable.exists() := home[`fileAccessTestFile-${timer.now()}`]; null ? [writable.createNewFile(null), writable.exists(), writable.getText()] # value: [null, true, ""] ? writable.setText("hi") ? writable.getText() # value: "hi" ? writable.delete(null) ? writable.exists() # value: false ? writable.setText("bye") ? writable.getText() # value: "bye" ? writable.delete(null) XXX all file operations all dir operations path construction is independent of current filesystem state deepReadOnly is properly transitive and shallowReadOnly isn't