Skip to content

Commit

Permalink
[10.x] Filesystem : can lock file on append of content (#49262)
Browse files Browse the repository at this point in the history
* [10.x] Can lock file on append of content

* Update facade docblocks

* Update Filesystem.php

---------

Co-authored-by: StephaneBour <StephaneBour@users.noreply.github.com>
Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
3 people committed Dec 6, 2023
1 parent 7d26bfb commit 84e2772
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Illuminate/Filesystem/Filesystem.php
Expand Up @@ -268,11 +268,12 @@ public function prepend($path, $data)
*
* @param string $path
* @param string $data
* @param bool $lock
* @return int
*/
public function append($path, $data)
public function append($path, $data, $lock = false)
{
return file_put_contents($path, $data, FILE_APPEND);
return file_put_contents($path, $data, FILE_APPEND | ($lock ? LOCK_EX : 0));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Facades/File.php
Expand Up @@ -16,7 +16,7 @@
* @method static void replace(string $path, string $content, int|null $mode = null)
* @method static void replaceInFile(array|string $search, array|string $replace, string $path)
* @method static int prepend(string $path, string $data)
* @method static int append(string $path, string $data)
* @method static int append(string $path, string $data, bool $lock = false)
* @method static mixed chmod(string $path, int|null $mode = null)
* @method static bool delete(string|array $paths)
* @method static bool move(string $path, string $target)
Expand Down

0 comments on commit 84e2772

Please sign in to comment.