Skip to content
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

ERROR: cp() when subdir contains symbolic linked dirs #10506

Closed
julia-user1000 opened this issue Mar 13, 2015 · 7 comments
Closed

ERROR: cp() when subdir contains symbolic linked dirs #10506

julia-user1000 opened this issue Mar 13, 2015 · 7 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@julia-user1000
Copy link

ERROR: cp() when subdir contains symbolic linked dirs

The documentation says: http://julia.readthedocs.org/en/latest/stdlib/file/?highlight=cp#Base.cp

cp(src::AbstractString, dst::AbstractString; recursive=false)

    Copy a file from src to dest. Passing recursive=true will enable recursive copying of directories.

For an example: I have such file structure which contains one absolute and one relative sympolic link to the directory src

root_src
├── src
│   └── src_text.txt
└── test
    ├── absolute_link_to_src -> /home/test/root_src/src
    └── relative_link_to_src -> ../src

Python just does it fine: also keeps the absolute link as it should be.

Python 3.4.3 (default, Feb 26 2015, 23:01:07) 
[GCC 4.9.2 20150204 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import shutil
>>> shutil.copytree("root_src", "copied_src", symlinks=True, ignore=None)
copied_src
├── src
│   └── src_text.txt
└── test
    ├── absolute_link_to_src -> /home/test/root_src/src
    └── relative_link_to_src -> ../src

Julia: ERROR

Version 0.4.0-dev+3806 (2015-03-13 01:02 UTC)
Commit 5195cc8 (0 days old master)
x86_64-unknown-linux-gnu

Arch Linux

julia> cp("root_src", "copied_src", recursive=true)
ERROR: sendfile: illegal operation on a directory (EISDIR)
 in sendfile at fs.jl:143
 in cp at file.jl:75
 in cp at file.jl:79 (repeats 2 times)

julia> 

Possible missing: readlink

I'm very new to julia so I might miss something and I'm not much of a C person - the reason I hope julia will fit my needs.

python has: readlink which is used in the shutil.copytree code

libuv supports readlink

uv_fs_readlink

But it seems to be missing from: julia: jl_uv.c

I'm not 100% sure how to implement readlink myself.

Thanks

@jiahao
Copy link
Member

jiahao commented Mar 13, 2015

cc @ninjin

@ghost
Copy link

ghost commented Mar 15, 2015

Thank you for the poke @jiahao, I was lagging behind a little bit on the mailing list. I will be setting this as my next target and have a look at a couple of other implementations in order to get things right.

@julia-user1000
Copy link
Author

cc @ninjin
In the process of fixing this error would it be possibleto add: uv_fs_readlink to jl_uv.c

readlink is useful in other cases too
Thanks

@peter1000
Copy link

Question:
julia 0.3 has: cp(src::String, dst::String)
julia 0.4dev has: cp(src::AbstractString, dst::AbstractString; recursive::Bool=false)

Would it make sense to split this into something like:

cp(src::AbstractString, dst::AbstractString)
cptree(src::AbstractString, dst::AbstractString; keepsym::Bool=false)

e.g. python uses shutil.copytree for Recursively copy an entire directory tree.

@tkelman
Copy link
Contributor

tkelman commented Apr 2, 2015

I don't think having two separate function names is a very Julian approach for this.

@simonster simonster added the bug Indicates an unexpected problem or unintended behavior label Apr 2, 2015
@peter1000
Copy link

I will start on this issue now where readlink is merged

@peter1000
Copy link

Can be closed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

5 participants