Skip to main content
GameDev.net gamedev.net
🔒 Locked

File copy with progress bar

Started by monkeykid1313 Jan 20, 2017 at 5:16 AM 8 replies 3.1k views
Original Post
monkeykid1313
monkeykid1313

Hi guys, I'm learning C++. I try to write this program but I have no idea how to do it.

"Write a program to copy a file byte-wise. It should take in two filenames as command-line arguments: the source file and the destination file. Furthermore, during the copy it should show a progress bar on a single line (print the carriage return \r to re-print a line). "

Is there any help? Thanks.

frob
frob
Looks like homework. What has your instructor told you recently?

I'm guessing you've been learning about opening and closing files, and also reading/writing data. Do that.

Out in the real world you'd use asynchronous OS calls, but that is probably far too advanced for now.
ChaosEngine
ChaosEngine
Think about the problem and break it down into steps. Write down the steps here and then tell us what part are you stuck on?
if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight
djsteffey
djsteffey

looks also like they told you something about threads ;)

what does threads have to do with this?

Alberth
Alberth

Threads only complicate things here, as the OP has yet to figure out how to do it sequentially.

Even if you know how to do that, you probably don't really need threads. Disk-speed is an order of magnitude slower than the CPU, and disk-cache read-ahead will make sure for ample supply of next data blocks. Maybe with an SSD that changes, but then a progress-bar makes no sense any more either :p

frob
frob

There are OS-specific techniques that can potentially do it in the background without the data ever touching the CPU or other higher-performance patterns.

Based on the wording, it looks like something that could be accomplished in about 10 lines of code if you know what you are doing. Open the files, find the length, read and write, update status. Rinse and repeat until done. Close the files.

I'm pretty sure I had the same assignment back in my college days.

ApochPiQ
ApochPiQ
That's nice. But your post is not very useful by itself. Don't be lazy, and respect the time of the people who are here voluntarily helping you.

Did you test it?

Does it work?

Does it NOT work?

Can you break it?

How does it break?

Can you speculate as to why it might be broken?


Also, if this is homework, please keep in mind that site policy is that we do not help with homework. Ask your teacher/professor/mentor.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.