/lib/files.arc

http://github.com/alimoeeny/arc · Unknown · 42 lines · 34 code · 8 blank · 0 comment · 0 complexity · 1be2edb2bc19b09dbe013bc29d235126 MD5 · raw file

  1. (def mv (src dst)
  2. " Moves the file or directory `src' to `dst'. "
  3. ($.rename-file-or-directory src dst)
  4. nil)
  5. (def cp (src dst)
  6. " Copies the file `src' to `dst'. "
  7. ($.copy-file src dst)
  8. nil)
  9. (def mtime (path)
  10. " Returns the modification time of the file or directory `path' in
  11. seconds since the epoch. "
  12. ($.file-or-directory-modify-seconds path))
  13. (def file-perms (path)
  14. " Returns a list of the effective file permssions of `path'. "
  15. ($.file-or-directory-permissions path))
  16. (def file-size (path)
  17. " Returns the size, in bytes, of a file `path'. "
  18. ($.file-size path))
  19. (def cd (path)
  20. " Changes the current directory. "
  21. ($.current-directory path)
  22. (pwd))
  23. (def pwd ()
  24. " Returns the current directory. "
  25. ($ (path->string (current-directory))))
  26. ; This could be defined in pure Arc, but we don't really have a good way of
  27. ; testing whether or not we should use Windows path separators,
  28. ; so we'll leave it up to Scheme.
  29. (def file-join parts
  30. " Joins `parts' into a path string. "
  31. ($.path->string (apply $.build-path parts)))
  32. (def qualified-path (path)
  33. " Returns the fully-qualified path of a possibly relative `path'. "
  34. ($ (path->string (simplify-path (path->complete-path ,path)))))