Conversation
std/file.d
Outdated
There was a problem hiding this comment.
I find the function useful but I don't like the interface.
why not copyDirectory(string from, string to, bool recursive = true, PreserveAttributes preserve = preserveAttributesDefault) ?
There was a problem hiding this comment.
Why would recursive be optional? Just use copy if that's what you want. Copying a directory is recursive by its very nature; otherwise, you'd just be doing mkdir.
There was a problem hiding this comment.
The interface shouldn't require immutable characters in from and to
There was a problem hiding this comment.
why not copyDirectory(string from, string to, bool recursive = true, PreserveAttributes preserve = preserveAttributesDefault) ?
I suppose with recursive = false this would copy files in the directory and create sub-directories, but it wouldn't step into the sub-directories and copy their contents, right?
Is there a need for that? As far as I'm aware, file managers don't supply that functionality. I don't see where one would need it.
Windows does have symlinks now (starting with Vista, I believe - but we specifically support Windows 7 and newer). I'm not very familiar with how they work exactly, but a quick search shows a number of articles on them. |
I'm not sure that it's critical for a first round of this (and we do a poor job with handling errors like this in general in std.file - e.g. with |
std/file.d
Outdated
There was a problem hiding this comment.
to here looks like a noop
There was a problem hiding this comment.
Is there any reason this uses mkdirRecurse instead of mkdir every time? Shouldn't it do the extra logic just for the root target directory?
There was a problem hiding this comment.
to here looks like a noop
Oh yeah, that's a left-over from when I tried to support ranges. Fixed.
Is there any reason this uses mkdirRecurse instead of mkdir every time? Shouldn't it do the extra logic just for the root target directory?
mkdir throws when the directory exists; mkdirRecurse doesn't. Could replace with if (!exists(to)) mkdir(to);, I guess.
|
This function allocates a lot of short-lived GC memory, one chunk for each unique path in the tree. This can and should be avoided. A related issue is that it should ideally work with all range paths, not just array paths. This enhancement has been done for I suspect this approach gives suboptimal performance, especially when |
std/file.d
Outdated
There was a problem hiding this comment.
std.path needs Delphi's ExcludeTrailingPathDelimiter.
There was a problem hiding this comment.
Agreed. In the meantime, I should probably replace buildNormalizedPath with something that only checks for the trailing separator.
85985fa to
a75a37b
Compare
Agreed.
I'd been playing around with a version that collects all thrown exceptions and throws a single one at the end of the operation. I.e., it would copy as much as possible and then inform the caller via exception about what failed. The delegate thing would be more flexible, so that sounds good to me.
I had tried that, but got frustrated when some of std.file's functions would take ranges but others only const arrays (mkdir vs mkdirRecurse). dirEntries even demands a string. I'll try and reduce the allocations. Any non-obvious pointers?
You mean we could try and skip files that haven't changed? I think we shouldn't try to be that clever here. Keep it simple, just do what the name says: copy everything. |
|
I'm a little confused about the changelog. I had to rebase and new changelog entries showed up. They seem to be the ones at http://dlang.org/changelog/2.070.0.html. Shouldn't the changelog for 2.070 be in the stable branch now? |
Those functions have yet to be improved.
No, a good tool reads and writes asynchronously. |
std/file.d
Outdated
There was a problem hiding this comment.
Just collapse this if-statement into the enforce condition
b48a03b to
67cb279
Compare
|
Somewhat larger update. New commits start at c178944 ("remove @safe from template setTimes"). Summary:
There are still two instances of stringification in Overall, I'm not very confident in my rangification of Other open issues:
By the way, I've noticed that |
|
On Windows, we should create junctions (not symlinks) for directories, as that doesn't require elevated privileges by default. Here's my code to create junctions and symlinks, feel free to submit to std.file: |
|
I've split off the prerequisite parts of this, and made individual pull requests:
|
|
@aG0aep6G needs rebase |
aG0aep6G Your wish has been heard - wanna rebase? ;-) |
copyRecurse differs from copy in that it accepts directories and copies them recursively.
Rebased, but I don't think this is ready to be merged. |
Needs a new rebase, what else do you have on your mind? |
|
|
I'm okay with the addition assuming some non-tenuous semantics can be defined. There are some implementation issues that I'd like to see improved. |
@aG0aep6G so I think this PR would be a lot more important than the |
The issues above still stand. If someone can give me directions on those, sure, I can work on this. Otherwise I'm willing to admit defeat here. |
|
@aG0aep6G are you still working on this or can I close it? |
For when you need to copy a directory.
Possible issues:
symlinkis Posix-only. ButattrIsSymlinkcan apparently be true on Windows.