浏览代码

triming DS is not enough for `Spl::getFilename()`

`SplFileInfo->getFilename('/filename.ext')` returns `/filename.ext` in both linux and windows
saeideng 8 年之前
父节点
当前提交
7b576d3bf4
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/Filesystem/File.php

+ 2 - 2
src/Filesystem/File.php

@@ -86,7 +86,7 @@ class File
         $splInfo = new SplFileInfo($path);
         $this->Folder = new Folder($splInfo->getPath(), $create, $mode);
         if (!is_dir($path)) {
-            $this->name = ltrim($splInfo->getFilename(), DS);
+            $this->name = ltrim($splInfo->getFilename(), '/\\');
         }
         $this->pwd();
         $create && !$this->exists() && $this->safe($path) && $this->create();
@@ -369,7 +369,7 @@ class File
         }
 
         $splInfo = new SplFileInfo($path);
-        $name = ltrim($splInfo->getFilename(), DS);
+        $name = ltrim($splInfo->getFilename(), '/\\');
 
         if ($ext === null || $ext === '') {
             return $name;