@@ -70,6 +70,18 @@ export interface IReadFileOptions {
7070 * @public
7171 */
7272export interface IFileSystemMoveOptions {
73+ /**
74+ * The path of the object to be moved.
75+ * The path may be absolute or relative.
76+ */
77+ sourcePath : string ;
78+
79+ /**
80+ * The new path for the object.
81+ * The path may be absolute or relative.
82+ */
83+ destinationPath : string ;
84+
7385 /**
7486 * If true, will overwrite the file if it already exists. Defaults to true.
7587 */
@@ -82,6 +94,24 @@ export interface IFileSystemMoveOptions {
8294 ensureFolderExists ?: boolean ;
8395}
8496
97+ /**
98+ * The options for FileSystem.copyFile()
99+ * @public
100+ */
101+ export interface IFileSystemCopyFileOptions {
102+ /**
103+ * The path of the object that will be copied.
104+ * The path may be absolute or relative.
105+ */
106+ sourcePath : string ;
107+
108+ /**
109+ * The path that the object will be copied to.
110+ * The path may be absolute or relative.
111+ */
112+ destinationPath : string ;
113+ }
114+
85115/**
86116 * The options for FileSystem.deleteFile()
87117 * @public
@@ -111,6 +141,24 @@ export interface IUpdateTimeParameters {
111141 modifiedTime : number | Date ;
112142}
113143
144+ /**
145+ * The options for FileSystem.createSymbolicLinkJunction(), createSymbolicLinkFile(), createSymbolicLinkFolder(),
146+ * and createHardLink().
147+ *
148+ * @public
149+ */
150+ export interface IFileSystemCreateLinkOptions {
151+ /**
152+ * The path where the new symlink link will be created.
153+ */
154+ linkPath : string ;
155+
156+ /**
157+ * The newly created symbolic link will point to this target.
158+ */
159+ linkTargetPath : string ;
160+ }
161+
114162/**
115163 * The FileSystem API provides a complete set of recommended operations for interacting with the file system.
116164 *
@@ -217,22 +265,19 @@ export class FileSystem {
217265 /**
218266 * Moves a file. The folder must exist, unless the `ensureFolderExists` option is provided.
219267 * Behind the scenes it uses `fs-extra.moveSync()`
220- * @param sourcePath - The absolute or relative path to the source file.
221- * @param targetPath - The absolute or relative path where the file should be moved to.
222- * @param options - Optional settings that can change the behavior. Type: `IFileSystemMoveOptions`
223268 */
224- public static move ( sourcePath : string , targetPath : string , options ? : IFileSystemMoveOptions ) : void {
269+ public static move ( options : IFileSystemMoveOptions ) : void {
225270 options = {
226271 overwrite : true ,
227272 ensureFolderExists : false ,
228273 ...options
229274 } ;
230275
231276 if ( options . ensureFolderExists ) {
232- FileSystem . ensureFolder ( pathUtilities . basename ( sourcePath ) ) ;
277+ FileSystem . ensureFolder ( pathUtilities . basename ( options . sourcePath ) ) ;
233278 }
234279
235- fsx . moveSync ( sourcePath , targetPath , { overwrite : options . overwrite } ) ;
280+ fsx . moveSync ( options . sourcePath , options . destinationPath , { overwrite : options . overwrite } ) ;
236281 }
237282
238283 // ===============
@@ -359,11 +404,9 @@ export class FileSystem {
359404 * Copies a file from one location to another.
360405 * By default, destinationPath is overwritten if it already exists.
361406 * Behind the scenes it uses `fs.copyFileSync()`.
362- * @param sourcePath - The absolute or relative path to the source file to be copied.
363- * @param destinationPath - The absolute or relative path to the new copy that will be created.
364407 */
365- public static copyFile ( sourcePath : string , destinationPath : string ) : void {
366- fsx . copySync ( sourcePath , destinationPath ) ;
408+ public static copyFile ( options : IFileSystemCopyFileOptions ) : void {
409+ fsx . copySync ( options . sourcePath , options . destinationPath ) ;
367410 }
368411
369412 /**
@@ -408,39 +451,33 @@ export class FileSystem {
408451 * @param linkSource - The absolute or relative path to the destination where the link should be created.
409452 * @param linkTarget - The absolute or relative path to the target of the link.
410453 */
411- public static createSymbolicLinkJunction ( linkTarget : string , linkSource : string ) : void {
454+ public static createSymbolicLinkJunction ( options : IFileSystemCreateLinkOptions ) : void {
412455 // For directories, we use a Windows "junction". On POSIX operating systems, this produces a regular symlink.
413- fsx . symlinkSync ( linkTarget , linkSource , 'junction' ) ;
456+ fsx . symlinkSync ( options . linkTargetPath , options . linkPath , 'junction' ) ;
414457 }
415458
416459 /**
417460 * Creates a symbolic link to a file (on Windows this requires elevated permissionsBits).
418461 * Behind the scenes it uses `fs.symlinkSync()`.
419- * @param linkSource - The absolute or relative path to the destination where the link should be created.
420- * @param linkTarget - The absolute or relative path to the target of the link.
421462 */
422- public static createSymbolicLinkFile ( linkTarget : string , linkSource : string ) : void {
423- fsx . symlinkSync ( linkSource , linkTarget , 'file' ) ;
463+ public static createSymbolicLinkFile ( options : IFileSystemCreateLinkOptions ) : void {
464+ fsx . symlinkSync ( options . linkTargetPath , options . linkPath , 'file' ) ;
424465 }
425466
426467 /**
427468 * Creates a symbolic link to a folder (on Windows this requires elevated permissionsBits).
428469 * Behind the scenes it uses `fs.symlinkSync()`.
429- * @param linkSource - The absolute or relative path to the destination where the link should be created.
430- * @param linkTarget - The absolute or relative path to the target of the link.
431470 */
432- public static createSymbolicLinkFolder ( linkTarget : string , linkSource : string ) : void {
433- fsx . symlinkSync ( linkSource , linkTarget , 'dir' ) ;
471+ public static createSymbolicLinkFolder ( options : IFileSystemCreateLinkOptions ) : void {
472+ fsx . symlinkSync ( options . linkTargetPath , options . linkPath , 'dir' ) ;
434473 }
435474
436475 /**
437476 * Creates a hard link.
438477 * Behind the scenes it uses `fs.linkSync()`.
439- * @param linkSource - The absolute or relative path to the destination where the link should be created.
440- * @param linkTarget - The absolute or relative path to the target of the link.
441478 */
442- public static createHardLink ( linkTarget : string , linkSource : string ) : void {
443- fsx . linkSync ( linkSource , linkTarget ) ;
479+ public static createHardLink ( options : IFileSystemCreateLinkOptions ) : void {
480+ fsx . linkSync ( options . linkTargetPath , options . linkPath ) ;
444481 }
445482
446483 /**
@@ -467,4 +504,4 @@ export class FileSystem {
467504 return text ;
468505 }
469506 }
470- }
507+ }
0 commit comments