about summary refs log tree commit diff
path: root/third_party
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2024-04-03T13·55+0200
committerclbot <clbot@tvl.fyi>2024-04-05T11·01+0000
commit5262e5bf6cb788a94376be95981a77dcd9a1b89a (patch)
tree4a1680099948e2b0b0b4fcfa3b3c8afb0f4deefd /third_party
parentd13b0791c58a43519d3c60c1bad449c20f65e67c (diff)
refactor(3p/mime4cl): use SB-POSIX for FILE-LENGTH r/7854
This is slightly better than the (mostly untested) mess we had before:
Just implement the one thing we need using the tools the one
implementation we support (SBCL) gives us.

Eventually, we'll want to make this portable, probably using osicat.
Unfortunately, packaging this requires support for cffi-grovel (b/383)
which buildLisp lacks at the moment.

Change-Id: I6960015f80e6a5dfde67baf55537c5274a19e4e2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11356
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Autosubmit: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'third_party')
-rw-r--r--third_party/lisp/mime4cl/default.nix1
-rw-r--r--third_party/lisp/mime4cl/ex-sclf.lisp47
2 files changed, 5 insertions, 43 deletions
diff --git a/third_party/lisp/mime4cl/default.nix b/third_party/lisp/mime4cl/default.nix
index 99b23c91aa69..af015a257bf2 100644
--- a/third_party/lisp/mime4cl/default.nix
+++ b/third_party/lisp/mime4cl/default.nix
@@ -10,6 +10,7 @@ depot.nix.buildLisp.library {
     depot.third_party.lisp.npg
     depot.third_party.lisp.trivial-gray-streams
     depot.third_party.lisp.qbase64
+    { sbcl = depot.nix.buildLisp.bundled "sb-posix"; }
   ];
 
   srcs = [
diff --git a/third_party/lisp/mime4cl/ex-sclf.lisp b/third_party/lisp/mime4cl/ex-sclf.lisp
index 7951b44f4d0f..1719732fb3d5 100644
--- a/third_party/lisp/mime4cl/ex-sclf.lisp
+++ b/third_party/lisp/mime4cl/ex-sclf.lisp
@@ -32,6 +32,8 @@
 
 (defpackage :mime4cl-ex-sclf
   (:use :common-lisp)
+  (:import-from :sb-posix :stat :stat-size)
+
   (:export
    #:aif
    #:awhen
@@ -62,8 +64,6 @@
    #:save-file-excursion
    #:read-file
 
-   #:unix-file-stat
-   #:unix-stat
    #:file-size
 
    #:promise
@@ -275,51 +275,12 @@ ELEMENT-TYPE."
   #-sbcl (let (#+cmu (lisp::*ignore-wildcards* t))
            (namestring pathname)))
 
-(defstruct (unix-file-stat (:conc-name stat-))
-  device
-  inode
-  links
-  atime
-  mtime
-  ctime
-  size
-  blksize
-  blocks
-  uid
-  gid
-  mode)
-
-(defun unix-stat (pathname)
-  ;; this could be different depending on the unix systems
-  (multiple-value-bind (ok? device inode mode links uid gid rdev
-                            size atime mtime ctime
-                            blksize blocks)
-      (#+cmu unix:unix-lstat
-       #+sbcl sb-unix:unix-lstat
-       ;; TODO(sterni): ECL, CCL
-       (if (stringp pathname)
-           pathname
-           (native-namestring pathname)))
-    (declare (ignore rdev))
-    (when ok?
-      (make-unix-file-stat :device device
-                           :inode inode
-                           :links links
-                           :atime atime
-                           :mtime mtime
-                           :ctime ctime
-                           :size size
-                           :blksize blksize
-                           :blocks blocks
-                           :uid uid
-                           :gid gid
-                           :mode mode))))
-
 ;; FILE-LENGTH is a bit idiosyncratic in this respect.  Besides, Unix
 ;; allows to get to know the file size without being able to open a
 ;; file; just ask politely.
 (defun file-size (pathname)
-  (stat-size (unix-stat pathname)))
+  #+sbcl (stat-size (unix-stat pathname))
+  #-sbcl (error "nyi"))
 
 ;; LAZY