]> gitweb.factorcode.org Git - factor.git/commitdiff
unix.xattrs: Add basic support for xaddrs on macOS
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 1 Apr 2021 03:13:02 +0000 (22:13 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 1 Apr 2021 03:19:15 +0000 (22:19 -0500)
basis/unix/ffi/macosx/macosx.factor
basis/unix/xattrs/macos/authors.txt [new file with mode: 0644]
basis/unix/xattrs/macos/macos.factor [new file with mode: 0644]
basis/unix/xattrs/macos/platforms.txt [new file with mode: 0644]

index 12847acc3f69043dccc89e3b91ea20f0a7996d0e..ac37f5a00f56583e61b21561a6525797b43bf0c4 100644 (file)
@@ -139,3 +139,24 @@ STRUCT: sf_hdtr
     { trl_cnt int } ;
 
 FUNCTION: int sendfile ( int fd, int s, off_t offset, off_t* len, sf_hdtr* hdtr, int flags )
+
+CONSTANT: XATTR_NOFOLLOW        0x0001
+CONSTANT: XATTR_CREATE          0x0002
+CONSTANT: XATTR_REPLACE         0x0004
+CONSTANT: XATTR_NOSECURITY      0x0008
+CONSTANT: XATTR_NODEFAULT       0x0010
+CONSTANT: XATTR_SHOWCOMPRESSION 0x0020
+
+CONSTANT: XATTR_MAXNAMELEN 127
+CONSTANT: XATTR_FINDERINFO_NAME   "com.apple.FinderInfo"
+CONSTANT: XATTR_RESOURCEFORK_NAME "com.apple.ResourceFork"
+CONSTANT: XATTR_MAXSIZE 67108864 ! 64 * 1024 * 1024
+
+FUNCTION: ssize_t getxattr ( c-string path, c-string name, void *value, size_t size, u_int32_t position, int options )
+FUNCTION: ssize_t fgetxattr ( int fd, c-string name, void *value, size_t size, u_int32_t position, int options )
+FUNCTION: int setxattr ( c-string path, c-string name, void *value, size_t size, u_int32_t position, int options )
+FUNCTION: int fsetxattr ( int fd, c-string name, void *value, size_t size, u_int32_t position, int options )
+FUNCTION: int removexattr ( c-string path, c-string name, int options )
+FUNCTION: int fremovexattr ( int fd, c-string name, int options )
+FUNCTION: ssize_t listxattr ( c-string path, c-string namebuf, size_t size, int options )
+FUNCTION: ssize_t flistxattr ( int fd, c-string namebuf, size_t size, int options )
diff --git a/basis/unix/xattrs/macos/authors.txt b/basis/unix/xattrs/macos/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/basis/unix/xattrs/macos/macos.factor b/basis/unix/xattrs/macos/macos.factor
new file mode 100644 (file)
index 0000000..cf5f8dc
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2021 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: byte-arrays continuations kernel libc literals retries
+sequences strings unix.ffi ;
+IN: unix.xattrs.macos
+
+: list-xattrs-impl ( path size flags -- string )
+    [ [ <byte-array> ] [ ] bi ] dip
+    [ listxattr dup io-error ] 3keep 2drop swap head >string ;
+
+: list-xattrs ( path flags -- out )
+    '[ _ _ swapd list-xattrs-impl ]
+    ${ 512 16384 XATTR_MAXSIZE } <immediate> retries ;
diff --git a/basis/unix/xattrs/macos/platforms.txt b/basis/unix/xattrs/macos/platforms.txt
new file mode 100644 (file)
index 0000000..6e806f4
--- /dev/null
@@ -0,0 +1 @@
+macosx