diff --git a/src/StreamWrapper/LocalStream.php b/src/StreamWrapper/LocalStream.php
index 0260408..30780ef 100644
--- a/src/StreamWrapper/LocalStream.php
+++ b/src/StreamWrapper/LocalStream.php
@@ -77,7 +77,7 @@ abstract class LocalStream extends StreamWrapperBase {
     $realpath = realpath($path);
     if (!$realpath) {
       // This file does not yet exist.
-      $realpath = realpath(dirname($path)) . '/' . drupal_basename($path);
+      $realpath = realpath(dirname($path)) . '/' . \Drupal::service('file_system')->basename($path);
     }
     $directory = realpath($this->getDirectoryPath());
 
@@ -318,7 +318,7 @@ abstract class LocalStream extends StreamWrapperBase {
    */
   public function unlink($uri) {
     $this->uri = $uri;
-    return drupal_unlink($this->getLocalPath());
+    return \Drupal::service('file_system')->unlink($this->getLocalPath());
   }
 
   /**
@@ -365,10 +365,10 @@ abstract class LocalStream extends StreamWrapperBase {
       $localpath = $this->getLocalPath($uri);
     }
     if ($options & STREAM_REPORT_ERRORS) {
-      return drupal_mkdir($localpath, $mode, $recursive);
+      return \Drupal::service('file_system')->mkdir($localpath, $mode, $recursive);
     }
     else {
-      return @drupal_mkdir($localpath, $mode, $recursive);
+      return @\Drupal::service('file_system')->mkdir($localpath, $mode, $recursive);
     }
   }
 
@@ -388,10 +388,10 @@ abstract class LocalStream extends StreamWrapperBase {
   public function rmdir($uri, $options) {
     $this->uri = $uri;
     if ($options & STREAM_REPORT_ERRORS) {
-      return drupal_rmdir($this->getLocalPath());
+      return \Drupal::service('file_system')->rmdir($this->getLocalPath());
     }
     else {
-      return @drupal_rmdir($this->getLocalPath());
+      return @\Drupal::service('file_system')->rmdir($this->getLocalPath());
     }
   }
 
