Skip to content

Docs for tools.rename() #2099

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 3 commits into from
May 24, 2021
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
21 changes: 20 additions & 1 deletion reference/conanfile/tools/files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ conan.tools.files.patch()
.. code-block:: python

def patch(conanfile, base_path=None, patch_file=None, patch_string=None,
strip=0, fuzz=False, **kwargs):
strip=0, fuzz=False, **kwargs):

Applies a diff from file (*patch_file*) or string (*patch_string*) in *base_path* directory. If
*base_path* is not passed it is applied in the current directory.
Expand Down Expand Up @@ -67,3 +67,22 @@ Example of ``conandata.yml`` with different patches for different versions:
"1.12.0":
- patch_file: "patches/0001-buildflatbuffers-cmake.patch"
base_path: "source_subfolder"

conan.tools.rename()
--------------------

.. code-block:: python

def rename(conanfile, src, dst)

Utility functions to rename a file or folder *src* to *dst*. On Windows, it is very common that ``os.rename()`` raises an "Access is denied" exception, so this tool uses:command:`robocopy` if available. If that is not the case, or the rename is done in a non-Windows machine, it falls back to the ``os.rename()`` implementation.

.. code-block:: python

def source(self):
tools.rename(self, "lib-sources-abe2h9fe", "sources") # renaming a folder

Parameters:
- **conanfile**: Conanfile object.
- **src** (Required): Path to be renamed.
- **dst** (Required): Path to be renamed to.