Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature: creating a directory tree #1367

Open
wants to merge 3 commits into
base: horizon
Choose a base branch
from
Open

Conversation

blerner
Copy link
Member

@blerner blerner commented Jul 6, 2018

Implements a new method create-dir-tree, which is like mkdir -p but enhanced. Given a base directory, and a string-dict of string-dicts of ..., where the innermost string-dicts' values are irrelevant, build a directory tree whose nesting structure corresponds to the keys of the string-dicts.

@shriram
Copy link
Member

shriram commented Jul 6, 2018

WHOA.

What does this do in the browser?

@blerner
Copy link
Member Author

blerner commented Jul 6, 2018

Nothing -- it's in the filelib module, which isn't made available on CPO.

if (isISD(tree)) {
RUNTIME.ffi.toArray(RUNTIME.getField(tree, "keys-list").app()).forEach(function(sub) {
var kid = RUNTIME.getColonField(tree, "get-value").full_meth(tree, sub);
makeDirs(baseDir + "/" + sub, kid);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be more judicious about using path.join or whatever the blessed path library thing is? I know we have other windows issues but that's probably the right thing to do.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't tell, tbh: https://nodejs.org/docs/latest/api/fs.html#fsmkdirpath-options-callback gives an example of calling mkdir on "/" even on Windows...

if (!fs.existsSync(baseDir)) fs.mkdirSync(baseDir);
if (isISD(tree)) {
RUNTIME.ffi.toArray(RUNTIME.getField(tree, "keys-list").app()).forEach(function(sub) {
var kid = RUNTIME.getColonField(tree, "get-value").full_meth(tree, sub);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth a comment that this won't stack capture because of what we know about immutable-string-dict's get-value method being flat? Like if this was changed to a generic .get-value dictionary interface, this wouldn't be safe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, possibly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants