Comments (5)
Thank you for your feedback, i will improve docs :)
from fs_extra.
Sorry, but fs_extra does not exist method dir_copy. fs_extra have this method fs_extra::dir::copy which contains third argument copy_options, where you can set necessary settings for copy operation.
If you are expected this c/d/b
behavior, you should set true for the copy_inside property of copy_option object
from fs_extra.
This is all not well explained in documentation. I was able to figure it out myself, but it require some trail and error.
from fs_extra.
I have to agree that the semantics are are bit weird:
Taking a look at the copy
function:
if options.copy_inside {
if to.exists() {
if let Some(dir_name) = from.components().last() {
to.push(dir_name.as_os_str());
} else {
err!("Invalid folder from", ErrorKind::InvalidFolder);
}
}
} else {
if let Some(dir_name) = from.components().last() {
to.push(dir_name.as_os_str());
} else {
err!("Invalid folder from", ErrorKind::InvalidFolder);
}
}
Depending on the fact that the target directory exists or not, the outcome is different. And there seems to be no way to influence that.
e.g.: copying a/b
from a
to c
, setting copy_inside=true
will result in:
c/b
- ifc
does not exist- or
c/a/b
- ifc
did already exist
So the behavior of copy
with copy_inside=true
is not as cp -r
.
Which causes as problem when you want to copy from multiple source directories, to a single target directory with copy_inside=true
.
Also is the documentation of https://docs.rs/fs_extra/1.1.0/fs_extra/dir/fn.copy.html wrong IMHO. It refers to a non-existing copy option named mirror_copy
.
I guess the right fix would be to simple drop the "if exists" check for copy_inside
.
from fs_extra.
Hi @ctron,
is not as cp -r
I checked right now behaviors cp -r
and this behavior the same as mine. These operations have a different outcome if the target folder exists or doesn't ...
It refers to a non-existing copy option named mirror_copy.
My bad... i missed this moment, when changed old name(mirror_copy) by new (copy_inside)
from fs_extra.
Related Issues (20)
- Open to adding builder methods for CopyOptions?
- Problematic move
- Some questions regarding this crate HOT 2
- Make a point release HOT 1
- Add exclude paths in CopyOptions
- Directory copy different behavior
- Errors in `fs_extra` are different than in `std::fs`
- Is this crate still maintained HOT 6
- `dir::get_size` returns wrong size for symlinks HOT 1
- `dir::copy` does not preserve symlinked directories HOT 3
- Data loss when moving directory on Windows HOT 4
- No such file or directory (os err or 2) HOT 1
- Request: reflink HOT 1
- New release? HOT 2
- many test failures in tests/dir.rs on Linux HOT 6
- Documentation mismatch for fs_extra::file::move_file_with_progress
- race condition with recursive copy HOT 1
- Add Option for Sequential Naming while File Copying
- support dereference
- remove_items silently fails on broken symlinks
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fs_extra.