MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / isKeyEmpty

Function isKeyEmpty

src/env.cpp:882–914  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

880}
881
882bool isKeyEmpty(HKEY key)
883{
884 // check for any values
885 if (keyHasValues(key)) {
886 return false;
887 }
888
889 auto r = forEachSubKey(key, [&](const wchar_t* name) {
890 // a subkey exists, recursively check if it's empty
891 auto subkey = openRegistryKey(key, name);
892
893 if (!subkey) {
894 // can't open, stop
895 return false;
896 }
897
898 if (!isKeyEmpty(subkey.get())) {
899 // not empty, stop
900 return false;
901 }
902
903 // empty, go on
904 return true;
905 });
906
907 if (!r) {
908 // something went wrong or some subkey has values
909 return false;
910 }
911
912 // key has no values and has either no subkeys or all subkeys are empty
913 return true;
914}
915
916void deleteRegistryKeyIfEmpty(const QString& name)
917{

Callers 1

deleteRegistryKeyIfEmptyFunction · 0.85

Calls 4

keyHasValuesFunction · 0.85
forEachSubKeyFunction · 0.85
openRegistryKeyFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected