C/C++ on Linux/Unix

Moderators: Lundin
Number of threads: 314
Number of posts: 633

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Moving files and directories in C++? Posted by Sephiroth on 24 Apr 2011 at 5:19 PM
The topic says it all. I don't have time to wait for the official ext4 defrag utility so I am going to write one that I can use temporarily. Basically, I want the user to specify a partition or directory to be defragmented and have my program move the directory or partition contents to an external HDD or, if it is large enough, temporary directory/partition, then start moving things back in alphabetical order. Since Linux will not fragment files during a move, this should take fragmented files and plop them back together, as well as sorting them alphabetically.

My problem lies within moving stuff using C++. I canot figure out how to do it. All I can find on Google are people taking shortcuts and using the system call to invoke "mv". I want my program to function properly though, with no shortcuts. Can somebody help me figure out how to move a directory-tree, including files, to a specified location? How about just moving individual files?

-Sephiroth



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.