Arc Forumnew | comments | leaders | submitlogin
Missing filesystem functions
16 points by sjs 5899 days ago | 2 comments
Arc lacks many basic filesystem functions (mtime, mkdir, size, etc.) and it seems the only way to add them is via scheme. Without further ado:

    (xdef 'file-mv (lambda (src dst)
                     (rename-file-or-directory src dst)
                     'nil))
    
    (xdef 'file-cp (lambda (src dst)
                     (copy-file src dst)
                     'nil))
    
    (xdef 'file-mtime (lambda (path)
                        (file-or-directory-modify-seconds path)))
    
    (xdef 'file-perms (lambda (path)
                        (file-or-directory-permissions path)))
    
    (xdef 'file-size (lambda (path)
                       (file-size path)))
    
    (xdef 'pwd (lambda () (path->string (current-directory))))
    
    (xdef 'mkdir (lambda (path)
                   (make-directory path)
                   'nil))
    
    ;; there's no reason this couldn't be defined in arc, but better to
    ;; keep all these defs together (as such, take advantage of scheme)
    (xdef 'file-join (lambda (first . rest)
                       (path->string (apply build-path (cons first rest)))))
    
Throw that somewhere appropriate in ac.scm. I'm aware that these probably aren't all named perfectly. I think I prefer mtime to file-mtime, and mv and cp are probably better than file-mv and file-cp. Bike-shedding....


3 points by nex3 5899 days ago | link

I've added slightly modified versions of these to the Anarkies.

-----

3 points by ryantmulligan 5899 days ago | link

I agree with the shorter name point.

-----