Copying and pasting files

closed account (jwkNwA7f)
I am making a file manager and I wanted to be able to copy and paste a file into a new directory.

Thank you!
And what is the problem?
closed account (jwkNwA7f)
kbw wrote:
And what is the problem?


I don't know how to copy a file and put it in a new directory. Sorry, I didn't have enough detail.
Last edited on
Sorry, I didn't have enough detail.

And you still don't have anough detail.

There are two parts to you problem:

1. how your file manager interacts with the user. This will depend on how you implemented the GUI component (is it a pretend Explorer?)

2. how the file manager interacts with the file system

A full solution for a Windows app can get rather involved, esp. if you want to support copy and paste between different instances of you file manager.

Andy
closed account (jwkNwA7f)
@Andy It is a very simple console application. The features it has right now is that it can create text files, view them, and write to them. So, basically it is a text editor, but I am planning to add to it. The feature I am wanting to add to it right now is for it to be able to copy the text file and put it in a new directory.
closed account (Dy7SLyTq)
theres a bunch of stuff in the windows api for that. however if you do it for *nix i would just write your own stuff. find a dirwalk function and use sys/stat.h and sys/types.h
The fact that you used the term copy and paste made be focus on the GUI side of things. Does your app also list the text files in a folder? In a folder tree? How does the user perform the "copy and paste"?

Once you know where the user wants the file, if you're working with Windows you can just use CopyFile.

In the POSIX case, it appears you need to code your own copy?

Or you could use Boost.Filesystem's copy_file function (this uses CopyFile on Windows and does its own thing in the POSIX case.)

Andy

CopyFile function
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363851%28v=vs.85%29.aspx

How can I copy a file on Unix using C?
http://stackoverflow.com/questions/2180079/how-can-i-copy-a-file-on-unix-using-c

Filesystem Library
http://www.boost.org/doc/libs/1_38_0/libs/filesystem/doc/index.htm
Last edited on
closed account (jwkNwA7f)
Thank you for your help and time, andywestken!
Topic archived. No new replies allowed.