Merge pull request #1 from edwinb/remove-directory-system

Add rmDir to System.Directory
This commit is contained in:
Edwin Brady 2020-05-19 12:24:35 +01:00 committed by GitHub
commit 6bbb914fca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View File

@ -266,6 +266,7 @@
(define Directory-System-prim_createDir (lambda (farg-0 farg-1) ((foreign-procedure #f "idris2_createDir" (string) int) farg-0)))
(define Directory-System-prim_closeDir (lambda (farg-0 farg-1) ((foreign-procedure #f "idris2_dirClose" (void*) void) farg-0) (vector 0 )))
(define Directory-System-prim_changeDir (lambda (farg-0 farg-1) ((foreign-procedure #f "idris2_changeDir" (string) int) farg-0)))
(define Directory-System-prim_rmDir (lambda (farg-0 farg-1) ((foreign-procedure #f "idris2_rmDir" (string) int) farg-0)))
(define Buffer-Data-stringByteLength (lambda (farg-0) ((foreign-procedure #f "strlen" (string) int) farg-0)))
(define Buffer-Data-prim__writeBuffer (lambda (farg-0 farg-1 farg-2 farg-3) (blodwen-write-bytevec farg-0 farg-1 farg-2)))
(define Buffer-Data-prim__setString (lambda (farg-0 farg-1 farg-2 farg-3) (blodwen-buffer-setstring farg-0 farg-1 farg-2)))

View File

@ -41,6 +41,9 @@ prim_openDir : String -> PrimIO DirPtr
%foreign support "idris2_dirClose"
prim_closeDir : DirPtr -> PrimIO ()
%foreign support "idris2_rmDir"
prim_rmDir : String -> PrimIO ()
%foreign support "idris2_nextDirEntry"
prim_dirEntry : DirPtr -> PrimIO (Ptr String)
@ -82,6 +85,10 @@ export
dirClose : Directory -> IO ()
dirClose (MkDir d) = primIO (prim_closeDir d)
export
rmDir : String -> IO ()
rmDir dirName = primIO (prim_rmDir dirName)
export
dirEntry : Directory -> IO (Either FileError String)
dirEntry (MkDir d)

View File

@ -49,6 +49,10 @@ void idris2_dirClose(void* d) {
free(di);
}
int idris2_rmDir(char* path) {
return rmdir(path);
}
char* idris2_nextDirEntry(void* d) {
DirInfo* di = (DirInfo*)d;
struct dirent* de = readdir(di->dirptr);