Copy directory content

Tandura

I want to copy the content o directory(tmp1) to another directory(tmp2). tmp1 may contain files and others directories. I want to copy the content of tmp1 (including the mode) using C/C++. If tmp1 contains a tree of directories I want to copy them recursively.

What is the simplest solution?

I found a solution to open the directory and read every entry and copy it with cp command. Any simpler solutions?

cshu

I recommend using std::filesystem (merged to ISO C++ as of C++17!)

Shamelessly copied from http://en.cppreference.com/w/cpp/filesystem/copy:

std::filesystem::copy("/dir1", "/dir3", std::filesystem::copy_options::recursive);

Read more about it:

https://gcc.gnu.org/onlinedocs/gcc-6.1.0/libstdc++/api/a01832.html

experimental::filesystem linker error

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

puppet copy directory but not its content

From Dev

Ansible: copy a directory content to another directory

From Dev

Copy recursively a directory excluding a subdirectory and ITS CONTENT

From Dev

Robocopy copy directory instead of just its content

From Dev

Copy content of one directory in bare repo to directory outside repo

From Dev

Python - How to copy content of USB(Flash) to system directory

From Dev

Copy the content/file to all subdirectory in a directory using terminal

From Dev

Error when trying to copy directory content with rsync inside a shell script

From Dev

Python - How to copy content of USB(Flash) to system directory

From Dev

SFTP Inbound channel Adapter does not copy file when local directory has any content

From Dev

Must I generate SSH key for each my computer, or to copy the `~/.ssh` directory's content is enough?

From Dev

Copy folder content included in C# project to output directory without parent folder

From Dev

How can I automatically copy the content of a usb (flash) drive to another directory?

From Dev

Must I generate SSH key for each my computer, or to copy the `~/.ssh` directory's content is enough?

From Dev

How to copy directory stucture, folders, sub-folders, files properties,metadata wihtout copying the actual content of files?

From Dev

Copy files in a directory to another directory

From Dev

Copy files in a directory to another directory

From Dev

Robocopy - Copy directory into another directory

From Dev

Copy entire directory in Gradle

From Dev

How to copy directory with xcopy?

From Dev

Dockerfile COPY: "lchown ... not a directory"

From Dev

WixToolset directory structure copy

From Dev

Java: HDFS copy directory

From Dev

Copy file to directory

From Dev

Copy a file into a created directory

From Dev

Copy and overwrite directory recursively

From Dev

Copy files to the newest Directory

From Dev

File not copy to correct directory

From Dev

Copy file to current directory?

Related Related

  1. 1

    puppet copy directory but not its content

  2. 2

    Ansible: copy a directory content to another directory

  3. 3

    Copy recursively a directory excluding a subdirectory and ITS CONTENT

  4. 4

    Robocopy copy directory instead of just its content

  5. 5

    Copy content of one directory in bare repo to directory outside repo

  6. 6

    Python - How to copy content of USB(Flash) to system directory

  7. 7

    Copy the content/file to all subdirectory in a directory using terminal

  8. 8

    Error when trying to copy directory content with rsync inside a shell script

  9. 9

    Python - How to copy content of USB(Flash) to system directory

  10. 10

    SFTP Inbound channel Adapter does not copy file when local directory has any content

  11. 11

    Must I generate SSH key for each my computer, or to copy the `~/.ssh` directory's content is enough?

  12. 12

    Copy folder content included in C# project to output directory without parent folder

  13. 13

    How can I automatically copy the content of a usb (flash) drive to another directory?

  14. 14

    Must I generate SSH key for each my computer, or to copy the `~/.ssh` directory's content is enough?

  15. 15

    How to copy directory stucture, folders, sub-folders, files properties,metadata wihtout copying the actual content of files?

  16. 16

    Copy files in a directory to another directory

  17. 17

    Copy files in a directory to another directory

  18. 18

    Robocopy - Copy directory into another directory

  19. 19

    Copy entire directory in Gradle

  20. 20

    How to copy directory with xcopy?

  21. 21

    Dockerfile COPY: "lchown ... not a directory"

  22. 22

    WixToolset directory structure copy

  23. 23

    Java: HDFS copy directory

  24. 24

    Copy file to directory

  25. 25

    Copy a file into a created directory

  26. 26

    Copy and overwrite directory recursively

  27. 27

    Copy files to the newest Directory

  28. 28

    File not copy to correct directory

  29. 29

    Copy file to current directory?

HotTag

Archive