Add support for Windows, replace all back slashes with forward slashes
This commit is contained in:
		
							parent
							
								
									5f6ee45f44
								
							
						
					
					
						commit
						f42f211e65
					
				| @ -101,7 +101,7 @@ class FileActionsController extends Controller | |||||||
|     { |     { | ||||||
|         $server = $request->attributes->get('server'); |         $server = $request->attributes->get('server'); | ||||||
| 
 | 
 | ||||||
|         $dirname = pathinfo($file, PATHINFO_DIRNAME); |         $dirname = str_replace('\\', '/', pathinfo($file, PATHINFO_DIRNAME)); | ||||||
|         try { |         try { | ||||||
|             $content = $this->repository->setServer($server)->setToken($request->attributes->get('server_token'))->getContent($file); |             $content = $this->repository->setServer($server)->setToken($request->attributes->get('server_token'))->getContent($file); | ||||||
|         } catch (RequestException $exception) { |         } catch (RequestException $exception) { | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ class FileRepository extends BaseRepository implements FileRepositoryInterface | |||||||
|      */ |      */ | ||||||
|     public function getFileStat(string $path): stdClass |     public function getFileStat(string $path): stdClass | ||||||
|     { |     { | ||||||
|         $file = pathinfo($path); |         $file = str_replace('\\', '/', pathinfo($path)); | ||||||
|         $file['dirname'] = in_array($file['dirname'], ['.', './', '/']) ? null : trim($file['dirname'], '/') . '/'; |         $file['dirname'] = in_array($file['dirname'], ['.', './', '/']) ? null : trim($file['dirname'], '/') . '/'; | ||||||
| 
 | 
 | ||||||
|         $response = $this->getHttpClient()->request('GET', sprintf( |         $response = $this->getHttpClient()->request('GET', sprintf( | ||||||
| @ -39,7 +39,7 @@ class FileRepository extends BaseRepository implements FileRepositoryInterface | |||||||
|      */ |      */ | ||||||
|     public function getContent(string $path): string |     public function getContent(string $path): string | ||||||
|     { |     { | ||||||
|         $file = pathinfo($path); |         $file = str_replace('\\', '/', pathinfo($path)); | ||||||
|         $file['dirname'] = in_array($file['dirname'], ['.', './', '/']) ? null : trim($file['dirname'], '/') . '/'; |         $file['dirname'] = in_array($file['dirname'], ['.', './', '/']) ? null : trim($file['dirname'], '/') . '/'; | ||||||
| 
 | 
 | ||||||
|         $response = $this->getHttpClient()->request('GET', sprintf( |         $response = $this->getHttpClient()->request('GET', sprintf( | ||||||
| @ -61,7 +61,7 @@ class FileRepository extends BaseRepository implements FileRepositoryInterface | |||||||
|      */ |      */ | ||||||
|     public function putContent(string $path, string $content): ResponseInterface |     public function putContent(string $path, string $content): ResponseInterface | ||||||
|     { |     { | ||||||
|         $file = pathinfo($path); |         $file = str_replace('\\', '/', pathinfo($path)); | ||||||
|         $file['dirname'] = in_array($file['dirname'], ['.', './', '/']) ? null : trim($file['dirname'], '/') . '/'; |         $file['dirname'] = in_array($file['dirname'], ['.', './', '/']) ? null : trim($file['dirname'], '/') . '/'; | ||||||
| 
 | 
 | ||||||
|         return $this->getHttpClient()->request('POST', 'server/file/save', [ |         return $this->getHttpClient()->request('POST', 'server/file/save', [ | ||||||
| @ -100,7 +100,7 @@ class FileRepository extends BaseRepository implements FileRepositoryInterface | |||||||
|                 array_push($files, [ |                 array_push($files, [ | ||||||
|                     'entry' => $value->name, |                     'entry' => $value->name, | ||||||
|                     'directory' => trim($path, '/'), |                     'directory' => trim($path, '/'), | ||||||
|                     'extension' => pathinfo($value->name, PATHINFO_EXTENSION), |                     'extension' => str_replace('\\', '/', pathinfo($value->name, PATHINFO_EXTENSION)), | ||||||
|                     'size' => human_readable($value->size), |                     'size' => human_readable($value->size), | ||||||
|                     'date' => strtotime($value->modified), |                     'date' => strtotime($value->modified), | ||||||
|                     'mime' => $value->mime, |                     'mime' => $value->mime, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Lance Pioch
						Lance Pioch