diff --git a/basis/io/files/listing/unix/unix.factor b/basis/io/files/listing/unix/unix.factor index 313ce1f79a..bef8d3dc56 100755 --- a/basis/io/files/listing/unix/unix.factor +++ b/basis/io/files/listing/unix/unix.factor @@ -3,7 +3,7 @@ USING: accessors combinators kernel system unicode.case io.unix.files io.files.listing generalizations strings arrays sequences io.files math.parser unix.groups unix.users -io.files.listing.private ; +io.files.listing.private unix.stat math ; IN: io.files.listing.unix string ] } cleave 10 narray concat ; +: mode>symbol ( mode -- ch ) + S_IFMT bitand + { + { [ dup S_IFDIR = ] [ drop "/" ] } + { [ dup S_IFIFO = ] [ drop "|" ] } + { [ dup any-execute? ] [ drop "*" ] } + { [ dup S_IFLNK = ] [ drop "@" ] } + { [ dup S_IFWHT = ] [ drop "%" ] } + { [ dup S_IFSOCK = ] [ drop "=" ] } + { [ t ] [ drop "" ] } + } cond ; + M: unix (directory.) ( path -- lines ) [ [ [ diff --git a/basis/io/unix/files/files.factor b/basis/io/unix/files/files.factor index 98206bc992..ad5c192a39 100644 --- a/basis/io/unix/files/files.factor +++ b/basis/io/unix/files/files.factor @@ -6,7 +6,8 @@ math.bitwise byte-arrays alien combinators calendar io.encodings.binary accessors sequences strings system io.files.private destructors vocabs.loader calendar.unix unix.stat alien.c-types arrays unix.users unix.groups -environment fry io.encodings.utf8 alien.strings unix.statfs ; +environment fry io.encodings.utf8 alien.strings unix.statfs +combinators.short-circuit ; IN: io.unix.files M: unix cwd ( -- path ) @@ -228,6 +229,15 @@ GENERIC: other-read? ( obj -- ? ) GENERIC: other-write? ( obj -- ? ) GENERIC: other-execute? ( obj -- ? ) +: any-read? ( obj -- ? ) + { [ user-read? ] [ group-read? ] [ other-read? ] } 1|| ; + +: any-write? ( obj -- ? ) + { [ user-write? ] [ group-write? ] [ other-write? ] } 1|| ; + +: any-execute? ( obj -- ? ) + { [ user-execute? ] [ group-execute? ] [ other-execute? ] } 1|| ; + M: integer uid? ( integer -- ? ) UID mask? ; M: integer gid? ( integer -- ? ) GID mask? ; M: integer sticky? ( integer -- ? ) STICKY mask? ; diff --git a/basis/unix/stat/stat.factor b/basis/unix/stat/stat.factor index 17d6604fc0..a3b0ed11b7 100644 --- a/basis/unix/stat/stat.factor +++ b/basis/unix/stat/stat.factor @@ -13,6 +13,7 @@ IN: unix.stat : S_IFIFO OCT: 010000 ; inline ! FIFO. : S_IFLNK OCT: 120000 ; inline ! Symbolic link. : S_IFSOCK OCT: 140000 ; inline ! Socket. +: S_IFWHT OCT: 160000 ; inline ! Whiteout. FUNCTION: int chmod ( char* path, mode_t mode ) ; FUNCTION: int fchmod ( int fd, mode_t mode ) ;