Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Moving files and directories in C++?
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?