/** * Retrieve the path from a string or File object * @param FileSystem $fs Instance of the filesystem * @param string|File $path * @return string the path in a string format */ private static function retrievePath(FileSystem $fs, $path, &$isRootPath) { if ($path instanceof self) { $path = $path->getPath(); } if (!String::isString($path, String::NOT_EMPTY)) { throw new FileSystemException('Cannot create a file with an empty path'); } $path = str_replace('\\', self::DIRECTORY_SEPARATOR, $path); $isRootPath = $fs->isRootPath($path); if (!$isRootPath) { $path = rtrim($path, self::DIRECTORY_SEPARATOR); } return $path; }