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

Add mkdir() function #1219

Closed
p6rt opened this issue Aug 11, 2009 · 4 comments
Closed

Add mkdir() function #1219

p6rt opened this issue Aug 11, 2009 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Aug 11, 2009

Migrated from rt.perl.org#68402 (status was 'resolved')

Searchable as RT68402$

@p6rt
Copy link
Author

p6rt commented Aug 11, 2009

From @carbin

This is a basic patch to add a mkdir function. The (optional) mode
parameter uses the octal radix markers as in S02 (eg. 0o777, 0o755
etc.) It defaults to 0o777 to mirror Perl 5's behaviour.

Let me know if there is anything wrong with this or something that I
have missed.

Thanks.

--
Carlin

@p6rt
Copy link
Author

p6rt commented Aug 11, 2009

From @carbin

0001-Add-mkdir-method.patch
From e108c3a56d172d05cea79ad9a79c81edb26c289c Mon Sep 17 00:00:00 2001
From: carlin <carlin-public@theintersect.org>
Date: Tue, 11 Aug 2009 02:27:58 +1200
Subject: [PATCH] Add mkdir() method

Error handling fix
---
 src/builtins/io.pir |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/builtins/io.pir b/src/builtins/io.pir
index 77fd0b5..7efa108 100644
--- a/src/builtins/io.pir
+++ b/src/builtins/io.pir
@@ -174,6 +174,29 @@ true value is returned.
     .tailcall '!FAIL'('Unable to change to directory "', newdir, '"')
 .end
 
+.sub 'mkdir'
+    .param string dirname
+    .param int dirmode :optional
+
+    if dirmode goto make
+    # Be permissive by default, as per reasoning in perldoc -f mkdir
+    dirmode = 0o777
+
+  make:
+    .local pmc os
+    os = root_new ['parrot';'OS']
+    push_eh failure
+    os.'mkdir'(dirname,dirmode)
+    pop_eh
+    $P0 = get_hll_global ['Bool'], 'True'
+    .return ($P0)
+
+  failure:
+    pop_eh
+    .tailcall '!FAIL'('Unable to create directory "', dirname, '"')
+.end
+
+
 =back
 
 =cut
-- 
1.6.0.4

@p6rt
Copy link
Author

p6rt commented Oct 22, 2009

From @carbin

Seems this was done in c4e6d0fa19bec03b7417b5ba743aefb18e6fcdad using a
different (well, not really all that different) patch.

@p6rt
Copy link
Author

p6rt commented Oct 22, 2009

@carbin - Status changed from 'new' to 'resolved'

@p6rt p6rt closed this as completed Oct 22, 2009
@p6rt p6rt added the patch label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant