Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
f8fab095
Commit
f8fab095
authored
1 year ago
by
Andre Maroneze
Browse files
Options
Downloads
Patches
Plain Diff
[Extlib] change return type and behavior of mkdir
parent
3795e146
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/libraries/stdlib/extlib.ml
+21
-11
21 additions, 11 deletions
src/libraries/stdlib/extlib.ml
src/libraries/stdlib/extlib.mli
+7
-2
7 additions, 2 deletions
src/libraries/stdlib/extlib.mli
with
28 additions
and
13 deletions
src/libraries/stdlib/extlib.ml
+
21
−
11
View file @
f8fab095
...
...
@@ -233,17 +233,27 @@ external address_of_value: 'a -> int = "address_of_value" [@@noalloc]
hence interrupting the process, might not work: child processes still need to
run some daemons, such as [flush_all] which is registered by default. *)
let
rec
mkdir
?
(
parents
=
false
)
name
perm
=
try
Unix
.
mkdir
name
perm
with
|
Unix
.
Unix_error
(
Unix
.
ENOENT
,_,_
)
when
parents
->
let
parent_name
=
Filename
.
dirname
name
in
if
name
<>
parent_name
then
begin
mkdir
~
parents
parent_name
perm
;
Unix
.
mkdir
name
perm
end
|
e
->
raise
e
let
rec
mkdir
?
(
parents
=
false
)
(
name
:
Filepath
.
Normalized
.
t
)
perm
=
if
Filepath
.
exists
name
then
if
not
(
Filepath
.
is_dir
name
)
then
failwith
(
Format
.
asprintf
"mkdir: %a exists but is not a directory"
Filepath
.
Normalized
.
pretty
name
)
else
false
else
begin
begin
try
Unix
.
mkdir
(
name
:>
string
)
perm
with
|
Unix
.
Unix_error
(
Unix
.
ENOENT
,_,_
)
when
parents
->
let
parent_name
=
Filepath
.
dirname
name
in
if
name
<>
parent_name
then
begin
ignore
(
mkdir
~
parents
parent_name
perm
);
Unix
.
mkdir
(
name
:>
string
)
perm
end
|
e
->
raise
e
end
;
true
end
let
pid
=
Unix
.
getpid
()
let
safe_at_exit
f
=
...
...
This diff is collapsed.
Click to expand it.
src/libraries/stdlib/extlib.mli
+
7
−
2
View file @
f8fab095
...
...
@@ -256,7 +256,7 @@ external address_of_value: 'a -> int = "address_of_value" [@@noalloc]
(** {2 System commands} *)
(* ************************************************************************* *)
val
mkdir
:
?
parents
:
bool
->
string
->
Unix
.
file_perm
->
unit
val
mkdir
:
?
parents
:
bool
->
Filepath
.
Normalized
.
t
->
Unix
.
file_perm
->
bool
(** [mkdir ?parents name perm] creates directory [name] with permission
[perm]. If [parents] is true, recursively create parent directories
if needed. [parents] defaults to false.
...
...
@@ -264,8 +264,13 @@ val mkdir : ?parents:bool -> string -> Unix.file_perm -> unit
and then fail to create the children, e.g. if [perm] does not allow
user execution of the created directory. This will leave the filesystem
in a modified state before raising an exception.
Returns [true] if the directory was created, [false] otherwise.
@raise Unix.Unix_error if cannot create [name] or its parents.
@since 19.0-Potassium *)
@since 19.0-Potassium
@since Frama-C+dev added check for existence of path (error if exists
but not a directory, otherwise do nothing if directory already exists).
Changed type of [name] argument and return type.
*)
val
safe_at_exit
:
(
unit
->
unit
)
->
unit
(** Register function to call with [Stdlib.at_exit], but only
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment