branch: externals/jarchive
commit 8c3c9fc24b62b553ee9d410bac9ca8193860f92c
Author: Danny Freeman <danny@dfreeman.email>
Commit: Danny Freeman <danny@dfreeman.email>

    Implement file-name-as-directory operation
    
    From bug report #2
    When calling
    
    (file-relative-name buffer-file-name "/some/directory")
    from a file opened with jarchive, file-relative-name is unable to build
    a path relative to another directory. file-name-as-directory is called
    repeatedly on the full `jar` or `zipfile` file URI, which always
    includes the scheme. The path is never relative to a directory, which
    keeps dwindling down the "/some/directory" -> "/some" -> "/" -> nil
    until an error is thrown trying to check if the dwindled down path of
    nil is a prefix of the full jar URI. This throws an exception. Having
    `file-name-as-directory` operate on the jar path doesn't quite return a
    correct answer (usually it returns `"."` in my testing), but the file in
    the jar can't really be relative to anything on the filesystem, since
    the jar acts like a remote file system with a separate file tree. This
    at least doesn't throw an error.
---
 jarchive.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/jarchive.el b/jarchive.el
index eabe1ffb59..73d8ae7715 100644
--- a/jarchive.el
+++ b/jarchive.el
@@ -94,6 +94,7 @@ primitive. See `(elisp)Magic File Names'."
           ((eq op 'file-attributes) nil)
           ((eq op 'make-auto-save-file-name) nil)
           ((eq op 'abbreviate-file-name) uri)
+          ((eq op 'file-name-as-directory) (file-name-as-directory jar-path))
 
           ;; Predicates
           ((eq op 'file-directory-p) nil)

Reply via email to