Add RegDeleteTree function to TRegKey
Borland's Object Windows Library for the modern age
Brought to you by:
jogybl,
sebas_ledesma
New methods added in [r5958].
Related
Commit: [r5958]
Hi Jogy, I've had a brief look at [r5958]:
PS. Regarding your use of DeleteTree in FolderSize [r5959], where you open the parent "shell" key, you will get an exception (since 7.0) if it is not present, since you pass TRegKey::NoCreate to the constructor, so there is no point in testing for key validity in the if-statement. If you don't want the exception, you can preferably use the new GetSubKey function (returns std::optional). Note that I here assume exceptions are used for error handling in DeleteTree.
Alternatively, if you want to treat a missing key as an error, you can simply do:
PS. There is a spelling error ("Regsitry") in the error message in OwlMain, which by the way should be sent to "cerr" not "cout".
Related
Commit: [r5958]
Commit: [r5959]
Feature Requests:
#151Last edit: Vidar Hasfjord 2022-04-19
Great suggestions. Please review latest commits for the implementation changes.
I discovered that when invoked from the command line, neither cerr or cout display anything. Most likely because it is built as a GUI application.
So I changed it to display all the errors in message boxes.
@jogybl wrote:
I've had a brief look, and it looks good! Some comments:
[[deprecated]](C++14 attribute).[[maybe_unused]]to avoid a warning in release build mode.Related
Commit: [r5961]
Commit: [r5963]
Which one? In all the cases when displaying a folder name, one of the operands is a tstring, and adding a pointer to it should work.
But the code looks very clunky and unreadable this way, so I may go to using a stringstream and displaying it.
@jogybl wrote:
Microsoft Visual Studio Community 2022 (version 17.1.5) gives me the following compilation errors when building the Debug | x64 configuration:
I think the problem is that you call path::c_str, which return type is
const path::value_type*, where value_type is wchar_t, regardless of character set build mode. Replace the path::c_str calls by to_tstring, and things should be fine. You can then even remove the tstring constructor calls around the string literals. Then replace the MessageBox calls by a local lambda, so that you do not have to call c_str. It also lets you avoid repeating the other arguments.Ah yes, I was building only in Unicode, as there are some file and folder names with non-english letters in their names on my machine that cannot be processed by std::filesystem if built for ANSI.
@jogybl wrote:
Compiles fine now!
Here are some coding tips:
Don't repeat yourself (DRY principle). Often you use if-statements to branch the thread of execution, when both branches are just setting up the same call, with only slightly different arguments. In particular for this code; branched calls to "showMessage", when the code logic only computes the message to display.
Current code:
Refactored to one call, only computing the message argument:
As another example, the code sections for options "-export-csv" and "-export-tab-delimited" are almost identical (copy-and-paste probably), except for the delimiter ("\t" or ","). The code can be abstracted into a local lambda taking the delimiter as a parameter.
Regarding formatting, ideally do not use space within braces of uniform initialisation and initializer lists.
E.g.
folder = path{params[2]}, and notfolder = path{ params[2] }.The Visual Studio editor can now (finally!) tell the difference between initialisers and function bodies, so you can configure the automatic formatting accordingly.
Also, configure your editor to not indent the contents of namespaces (generally unhelpful indentation).
Tip: In Visual Studio, select editor settings can be saved and easily recalled for working on projects with different formatting conventions (Tools | Import and Export Settings).
Related
Commit: [r5967]
Last edit: Vidar Hasfjord 2022-04-25