]> gitweb.factorcode.org Git - factor.git/commitdiff
Revert "io.files.trash: change unix to linux for now"
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 25 Jan 2022 17:49:01 +0000 (09:49 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 25 Jan 2022 17:49:01 +0000 (09:49 -0800)
This reverts commit 0e0aa69839ae09b8e8a63d198972ed5e2891f070.

extra/io/files/trash/linux/linux.factor [deleted file]
extra/io/files/trash/linux/platforms.txt [deleted file]
extra/io/files/trash/trash.factor
extra/io/files/trash/unix/platforms.txt [new file with mode: 0644]
extra/io/files/trash/unix/unix.factor [new file with mode: 0644]

diff --git a/extra/io/files/trash/linux/linux.factor b/extra/io/files/trash/linux/linux.factor
deleted file mode 100644 (file)
index feb047c..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-! Copyright (C) 2010 John Benediktsson
-! See http://factorcode.org/license.txt for BSD license
-
-USING: accessors calendar combinators.short-circuit formatting
-io io.backend io.directories io.encodings.utf8 io.files
-io.files.info io.files.info.unix io.files.trash io.pathnames
-kernel math math.parser sequences system unix.stat unix.users
-xdg ;
-
-IN: io.files.trash.linux
-
-! Implements the FreeDesktop.org Trash Specification 0.7
-
-<PRIVATE
-
-: top-directory? ( path -- ? )
-    dup ".." append-path [ link-status ] bi@
-    [ [ st_dev>> ] same? not ] [ [ st_ino>> ] same? ] 2bi or ;
-
-: top-directory ( path -- path' )
-    [ dup top-directory? not ] [ ".." append-path ] while ;
-
-: make-user-directory ( path -- )
-    [ make-directories ] [ 0o700 set-file-permissions ] bi ;
-
-: check-trash-path ( path -- )
-    {
-        [ file-info directory? ]
-        [ sticky? ]
-        [ link-info symbolic-link? not ]
-    } 1&& [ "invalid trash path" throw ] unless ;
-
-: trash-home ( -- path )
-    xdg-data-home "Trash" append-path dup check-trash-path ;
-
-: trash-1 ( root -- path )
-    ".Trash" append-path dup check-trash-path
-    real-user-id number>string append-path ;
-
-: trash-2 ( root -- path )
-    real-user-id ".Trash-%d" sprintf append-path ;
-
-: trash-path ( path -- path' )
-    top-directory dup trash-home top-directory = [
-        drop trash-home
-    ] [
-        dup ".Trash" append-path file-exists?
-        [ trash-1 ] [ trash-2 ] if
-        [ make-user-directory ] keep
-    ] if ;
-
-: (safe-file-name) ( path counter -- path' )
-    [
-        [ parent-directory ]
-        [ file-stem ]
-        [ file-extension dup [ "." prepend ] when ] tri
-    ] dip swap "%s%s %s%s" sprintf ;
-
-: safe-file-name ( path -- path' )
-    dup 0 [ over file-exists? ] [
-        [ parent-directory to-directory ] [ 1 + ] bi*
-        [ (safe-file-name) ] keep
-    ] while drop nip ;
-
-PRIVATE>
-
-M: unix send-to-trash ( path -- )
-    normalize-path dup trash-path [
-        "files" append-path [ make-user-directory ] keep
-        to-directory safe-file-name
-    ] [
-        "info" append-path [ make-user-directory ] keep
-        to-directory ".trashinfo" append overd utf8 [
-            "[Trash Info]" write nl
-            "Path=" write write nl
-            "DeletionDate=" write
-            now "%Y-%m-%dT%H:%M:%S" strftime write nl
-        ] with-file-writer
-    ] bi move-file ;
diff --git a/extra/io/files/trash/linux/platforms.txt b/extra/io/files/trash/linux/platforms.txt
deleted file mode 100644 (file)
index 509143d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-unix
index ad1e1de6c0e70f673eb9144b82ccdbee1bb7f192..95e729106fc866df1c7980a09710fb20623524a5 100644 (file)
@@ -10,5 +10,5 @@ HOOK: send-to-trash os ( path -- )
 {
     { [ os windows? ] [ "io.files.trash.windows" ] }
     { [ os macosx? ] [ "io.files.trash.macosx" ] }
-    { [ os linux? ] [ "io.files.trash.linux" ] }
+    { [ os unix? ] [ "io.files.trash.unix" ] }
 } cond require
diff --git a/extra/io/files/trash/unix/platforms.txt b/extra/io/files/trash/unix/platforms.txt
new file mode 100644 (file)
index 0000000..509143d
--- /dev/null
@@ -0,0 +1 @@
+unix
diff --git a/extra/io/files/trash/unix/unix.factor b/extra/io/files/trash/unix/unix.factor
new file mode 100644 (file)
index 0000000..5f3812f
--- /dev/null
@@ -0,0 +1,79 @@
+! Copyright (C) 2010 John Benediktsson
+! See http://factorcode.org/license.txt for BSD license
+
+USING: accessors calendar combinators.short-circuit formatting
+io io.backend io.directories io.encodings.utf8 io.files
+io.files.info io.files.info.unix io.files.trash io.pathnames
+kernel math math.parser sequences system unix.stat unix.users
+xdg ;
+
+IN: io.files.trash.unix
+
+! Implements the FreeDesktop.org Trash Specification 0.7
+
+<PRIVATE
+
+: top-directory? ( path -- ? )
+    dup ".." append-path [ link-status ] bi@
+    [ [ st_dev>> ] same? not ] [ [ st_ino>> ] same? ] 2bi or ;
+
+: top-directory ( path -- path' )
+    [ dup top-directory? not ] [ ".." append-path ] while ;
+
+: make-user-directory ( path -- )
+    [ make-directories ] [ 0o700 set-file-permissions ] bi ;
+
+: check-trash-path ( path -- )
+    {
+        [ file-info directory? ]
+        [ sticky? ]
+        [ link-info symbolic-link? not ]
+    } 1&& [ "invalid trash path" throw ] unless ;
+
+: trash-home ( -- path )
+    xdg-data-home "Trash" append-path dup check-trash-path ;
+
+: trash-1 ( root -- path )
+    ".Trash" append-path dup check-trash-path
+    real-user-id number>string append-path ;
+
+: trash-2 ( root -- path )
+    real-user-id ".Trash-%d" sprintf append-path ;
+
+: trash-path ( path -- path' )
+    top-directory dup trash-home top-directory = [
+        drop trash-home
+    ] [
+        dup ".Trash" append-path file-exists?
+        [ trash-1 ] [ trash-2 ] if
+        [ make-user-directory ] keep
+    ] if ;
+
+: (safe-file-name) ( path counter -- path' )
+    [
+        [ parent-directory ]
+        [ file-stem ]
+        [ file-extension dup [ "." prepend ] when ] tri
+    ] dip swap "%s%s %s%s" sprintf ;
+
+: safe-file-name ( path -- path' )
+    dup 0 [ over file-exists? ] [
+        [ parent-directory to-directory ] [ 1 + ] bi*
+        [ (safe-file-name) ] keep
+    ] while drop nip ;
+
+PRIVATE>
+
+M: unix send-to-trash ( path -- )
+    normalize-path dup trash-path [
+        "files" append-path [ make-user-directory ] keep
+        to-directory safe-file-name
+    ] [
+        "info" append-path [ make-user-directory ] keep
+        to-directory ".trashinfo" append overd utf8 [
+            "[Trash Info]" write nl
+            "Path=" write write nl
+            "DeletionDate=" write
+            now "%Y-%m-%dT%H:%M:%S" strftime write nl
+        ] with-file-writer
+    ] bi move-file ;