]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/windows/privileges/privileges.factor
factor: trim using lists
[factor.git] / basis / windows / privileges / privileges.factor
index ed2827ed8a8428efafe87f0c5baac9b7e822128f..32ad96a42cfcaa38ed64f0b6d64a01a5fd645ccf 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2010 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.data alien.syntax classes.struct
-continuations fry kernel libc literals locals sequences
-windows.advapi32 windows.errors windows.kernel32 windows.types ;
+continuations kernel libc literals sequences windows.advapi32
+windows.errors windows.kernel32 windows.types ;
 IN: windows.privileges
 
 TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES
@@ -17,21 +17,21 @@ TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES
     with-out-parameters ;
 
 : open-process-token ( -- handle )
-    #! remember to CloseHandle
+    ! remember to CloseHandle
     GetCurrentProcess (open-process-token) ;
 
 : with-process-token ( quot -- )
-    #! quot: ( token-handle -- token-handle )
+    ! quot: ( token-handle -- token-handle )
     [ open-process-token ] dip
     [ keep ] curry
-    [ CloseHandle drop ] [ ] cleanup ; inline
+    [ CloseHandle drop ] finally ; inline
 
 : lookup-privilege ( string -- luid )
-    [ f ] dip LUID <struct>
+    [ f ] dip LUID new
     [ LookupPrivilegeValue win32-error=0/f ] keep ;
 
 :: make-token-privileges ( name enabled? -- obj )
-    TOKEN_PRIVILEGES <struct>
+    TOKEN_PRIVILEGES new
         1 >>PrivilegeCount
         LUID_AND_ATTRIBUTES malloc-struct &free
             enabled? [ SE_PRIVILEGE_ENABLED >>Attributes ] when
@@ -51,4 +51,4 @@ TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES
 : with-privileges ( seq quot -- )
     [ '[ _ [ t set-privilege ] each @ ] ]
     [ drop '[ _ [ f set-privilege ] each ] ]
-    2bi [ ] cleanup ; inline
+    2bi finally ; inline