In message <11**********************@g14g2000cwa.googlegroups .com>,
KevinGPO <ke******@hotmail.com> writes
I am wondering about what's the best
Define "best". Fastest? Easiest to code?
and easiest
For the programmer or for the user?
way to strip trailing
whitespace from every single file in a folder, recursively.
I want to write a program/script so that you pass in a folder name and
it'll recursively go through all sub-folders and strips trailing
whitespace from every single file.
Standard C++ has no concept of "folder", "sub-folder" or even "every ...
file", so the solution is inevitably going to be platform-dependent and
off topic here. You might do better with a scripting language - for
example, perl has easy ways of applying operations to all matching
files.
Trailing whitespace includes:
1. whitespaces at end of text lines, strip whitespace but retain text
2. whitespaces on empty lines, strip whitespace but leave the empty
line
2 is just the special case of 1 when the text is of zero size. No need
to treat it specially.
std::string has lots of functions that might help - find_last_not_of,
for example.
--
Richard Herring