Skip to content

Commit 05fa7ab

Browse files
authored
Merge pull request #2099 from danimtb/feature/conan/9997b
Docs for tools.rename()
2 parents e471660 + b9be560 commit 05fa7ab

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

reference/conanfile/tools/files.rst

+20-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ conan.tools.files.patch()
1111
.. code-block:: python
1212
1313
def patch(conanfile, base_path=None, patch_file=None, patch_string=None,
14-
strip=0, fuzz=False, **kwargs):
14+
strip=0, fuzz=False, **kwargs):
1515
1616
Applies a diff from file (*patch_file*) or string (*patch_string*) in *base_path* directory. If
1717
*base_path* is not passed it is applied in the current directory.
@@ -67,3 +67,22 @@ Example of ``conandata.yml`` with different patches for different versions:
6767
"1.12.0":
6868
- patch_file: "patches/0001-buildflatbuffers-cmake.patch"
6969
base_path: "source_subfolder"
70+
71+
conan.tools.rename()
72+
--------------------
73+
74+
.. code-block:: python
75+
76+
def rename(conanfile, src, dst)
77+
78+
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.
79+
80+
.. code-block:: python
81+
82+
def source(self):
83+
tools.rename(self, "lib-sources-abe2h9fe", "sources") # renaming a folder
84+
85+
Parameters:
86+
- **conanfile**: Conanfile object.
87+
- **src** (Required): Path to be renamed.
88+
- **dst** (Required): Path to be renamed to.

0 commit comments

Comments
 (0)