]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/unix/unix.factor
basis: use lint.vocabs tool to trim using lists
[factor.git] / basis / unix / unix.factor
index 0fb4de728de93290d3ca791b5a9b7511b05a322b..2d09096451db447bb591a23b054cbf03a57afda0 100644 (file)
@@ -1,12 +1,10 @@
 ! Copyright (C) 2005, 2010 Slava Pestov.
 ! Copyright (C) 2008 Eduardo Cavazos.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien alien.c-types alien.libraries
-alien.syntax byte-vectors classes.struct combinators
-combinators.short-circuit combinators.smart continuations
-generalizations io kernel libc locals macros math namespaces
-sequences sequences.generalizations stack-checker strings system
-unix.time unix.types vocabs vocabs.loader unix.ffi ;
+USING: accessors alien.c-types alien.syntax byte-arrays
+combinators.short-circuit combinators.smart generalizations kernel
+libc math sequences sequences.generalizations strings system
+unix.ffi vocabs.loader ;
 IN: unix
 
 ERROR: unix-system-call-error args errno message word ;
@@ -64,7 +62,7 @@ HOOK: open-file os ( path flags mode -- fd )
 
 : close-file ( fd -- ) [ close ] unix-system-call-allow-eintr drop ;
 
-FUNCTION: int _exit ( int status ) ;
+FUNCTION: int _exit ( int status )
 
 M: unix open-file [ open ] unix-system-call ;
 
@@ -75,21 +73,20 @@ M: unix open-file [ open ] unix-system-call ;
 : touch ( filename -- ) f [ utime ] unix-system-call drop ;
 
 : change-file-times ( filename access modification -- )
-    utimbuf <struct>
+    utimbuf new
         swap >>modtime
         swap >>actime
         [ utime ] unix-system-call drop ;
 
+: (read-symbolic-link) ( path bufsiz -- path' )
+    dup <byte-array> 3dup swap [ readlink ] unix-system-call
+    pick dupd < [ head >string 2nip ] [
+        2nip 2 * (read-symbolic-link)
+    ] if ;
+
 : read-symbolic-link ( path -- path )
-    PATH_MAX <byte-vector> [
-        underlying>> PATH_MAX
-        [ readlink ] unix-system-call
-    ] keep swap >>length >string ;
+    4096 (read-symbolic-link) ;
 
 : unlink-file ( path -- ) [ unlink ] unix-system-call drop ;
 
-<<
-
 { "unix" "debugger" } "unix.debugger" require-when
-
->>