@@ -1619,13 +1619,6 @@ defmodule File do
16191619 directories removed in no specific order, `{:error, reason, file}`
16201620 otherwise.
16211621
1622- ## Options
1623-
1624- * `:each_directory` - (since v1.20.0) a callback invoked for each
1625- directory before its contents are deleted. The callback receives the
1626- directory path as a binary. It is useful, for example, to grant write
1627- permission to a directory before attempting to delete it.
1628-
16291622 ## Examples
16301623
16311624 File.rm_rf("samples")
@@ -1637,28 +1630,24 @@ defmodule File do
16371630 File.rm_rf("/tmp")
16381631 #=> {:error, :eperm, "/tmp"}
16391632 """
1640- @ spec rm_rf ( Path . t ( ) , each_directory: ( Path . t ( ) -> term ) ) ::
1641- { :ok , [ binary ] } | { :error , posix | :badarg , binary }
1642- def rm_rf ( path , options \\ [ ] ) do
1633+ @ spec rm_rf ( Path . t ( ) ) :: { :ok , [ binary ] } | { :error , posix | :badarg , binary }
1634+ def rm_rf ( path ) do
16431635 { major , _ } = :os . type ( )
1644- each_directory = Keyword . get ( options , :each_directory , fn _ -> :ok end )
16451636
16461637 path
16471638 |> IO . chardata_to_string ( )
16481639 |> assert_no_null_byte! ( "File.rm_rf/1" )
1649- |> do_rm_rf ( [ ] , major , each_directory )
1640+ |> do_rm_rf ( [ ] , major )
16501641 end
16511642
1652- defp do_rm_rf ( path , acc , major , each_directory ) do
1643+ defp do_rm_rf ( path , acc , major ) do
16531644 case safe_list_dir ( path , major ) do
16541645 { :ok , files } when is_list ( files ) ->
1655- each_directory . ( path )
1656-
16571646 acc =
16581647 Enum . reduce ( files , acc , fn file , acc ->
16591648 # In case we can't delete, continue anyway, we might succeed
16601649 # to delete it on Windows due to how they handle symlinks.
1661- case do_rm_rf ( Path . join ( path , file ) , acc , major , each_directory ) do
1650+ case do_rm_rf ( Path . join ( path , file ) , acc , major ) do
16621651 { :ok , acc } -> acc
16631652 { :error , _ , _ } -> acc
16641653 end
@@ -1734,7 +1723,7 @@ defmodule File do
17341723 end
17351724
17361725 @ doc """
1737- Same as `rm_rf/2 ` but raises a `File.Error` exception in case of failures,
1726+ Same as `rm_rf/1 ` but raises a `File.Error` exception in case of failures,
17381727 otherwise returns the list of files or directories removed.
17391728
17401729 ## Examples
@@ -1748,9 +1737,9 @@ defmodule File do
17481737 File.rm_rf!("/tmp")
17491738 ** (File.Error) could not remove files and directories recursively from "/tmp": not owner
17501739 """
1751- @ spec rm_rf! ( Path . t ( ) , each_directory: ( Path . t ( ) -> term ) ) :: [ binary ]
1752- def rm_rf! ( path , options \\ [ ] ) do
1753- case rm_rf ( path , options ) do
1740+ @ spec rm_rf! ( Path . t ( ) ) :: [ binary ]
1741+ def rm_rf! ( path ) do
1742+ case rm_rf ( path ) do
17541743 { :ok , files } ->
17551744 files
17561745
0 commit comments