-
-
Notifications
You must be signed in to change notification settings - Fork 731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for moving directories #260
Comments
I could be reading this wrong, but I have some objections to the MoveDirectories worries me, specifically |
The cross volume restriction for moving a directory is from the underlying .NET API for Directory.Move. In addition, you can't overwrite an existing directory. Personally, I like the symmetry with the Cake File aliases such as MoveFileToDirectory and MoveFiles and I'm glad the Cake APIs don't follow the underlying .NET API. I also think it's simpler for a build system where the main (only?) reason to move directories is for packaging. I want to move a bunch of directories into a packaging directory. I don't think we should support overwriting a directory at all though. I'm happy to go with any API though. For my purposes it would just mean having to duplicate the leaf folder in the source and destination DirectoryPaths. MoveDirectory(projectDir + Directory("settings"), packagingDir + Directory("settings") |
Going to submit a PR for this shortly. I'm only going to focus on the single As with |
Nice one, this will knock at least a minute of my current build time. Not sure what why moving multiple directories is any more troublesome than moving multiple files but maybe I'm missing something? Also, I think it's a shame that the Cake File APIs and Directory APIs will not be consistent (the file APIs do not behave the same as the underlying .NET file APIs), but it's hardly the end of the world. |
@coxp Out of interest, where do the file APIs not behave the same as the underlying .NET file APIs? |
Fixed by #1302 |
I think the API should follow that for moving files.
MoveDirectoryToDirectory(directoryPath, targetDirectoryPath)
- Moves an existing directory to a new location (e.g. Move "build/project" to "package" results in "build/" and "package/project"). Target location must exist but full path to target location (once combined with directoryPath) must not.MoveDirectories(pattern, targetDirectoryPath)
- Moves existing directories matching the specified patern to a new location. Actual move implementation as MoveDirectoryToDirectory.MoveDirectories(directoryPaths, targetDirectoryPath)
- Moves existing directories to a new location. Actual move implementation as MoveDirectoryToDirectory.MoveDirectory(directoryPath, targetDirectoryPath)
- Moves an existing directory to a new location, providing the option to specify a new directory name. Target location must not exist. (e.g. Move "build/project" to "package" results in "build/" and "package/" if "package" did not already exist and an error if it did, whereas move "build/project" to "package/project" results in "build/" and "package/project").I think the MoveDirectory API should only work for directories on the same volume. Alternatively, if we determine the targetDirectoryPath is on a different volume (not sure if there is an existing method for this?) then we could implement a method to create a new directory on the the target volume, move the files within that directory, recursively apply for any sub-directories, and then delete the source directory.
The text was updated successfully, but these errors were encountered: