Do you have any idea how to copy directory and subdir like cp from shell with Api ?
I know how to move and delete dir and subdir.
Thanks.
How to copy directory
Re: How to copy directory
You could use system to run cp -r or rsync -r.
If you want to stick to pure FB code, you'll have to do it all yourself. Walk the directory tree, if an item is a directory, recurse into it.
If you want to stick to pure FB code, you'll have to do it all yourself. Walk the directory tree, if an item is a directory, recurse into it.
Re: How to copy directory
Thanks, Maybe system is the solution for now.caseih wrote:You could use system to run cp -r or rsync -r.
If you want to stick to pure FB code, you'll have to do it all yourself. Walk the directory tree, if an item is a directory, recurse into it.
Dir plus subdir and files,sorry.
I read how to delete with ntfw from here:
https://stackoverflow.com/questions/546 ... in-posix-c
Re: How to copy directory
You can do a copy in much the same way, using nftw. Rather than unlinking a file, you would copy it. Of course you have to do the copy yourself also, by opening the source and target and reading and writing chunks of data. Then of course set the permissions. I don't know of any function that copies files, but I bet there is something in a library somewhere.
Re: How to copy directory
Thanks again, It's really helpful.caseih wrote:You can do a copy in much the same way, using nftw. Rather than unlinking a file, you would copy it. Of course you have to do the copy yourself also, by opening the source and target and reading and writing chunks of data. Then of course set the permissions. I don't know of any function that copies files, but I bet there is something in a library somewhere.
Re: How to copy directory
So this post may be relevant: https://stackoverflow.com/questions/919 ... linux-unix
ntfw can do it, but your callback will need some way of knowing what the target path is, since it's not part of the callback mechanism. A global variable would do it, but that's not so clean in my opinion. Perhaps you can recursively scan the files yourself using FB's builtin DIR() function.
ntfw can do it, but your callback will need some way of knowing what the target path is, since it's not part of the callback mechanism. A global variable would do it, but that's not so clean in my opinion. Perhaps you can recursively scan the files yourself using FB's builtin DIR() function.
Re: How to copy directory
Thanks again,caseih wrote:So this post may be relevant: https://stackoverflow.com/questions/919 ... linux-unix
ntfw can do it, but your callback will need some way of knowing what the target path is, since it's not part of the callback mechanism. A global variable would do it, but that's not so clean in my opinion. Perhaps you can recursively scan the files yourself using FB's builtin DIR() function.
There is one problem with this ntfw, i/o error message after several dirs if the source path is root(/).
Maybe with dir like you said and filecopy will do it.