Skip to content

Commit 5447036

Browse files
committed
minor #8474 Reworded some explanations about Filesystem methods (javiereguiluz)
This PR was merged into the 2.7 branch. Discussion ---------- Reworded some explanations about Filesystem methods I was trying to solve #8453, but I'm not sure we need to add a deprecation notice for that change (because we always explained and assumed that absolute paths are used). However, I propose to reword some explanations for some methods. Commits ------- 4eb0c4c Reworded some explanations about Filesystem methods
2 parents b39756f + 4eb0c4c commit 5447036

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

components/filesystem.rst

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,13 @@ exists
7979
~~~~~~
8080

8181
:method:`Symfony\\Component\\Filesystem\\Filesystem::exists` checks for the
82-
presence of all files or directories and returns ``false`` if a file is missing::
82+
presence of one or more files or directories and returns ``false`` if any of
83+
them is missing::
8384

8485
// this directory exists, return true
8586
$fs->exists('/tmp/photos');
8687

87-
// rabbit.jpg exists, bottle.png does not exists, return false
88+
// rabbit.jpg exists, bottle.png does not exist, return false
8889
$fs->exists(array('rabbit.jpg', 'bottle.png'));
8990

9091
.. note::
@@ -95,10 +96,11 @@ presence of all files or directories and returns ``false`` if a file is missing:
9596
copy
9697
~~~~
9798

98-
:method:`Symfony\\Component\\Filesystem\\Filesystem::copy` is used to copy
99-
files. If the target already exists, the file is copied only if the source
100-
modification date is later than the target. This behavior can be overridden by
101-
the third boolean argument::
99+
:method:`Symfony\\Component\\Filesystem\\Filesystem::copy` makes a copy of a
100+
single file (use :method:`Symfony\\Component\\Filesystem\\Filesystem::mirror` to
101+
copy directories). If the target already exists, the file is copied only if the
102+
source modification date is later than the target. This behavior can be overridden
103+
by the third boolean argument::
102104

103105
// works only if image-ICC has been modified after image.jpg
104106
$fs->copy('image-ICC.jpg', 'image.jpg');
@@ -128,8 +130,8 @@ your own with the second argument. The third argument is the access time::
128130
chown
129131
~~~~~
130132

131-
:method:`Symfony\\Component\\Filesystem\\Filesystem::chown` is used to change
132-
the owner of a file. The third argument is a boolean recursive option::
133+
:method:`Symfony\\Component\\Filesystem\\Filesystem::chown` changes the owner of
134+
a file. The third argument is a boolean recursive option::
133135

134136
// set the owner of the lolcat video to www-data
135137
$fs->chown('lolcat.mp4', 'www-data');
@@ -144,8 +146,8 @@ the owner of a file. The third argument is a boolean recursive option::
144146
chgrp
145147
~~~~~
146148

147-
:method:`Symfony\\Component\\Filesystem\\Filesystem::chgrp` is used to change
148-
the group of a file. The third argument is a boolean recursive option::
149+
:method:`Symfony\\Component\\Filesystem\\Filesystem::chgrp` changes the group of
150+
a file. The third argument is a boolean recursive option::
149151

150152
// set the group of the lolcat video to nginx
151153
$fs->chgrp('lolcat.mp4', 'nginx');
@@ -160,8 +162,8 @@ the group of a file. The third argument is a boolean recursive option::
160162
chmod
161163
~~~~~
162164

163-
:method:`Symfony\\Component\\Filesystem\\Filesystem::chmod` is used to change
164-
the mode of a file. The fourth argument is a boolean recursive option::
165+
:method:`Symfony\\Component\\Filesystem\\Filesystem::chmod` changes the mode or
166+
permissions of a file. The fourth argument is a boolean recursive option::
165167

166168
// set the mode of the video to 0600
167169
$fs->chmod('video.ogg', 0600);
@@ -176,8 +178,8 @@ the mode of a file. The fourth argument is a boolean recursive option::
176178
remove
177179
~~~~~~
178180

179-
:method:`Symfony\\Component\\Filesystem\\Filesystem::remove` is used to remove
180-
files, symlinks, directories easily::
181+
:method:`Symfony\\Component\\Filesystem\\Filesystem::remove` deletes files,
182+
directories and symlinks::
181183

182184
$fs->remove(array('symlink', '/path/to/directory', 'activity.log'));
183185

@@ -189,8 +191,8 @@ files, symlinks, directories easily::
189191
rename
190192
~~~~~~
191193

192-
:method:`Symfony\\Component\\Filesystem\\Filesystem::rename` is used to rename
193-
files and directories::
194+
:method:`Symfony\\Component\\Filesystem\\Filesystem::rename` changes the name
195+
of a single file or directory::
194196

195197
// rename a file
196198
$fs->rename('/tmp/processed_video.ogg', '/path/to/store/video_647.ogg');
@@ -213,8 +215,8 @@ support symbolic links, a third boolean argument is available::
213215
makePathRelative
214216
~~~~~~~~~~~~~~~~
215217

216-
:method:`Symfony\\Component\\Filesystem\\Filesystem::makePathRelative` returns
217-
the relative path of a directory given another one::
218+
:method:`Symfony\\Component\\Filesystem\\Filesystem::makePathRelative` takes two
219+
absolute paths and returns the relative path from the second path to the first one::
218220

219221
// returns '../'
220222
$fs->makePathRelative(
@@ -227,8 +229,10 @@ the relative path of a directory given another one::
227229
mirror
228230
~~~~~~
229231

230-
:method:`Symfony\\Component\\Filesystem\\Filesystem::mirror` mirrors a
231-
directory::
232+
:method:`Symfony\\Component\\Filesystem\\Filesystem::mirror` copies all the
233+
contents of the source directory into the target one (use the
234+
:method:`Symfony\\Component\\Filesystem\\Filesystem::copy` method to copy single
235+
files)::
232236

233237
$fs->mirror('/path/to/source', '/path/to/target');
234238

@@ -253,8 +257,8 @@ dumpFile
253257
.. versionadded:: 2.3
254258
The ``dumpFile()`` was introduced in Symfony 2.3.
255259

256-
:method:`Symfony\\Component\\Filesystem\\Filesystem::dumpFile` allows you to
257-
dump contents to a file. It does this in an atomic manner: it writes a temporary
260+
:method:`Symfony\\Component\\Filesystem\\Filesystem::dumpFile` saves the given
261+
contents into a file. It does this in an atomic manner: it writes a temporary
258262
file first and then moves it to the new file location when it's finished.
259263
This means that the user will always see either the complete old file or
260264
complete new file (but never a partially-written file)::

0 commit comments

Comments
 (0)