Skip to content

Commit 85e788d

Browse files
committed
FileSystem::apend fix #3
1 parent dd18b38 commit 85e788d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/FileSystem.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public static function write($filename, $content, $overwrite = false)
122122
$file = fopen($filename, "w");
123123
fwrite($file, $content);
124124
fclose($file);
125+
clearstatcache();
125126
}
126127

127128
/**
@@ -143,9 +144,8 @@ public static function append($filename, $content, $newLine = true)
143144
{
144145
throw new InvalidArgumentException("Given value '$filename' is not valid filename.");
145146
}
146-
$isEmpty = !(FileSystem::isFile($filename) && FileSystem::size($filename) > 0);
147147
$file = fopen($filename, "a");
148-
if ($isEmpty)
148+
if (FileSystem::isEmpty($filename))
149149
{
150150
fwrite($file, $content);
151151
}
@@ -158,6 +158,7 @@ public static function append($filename, $content, $newLine = true)
158158
fwrite($file, PHP_EOL . $content);
159159
}
160160
fclose($file);
161+
clearstatcache();
161162
}
162163

163164
/**
@@ -186,6 +187,7 @@ public static function readAllLines($filename, $trimEndOfLine = true)
186187
$lines[] = $trimEndOfLine ? Strings::trimEnd(fgets($file), [PHP_EOL]) : fgets($file);
187188
}
188189
fclose($file);
190+
clearstatcache();
189191
return $lines;
190192
}
191193

@@ -214,6 +216,7 @@ public static function readLineByLine($filename, $trimEndOfLine = true)
214216
yield $trimEndOfLine ? Strings::trimEnd(fgets($file), [PHP_EOL]) : fgets($file);
215217
}
216218
fclose($file);
219+
clearstatcache();
217220
}
218221

219222
/**

0 commit comments

Comments
 (0)