-
Notifications
You must be signed in to change notification settings - Fork 54
/
posix.rmdir.m
51 lines (41 loc) · 1.61 KB
/
posix.rmdir.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
%-----------------------------------------------------------------------------%
% vim: ft=mercury ts=4 sw=4 et
%-----------------------------------------------------------------------------%
% Copyright (C) 2001, 2007 The University of Melbourne.
% Copyright (C) 2018-2019 The Mercury team.
% This file is distributed under the terms specified in COPYING.LIB.
%-----------------------------------------------------------------------------%
%
% Module: posix.rmdir.
% Main author: Michael Day <miked@lendtech.com.au>
%
%------------------------------------------------------------------------------%
:- module posix.rmdir.
:- interface.
:- import_module string.
:- pred rmdir(string::in, posix.result::out, io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
:- implementation.
:- pragma foreign_decl("C", "
#include <unistd.h>
").
%-----------------------------------------------------------------------------%
rmdir(Path, Result, !IO) :-
rmdir0(Path, Res, !IO),
( if Res = 0 then
Result = ok
else
errno(Err, !IO),
Result = error(Err)
).
:- pred rmdir0(string::in, int::out, io::di, io::uo) is det.
:- pragma foreign_proc("C",
rmdir0(Path::in, Res::out, _IO0::di, _IO::uo),
[promise_pure, will_not_call_mercury, thread_safe, tabled_for_io],
"
Res = rmdir(Path);
").
%-----------------------------------------------------------------------------%
:- end_module posix.rmdir.
%-----------------------------------------------------------------------------%