Skip to content

Commit ac5dfeb

Browse files
committed
Clean-up some remaining readdir calls with undesirable false evaluation potential
Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
1 parent 2fd7feb commit ac5dfeb

8 files changed

Lines changed: 10 additions & 10 deletions

File tree

apps/files_external/lib/Lib/Storage/Swift.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public function rmdir($path) {
260260
}
261261

262262
$dh = $this->opendir($path);
263-
while ($file = readdir($dh)) {
263+
while (($file = readdir($dh)) !== false) {
264264
if (\OC\Files\Filesystem::isIgnoredDir($file)) {
265265
continue;
266266
}
@@ -526,7 +526,7 @@ public function copy($source, $target) {
526526
}
527527

528528
$dh = $this->opendir($source);
529-
while ($file = readdir($dh)) {
529+
while (($file = readdir($dh)) !== false) {
530530
if (\OC\Files\Filesystem::isIgnoredDir($file)) {
531531
continue;
532532
}

apps/files_trashbin/lib/Trashbin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ private static function getTrashbinSize($user) {
11091109
public static function isEmpty($user) {
11101110
$view = new View('/' . $user . '/files_trashbin');
11111111
if ($view->is_dir('/files') && $dh = $view->opendir('/files')) {
1112-
while ($file = readdir($dh)) {
1112+
while (($file = readdir($dh)) !== false) {
11131113
if (!Filesystem::isIgnoredDir($file)) {
11141114
return false;
11151115
}

lib/private/Files/Storage/Common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public function copy($source, $target) {
228228
$this->remove($target);
229229
$dir = $this->opendir($source);
230230
$this->mkdir($target);
231-
while ($file = readdir($dir)) {
231+
while (($file = readdir($dir)) !== false) {
232232
if (!Filesystem::isIgnoredDir($file)) {
233233
if (!$this->copy($source . '/' . $file, $target . '/' . $file)) {
234234
closedir($dir);

lib/private/Files/Storage/PolyFill/CopyDirectory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function copy($source, $target) {
8686
protected function copyRecursive($source, $target) {
8787
$dh = $this->opendir($source);
8888
$result = true;
89-
while ($file = readdir($dh)) {
89+
while (($file = readdir($dh)) !== false) {
9090
if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
9191
if ($this->is_dir($source . '/' . $file)) {
9292
$this->mkdir($target . '/' . $file);

tests/apps.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function loadDirectory($path) {
1313
if (strpos($path, 'Integration')) {
1414
return;
1515
}
16-
if ($dh = opendir($path)) {
16+
if (($dh = opendir($path)) !==false) {
1717
while ($name = readdir($dh)) {
1818
if ($name[0] !== '.') {
1919
$file = $path . '/' . $name;

tests/lib/Files/Storage/Storage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function testDirectories($directory) {
8181

8282
$dh = $this->instance->opendir('/');
8383
$content = [];
84-
while ($file = readdir($dh)) {
84+
while (($file = readdir($dh)) !== false) {
8585
if ($file != '.' and $file != '..') {
8686
$content[] = $file;
8787
}
@@ -113,7 +113,7 @@ public function testDirectories($directory) {
113113

114114
$dh = $this->instance->opendir('/');
115115
$content = [];
116-
while ($file = readdir($dh)) {
116+
while (($file = readdir($dh)) !== false) {
117117
if ($file != '.' and $file != '..') {
118118
$content[] = $file;
119119
}

tests/lib/Files/Storage/Wrapper/EncodingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public function testNormalizedDirectoryEntriesOpenDir() {
209209

210210
$dh = $this->instance->opendir('/test');
211211
$content = [];
212-
while ($file = readdir($dh)) {
212+
while (($file = readdir($dh)) !== false) {
213213
if ($file != '.' and $file != '..') {
214214
$content[] = $file;
215215
}

tests/lib/Files/Storage/Wrapper/JailTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected function tearDown(): void {
2828
// test that nothing outside our jail is touched
2929
$contents = [];
3030
$dh = $this->sourceStorage->opendir('');
31-
while ($file = readdir($dh)) {
31+
while (($file = readdir($dh)) !== false) {
3232
if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
3333
$contents[] = $file;
3434
}

0 commit comments

Comments
 (0)