Re: Please check this find/rm script I'm about to run as root
On May 16, 2:19 pm, Amaranth <rhudso...@googlemail.com> wrote:
I created this C++ program to recursively search directories
for redundant files larger than 100MB and delete all but the
largest of them.
I've tested it myself as a normal user on a few dummy files
but am quite apprehensive to run it as root to clean up my
messy file systems.
Any comments on the program, advice on streamlining it or any
bugs spotted, etc.?
A wishlist for the program is to only delete the smaller files
if they are also older, i.e. the largest file that is
preserved must be newer than all other files. If the smaller
files are newer then the user is warned/prompted.
There's really nothing in standard C++ to support anything
involving directories, so you'll end up either reverting to a
third party library (Boost or other), or using system specific
requests. In either case, this isn't really the appropriate
forum (except maybe for Boost).
=========================
========================
// find_duplicates.cpp
[...]
(I'm assuming Unix or a Unix-like system here, given the
commands used in the calls to system.)
Given all the calls to system in your code, my suggestion is, if
you want to take this approach, to write the program in shell;
it's much more natural for this sort of thing. See
comp.unix.shell.
Otherwise, you can use the Posix level interface: see
opendir/readdir/closedir, stat and unlink/rmdir. And if you
have questions, comp.unix.programming.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34