Skip to content

Tools files rm: Update usage with new excludes parameter #3743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions reference/tools/files/basic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,26 @@ Usage:
conan.tools.files.rm()
----------------------

.. currentmodule:: conan.tools.files.files
This function removes files from the filesystem. It can be used to remove a single file or a pattern based on fnmatch.
It's indicated to use it instead of ``os.remove`` because it's cross-platform and may avoid permissions issues.

.. autofunction:: rm
.. code-block:: python
:caption: *Remove all files finished in .tmp in build_folder and recursively*

from conan.tools.files import rm

Usage:
rm(self, "*.tmp", self.build_folder, recursive=True)

.. code-block:: python
:caption: *Remove all files from bin_folder, except for any finished by .dll*

from conan.tools.files import rm

rm(self, "*.tmp", self.build_folder, recursive=True)
rm(self, "*", self.bin_folder, recursive=False, excludes="*.dll")

.. currentmodule:: conan.tools.files.files

.. autofunction:: rm


conan.tools.files.mkdir()
Expand Down Expand Up @@ -306,7 +313,7 @@ For UNIX libraries starting with **lib**, like *libmath.a*, this tool will colle
library name **math**. Regarding symlinks, this tool will keep only the "most generic"
file among the resolved real file and all symlinks pointing to this real file. For example
among files below, this tool will select *libmath.dylib* file and therefore only append
*math* in the returned list:
*math* in the returned list:

.. code-block:: shell

Expand Down