Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,117 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,778 people online right now. Registration is fast and FREE... Join Now!




Directory Contents Comparison

 
Reply to this topicStart new topic

Directory Contents Comparison, update destination filesystem when change occurs in source

pdavis65
16 Apr, 2007 - 04:26 AM
Post #1

New D.I.C Head
*

Joined: 16 Apr, 2007
Posts: 1


My Contributions
Hi I am very new to C++ programming having just finished my training. I live in the UK and am trying to learn coding in C++ so that I can develop my career prospects. You may be seeing a lot of posts from me over the next few months so please bear with me.

I have been given a task which I would really appreciate some help with.
None of my initial training contained info on how look at filesystems, only how to edit the contents of a file, therefore I haven't clue where to start crazy.gif

The program needs to run from the command prompt, not from a GUI.

I need to compare the contents of an entire directory structure who's source location has been hard coded into the program (C:\temp1\test1)
to an identical directory structure on a different drive who's letter I am manually prompted to enter, in this case (I:\temp1\test1)

I need to be able to compare all files in the source directory against all files in the destination. If there is a new file added to the source it needs to be copied to the destination. If a file has been deleted from the source it need to be deleted from the destination. Also needs to copy accross from the source any file who's modification date is newer than the file in the destination, and Finally if there has been a directory deleted or created or had it's name changed in the source, that change needs to be reflected in the destination too.

Phew, hope that all makes sense. I suppose you could say it is like a backup that only amends the destination tree to reflect any change in the source tree.

Many thanks in advance for any help that is offered. I wish I had started on something a little less confusing.....




User is offlineProfile CardPM
+Quote Post

dizzywiggle
RE: Directory Contents Comparison
16 Apr, 2007 - 05:00 AM
Post #2

New D.I.C Head
*

Joined: 13 Apr, 2007
Posts: 9


My Contributions
Check out _findfirst and the _findnext functions.

-Shane
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Directory Contents Comparison
16 Apr, 2007 - 05:13 AM
Post #3

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,226



Thanked: 37 times
Dream Kudos: 25
My Contributions
Good suggestion, although there may be portability/compatibility issues with those functions.
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: Directory Contents Comparison
16 Apr, 2007 - 02:18 PM
Post #4

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,858



Thanked: 49 times
Dream Kudos: 550
My Contributions
How you deal with directories depends upon the platform you are on. For some reason or another no one on the standards commitee thought dealing with directories was very usefull (my bet is that they were all embedded systems gurus) and left it ous of the standard.

There are findfirst() (_findfirst()) and (_findnext()) in some libraries.

On windows you can use FindFirstFile() and FindNextFile() from the win32 API. I am not sure how to do it on a UNIX or MAC platform.

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 09:56PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month