diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php
index 34e8974a6d50822e4e9b89f4d1717b65093d002e..24a0346df63350fb433e067a17ccc42793f60cdd 100644
--- a/apps/files_external/lib/amazons3.php
+++ b/apps/files_external/lib/amazons3.php
@@ -517,7 +517,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
 			$dh = $this->opendir($path1);
 			if (is_resource($dh)) {
 				while (($file = readdir($dh)) !== false) {
-					if ($file === '.' || $file === '..') {
+					if (\OC\Files\Filesystem::isIgnoredDir($file)) {
 						continue;
 					}
 
diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php
index 6f93f3c84cd79f20f83b92e226d6ebd249e9ccdd..20d2b8f498804c7c587dad2282ee5636abb1ef09 100644
--- a/apps/files_external/lib/swift.php
+++ b/apps/files_external/lib/swift.php
@@ -175,7 +175,7 @@ class Swift extends \OC\Files\Storage\Common {
 
 		$dh = $this->opendir($path);
 		while ($file = readdir($dh)) {
-			if ($file === '.' || $file === '..') {
+			if (\OC\Files\Filesystem::isIgnoredDir($file)) {
 				continue;
 			}
 
@@ -429,7 +429,7 @@ class Swift extends \OC\Files\Storage\Common {
 
 			$dh = $this->opendir($path1);
 			while ($file = readdir($dh)) {
-				if ($file === '.' || $file === '..') {
+				if (\OC\Files\Filesystem::isIgnoredDir($file)) {
 					continue;
 				}
 
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index 3b2d4cf592921a5b47f360fc04861b2673f5c073..2a9df94988d1dcb259eed9d57c3cd74b4ec2070a 100644
--- a/apps/files_trashbin/lib/trashbin.php
+++ b/apps/files_trashbin/lib/trashbin.php
@@ -895,7 +895,7 @@ class Trashbin {
 		$view = new \OC\Files\View('/' . $user . '/files_trashbin');
 		if ($view->is_dir('/files') && $dh = $view->opendir('/files')) {
 			while ($file = readdir($dh)) {
-				if ($file !== '.' and $file !== '..') {
+				if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
 					return false;
 				}
 			}
diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php
index a5ed5fd39966114b240f386c2abbd9881f05ab58..2d579fa2b607174aa072756ba443722e80f0c12a 100644
--- a/lib/private/files/storage/common.php
+++ b/lib/private/files/storage/common.php
@@ -260,7 +260,7 @@ abstract class Common implements Storage {
 		$dh = $this->opendir($path);
 		if (is_resource($dh)) {
 			while (($file = readdir($dh)) !== false) {
-				if ($file !== '.' and $file !== '..') {
+				if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
 					if ($this->is_dir($path . '/' . $file)) {
 						mkdir($target . '/' . $file);
 						$this->addLocalFolder($path . '/' . $file, $target . '/' . $file);
@@ -283,7 +283,7 @@ abstract class Common implements Storage {
 		$dh = $this->opendir($dir);
 		if (is_resource($dh)) {
 			while (($item = readdir($dh)) !== false) {
-				if ($item == '.' || $item == '..') continue;
+				if (\OC\Files\Filesystem::isIgnoredDir($item)) continue;
 				if (strstr(strtolower($item), strtolower($query)) !== false) {
 					$files[] = $dir . '/' . $item;
 				}
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php
index 3676fe69131b1fa33fb68067b6e7da52b6afd1a2..4b6b08a16fd4aa98291545b958e0c499c4bfa658 100644
--- a/lib/private/files/storage/local.php
+++ b/lib/private/files/storage/local.php
@@ -283,7 +283,7 @@ class Local extends \OC\Files\Storage\Common {
 		$files = array();
 		$physicalDir = $this->getSourcePath($dir);
 		foreach (scandir($physicalDir) as $item) {
-			if ($item == '.' || $item == '..')
+			if (\OC\Files\Filesystem::isIgnoredDir($item))
 				continue;
 			$physicalItem = $physicalDir . '/' . $item;
 
diff --git a/lib/private/files/storage/polyfill/copydirectory.php b/lib/private/files/storage/polyfill/copydirectory.php
index 1b4873a3a762ea021e1ab0ea41cdd8b455a16a26..73c6d3d543667d9c261d4139deece3f133dbaf68 100644
--- a/lib/private/files/storage/polyfill/copydirectory.php
+++ b/lib/private/files/storage/polyfill/copydirectory.php
@@ -72,7 +72,7 @@ trait CopyDirectory {
 		$dh = $this->opendir($source);
 		$result = true;
 		while ($file = readdir($dh)) {
-			if ($file !== '.' and $file !== '..') {
+			if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
 				if ($this->is_dir($source . '/' . $file)) {
 					$this->mkdir($target . '/' . $file);
 					$result = $this->copyRecursive($source . '/' . $file, $target . '/' . $file);
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 9afa9d40b20db62c5f0fd21bff22d500a8fc2e86..d7119cf030ddb6c2693eb434bfa5daaeba345a54 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1656,7 +1656,7 @@ class View {
 		if ($trimmed === '') {
 			throw new InvalidPathException($l10n->t('Empty filename is not allowed'));
 		}
-		if ($trimmed === '.' || $trimmed === '..') {
+		if (\OC\Files\Filesystem::isIgnoredDir($trimmed)) {
 			throw new InvalidPathException($l10n->t('Dot files are not allowed'));
 		}
 
diff --git a/lib/private/util.php b/lib/private/util.php
index eb1de5be5a424b331f48d9a9f8ae849cffe2c313..667d358655fc9c6c97ed888fa8c90b19336ae3f8 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -1433,7 +1433,7 @@ class OC_Util {
 		if ($trimmed === '') {
 			return false;
 		}
-		if ($trimmed === '.' || $trimmed === '..') {
+		if (\OC\Files\Filesystem::isIgnoredDir($trimmed)) {
 			return false;
 		}
 		foreach (str_split($trimmed) as $char) {
diff --git a/tests/lib/files/storage/wrapper/jail.php b/tests/lib/files/storage/wrapper/jail.php
index a7bd684df4403babee11c81890d7cfaf3c4c964a..9b16bc5a3213d3905b5276cdcb5713584463500b 100644
--- a/tests/lib/files/storage/wrapper/jail.php
+++ b/tests/lib/files/storage/wrapper/jail.php
@@ -30,7 +30,7 @@ class Jail extends \Test\Files\Storage\Storage {
 		$contents = array();
 		$dh = $this->sourceStorage->opendir('');
 		while ($file = readdir($dh)) {
-			if ($file !== '.' and $file !== '..') {
+			if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
 				$contents[] = $file;
 			}
 		}
diff --git a/tests/lib/testcase.php b/tests/lib/testcase.php
index 854d5f4f65b24064c0edf86ab7f810abc74f376d..7e4890a46c2ee546863c5e700c113ddeed28c704 100644
--- a/tests/lib/testcase.php
+++ b/tests/lib/testcase.php
@@ -193,7 +193,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
 	static protected function tearDownAfterClassCleanStrayDataUnlinkDir($dir) {
 		if ($dh = @opendir($dir)) {
 			while (($file = readdir($dh)) !== false) {
-				if ($file === '..' || $file === '.') {
+				if (\OC\Files\Filesystem::isIgnoredDir($file)) {
 					continue;
 				}
 				$path = $dir . '/' . $file;