@@ -125,6 +125,18 @@ public static function tell($stream, $uri = null): int
125125 return self ::throwOnFailure ($ result , 'Error getting file position indicator for stream: %s ' , $ uri , $ stream );
126126 }
127127
128+ /**
129+ * Copy a file
130+ *
131+ * @see copy()
132+ * @throws FilesystemErrorException on failure.
133+ */
134+ public static function copy (string $ from , string $ to ): void
135+ {
136+ $ result = @copy ($ from , $ to );
137+ self ::throwOnFailure ($ result , 'Error copying %s to %s ' , $ from , null , false , $ to );
138+ }
139+
128140 /**
129141 * Get the status of a file or stream
130142 *
@@ -738,17 +750,18 @@ public static function getStreamUri($stream): ?string
738750 * @param Stringable|string|null $uri
739751 * @param resource|null $stream
740752 * @param TFailure $failure
753+ * @param string|int|float ...$args
741754 * @return ($result is TFailure ? never : TSuccess)
742755 */
743- private static function throwOnFailure ($ result , string $ message , $ uri , $ stream = null , $ failure = false )
756+ private static function throwOnFailure ($ result , string $ message , $ uri , $ stream = null , $ failure = false , ... $ args )
744757 {
745758 if ($ result === $ failure ) {
746759 $ error = error_get_last ();
747760 if ($ error ) {
748761 throw new FilesystemErrorException ($ error ['message ' ]);
749762 }
750763 throw new FilesystemErrorException (
751- sprintf ($ message , self ::getFriendlyStreamUri ($ uri , $ stream ))
764+ sprintf ($ message , self ::getFriendlyStreamUri ($ uri , $ stream ), ... $ args )
752765 );
753766 }
754767 return $ result ;
0 commit comments