diff --git a/Source/.clang-tidy b/Source/.clang-tidy index 57bdf31c4..003dec7cd 100644 --- a/Source/.clang-tidy +++ b/Source/.clang-tidy @@ -111,37 +111,37 @@ Checks: > readability-implicit-bool-conversion, readability-inconsistent-declaration-parameter-name, readability-isolate-declaration, - # readability-magic-numbers, - # readability-make-member-function-const, - # readability-math-missing-parentheses, - # readability-misleading-indentation, - # readability-misplaced-array-index, - # readability-named-parameter, - # readability-non-const-parameter, - # readability-operators-representation, - # readability-qualified-auto, - # readability-redundant-access-specifiers, - # readability-redundant-casting, - # readability-redundant-control-flow, - # readability-redundant-declaration, - # readability-redundant-function-ptr-dereference, - # readability-redundant-inline-specifier, - # readability-redundant-member-init, - # readability-redundant-preprocessor, - # readability-redundant-smartptr-get, - # readability-redundant-string-cstr, - # readability-redundant-string-init, - # readability-reference-to-constructed-temporary, - # readability-simplify-boolean-expr, - # readability-simplify-subscript-expr, + # readability-magic-numbers, <-- large + readability-make-member-function-const, + readability-math-missing-parentheses, + readability-misleading-indentation, + readability-misplaced-array-index, + readability-named-parameter, + # readability-non-const-parameter, <-- would be nice some day, but that's massive + # readability-operators-representation, <-- not sure about the benefits + # readability-qualified-auto, <-- would be nice some day, but that's massive + readability-redundant-access-specifiers, + readability-redundant-casting, + readability-redundant-control-flow, + readability-redundant-declaration, + readability-redundant-function-ptr-dereference, + readability-redundant-inline-specifier, + readability-redundant-member-init, + readability-redundant-preprocessor, + readability-redundant-smartptr-get, + readability-redundant-string-cstr, + readability-redundant-string-init, + readability-reference-to-constructed-temporary, + readability-simplify-boolean-expr, + readability-simplify-subscript-expr, readability-static-accessed-through-instance, - # readability-static-definition-in-anonymous-namespace, - # readability-string-compare, - # readability-suspicious-call-argument, - # readability-uniqueptr-delete-release, - # readability-uppercase-literal-suffix, - # readability-use-anyofallof, - # readability-use-std-min-max, + readability-static-definition-in-anonymous-namespace, + readability-string-compare, + readability-suspicious-call-argument, + readability-uniqueptr-delete-release, + # readability-uppercase-literal-suffix, <-- controversial + readability-use-anyofallof, + readability-use-std-min-max, CheckOptions: - key: modernize-loop-convert.MinConfidence diff --git a/Source/Base/include/Base/StringsBulk.h b/Source/Base/include/Base/StringsBulk.h index f963cf25b..492e919ae 100644 --- a/Source/Base/include/Base/StringsBulk.h +++ b/Source/Base/include/Base/StringsBulk.h @@ -74,7 +74,7 @@ class StringsBulk::Iterator Iterator operator--(int) noexcept; Iterator &operator+=(long) noexcept; Iterator &operator-=(long) noexcept; - long operator-(const Iterator &) noexcept; + long operator-(const Iterator &) const noexcept; bool operator==(const Iterator &) const noexcept; bool operator!=(const Iterator &) const noexcept; diff --git a/Source/Base/source/CFDefaultsCPP.cpp b/Source/Base/source/CFDefaultsCPP.cpp index a167b27eb..c8db92839 100644 --- a/Source/Base/source/CFDefaultsCPP.cpp +++ b/Source/Base/source/CFDefaultsCPP.cpp @@ -89,7 +89,7 @@ std::optional CFDefaultsGetOptionalBool(CFStringRef _key) noexcept const Boolean v = CFPreferencesGetAppBooleanValue(_key, kCFPreferencesCurrentApplication, &has); if( !has ) return {}; - return v ? true : false; + return v != 0; } void CFDefaultsSetBool(CFStringRef _key, bool _value) noexcept diff --git a/Source/Base/source/CFStackAllocator.cpp b/Source/Base/source/CFStackAllocator.cpp index d32f6768f..8d87b0daf 100644 --- a/Source/Base/source/CFStackAllocator.cpp +++ b/Source/Base/source/CFStackAllocator.cpp @@ -28,7 +28,7 @@ CFAllocatorRef CFStackAllocator::Construct() noexcept return CFAllocatorCreate(kCFAllocatorUseContext, &context); } -void *CFStackAllocator::DoAlloc(CFIndex _alloc_size, CFOptionFlags, void *_info) noexcept +void *CFStackAllocator::DoAlloc(CFIndex _alloc_size, CFOptionFlags /*_hint*/, void *_info) noexcept { assert(_alloc_size >= 0); constexpr long alignment = 16; diff --git a/Source/Base/source/StringsBulk.cpp b/Source/Base/source/StringsBulk.cpp index 816538882..6933d34da 100644 --- a/Source/Base/source/StringsBulk.cpp +++ b/Source/Base/source/StringsBulk.cpp @@ -16,18 +16,18 @@ struct StringsBulk::Ctrl { // offsets: count * 4 bytes // null-terminated strings - [[nodiscard]] inline const uint32_t *Offsets() const noexcept + [[nodiscard]] const uint32_t *Offsets() const noexcept { const auto raw = reinterpret_cast(this); return reinterpret_cast(raw + sizeof(Ctrl)); } - [[nodiscard]] inline const char *Get(size_t _index) const noexcept + [[nodiscard]] const char *Get(size_t _index) const noexcept { return reinterpret_cast(this) + Offsets()[_index]; } - [[nodiscard]] inline size_t StrLen(size_t _index) const noexcept + [[nodiscard]] size_t StrLen(size_t _index) const noexcept { if( _index + 1 < count ) return Offsets()[_index + 1] - Offsets()[_index] - 1; @@ -189,7 +189,7 @@ StringsBulk::Ctrl *StringsBulk::Allocate(size_t _number_of_strings, size_t _tota { assert(_number_of_strings != 0); - const size_t bytes = sizeof(Ctrl) + sizeof(uint32_t) * _number_of_strings + _total_chars; + const size_t bytes = sizeof(Ctrl) + (sizeof(uint32_t) * _number_of_strings) + _total_chars; const auto ctrl = reinterpret_cast(malloc(bytes)); if( ctrl == nullptr ) @@ -349,7 +349,7 @@ StringsBulk::Iterator &StringsBulk::Iterator::operator-=(long _d) noexcept return *this; } -long StringsBulk::Iterator::operator-(const Iterator &_rhs) noexcept +long StringsBulk::Iterator::operator-(const Iterator &_rhs) const noexcept { return long(m_Index) - long(_rhs.m_Index); } @@ -400,7 +400,7 @@ StringsBulk StringsBulk::NonOwningBuilder::Build() const const auto ctrl = StringsBulk::Allocate(strings_num, total_chars); auto offsets = reinterpret_cast(reinterpret_cast(ctrl) + sizeof(StringsBulk::Ctrl)); - char *storage = reinterpret_cast(ctrl) + sizeof(StringsBulk::Ctrl) + sizeof(uint32_t) * strings_num; + char *storage = reinterpret_cast(ctrl) + sizeof(StringsBulk::Ctrl) + (sizeof(uint32_t) * strings_num); for( size_t index = 0; index < strings_num; ++index ) { offsets[index] = uint32_t(storage - reinterpret_cast(ctrl)); const auto string_bytes = m_Strings[index].length(); @@ -448,7 +448,7 @@ StringsBulk StringsBulk::Builder::Build() const const auto ctrl = StringsBulk::Allocate(strings_num, total_chars); auto offsets = reinterpret_cast(reinterpret_cast(ctrl) + sizeof(StringsBulk::Ctrl)); - char *storage = reinterpret_cast(ctrl) + sizeof(StringsBulk::Ctrl) + sizeof(uint32_t) * strings_num; + char *storage = reinterpret_cast(ctrl) + sizeof(StringsBulk::Ctrl) + (sizeof(uint32_t) * strings_num); for( size_t index = 0; index < strings_num; ++index ) { offsets[index] = uint32_t(storage - reinterpret_cast(ctrl)); const auto string_bytes = m_Strings[index].length() + 1; diff --git a/Source/Base/source/algo.cpp b/Source/Base/source/algo.cpp index bea9d3679..70d602a55 100644 --- a/Source/Base/source/algo.cpp +++ b/Source/Base/source/algo.cpp @@ -110,7 +110,7 @@ std::vector SplitByDelimiters(std::string_view _str, std::string_vi std::string next; for( auto c : _str ) { if( _delims.contains(c) ) { - if( !next.empty() || _compress == false ) { + if( !next.empty() || !_compress ) { res.emplace_back(std::move(next)); next = {}; } @@ -120,7 +120,7 @@ std::vector SplitByDelimiters(std::string_view _str, std::string_vi } } - if( !next.empty() || (_compress == false && !_str.empty()) ) { + if( !next.empty() || (!_compress && !_str.empty()) ) { res.emplace_back(std::move(next)); } @@ -133,7 +133,7 @@ std::vector SplitByDelimiter(std::string_view _str, char _delim, bo std::string next; for( auto c : _str ) { if( c == _delim ) { - if( !next.empty() || _compress == false ) { + if( !next.empty() || !_compress ) { res.emplace_back(std::move(next)); next = {}; } @@ -143,7 +143,7 @@ std::vector SplitByDelimiter(std::string_view _str, char _delim, bo } } - if( !next.empty() || (_compress == false && !_str.empty()) ) { + if( !next.empty() || (!_compress && !_str.empty()) ) { res.emplace_back(std::move(next)); } diff --git a/Source/Base/tests/StringsBulk_UT.cpp b/Source/Base/tests/StringsBulk_UT.cpp index b927524f9..2dbc37542 100644 --- a/Source/Base/tests/StringsBulk_UT.cpp +++ b/Source/Base/tests/StringsBulk_UT.cpp @@ -60,7 +60,7 @@ TEST_CASE(PREFIX "random strings") const auto l = rand() % 1000; string s(l, ' '); for( int j = 0; j < l; ++j ) - s[j] = static_cast(j % 255 + 1); + s[j] = static_cast((j % 255) + 1); v.emplace_back(s); } StringsBulk::Builder sbb; @@ -87,7 +87,7 @@ TEST_CASE(PREFIX "non-owning builder") const auto l = rand() % 1000; string s(l, ' '); for( int j = 0; j < l; ++j ) - s[j] = static_cast(j % 255 + 1); + s[j] = static_cast((j % 255) + 1); v.emplace_back(s); } StringsBulk::NonOwningBuilder sbb; diff --git a/Source/CUI/source/CommandPopover.mm b/Source/CUI/source/CommandPopover.mm index a754cffec..d566071f9 100644 --- a/Source/CUI/source/CommandPopover.mm +++ b/Source/CUI/source/CommandPopover.mm @@ -1036,7 +1036,7 @@ - (void)showRelativeToRect:(NSRect)_positioning_rect else if( _alignment == NCCommandPopoverAlignment::Right ) return NSMaxX(rect_on_screen) - sx; else - return NSMinX(rect_on_screen) + (rect_on_screen.size.width - sx) / 2.; + return NSMinX(rect_on_screen) + ((rect_on_screen.size.width - sx) / 2.); }(); const double y = NSMinY(rect_on_screen) - m_ContentSize.height; NSScreen *screen = _positioning_view.window.screen; diff --git a/Source/CUI/source/ProcessSheetController.mm b/Source/CUI/source/ProcessSheetController.mm index f0826b7c8..611891e93 100644 --- a/Source/CUI/source/ProcessSheetController.mm +++ b/Source/CUI/source/ProcessSheetController.mm @@ -92,7 +92,7 @@ - (void)Show { // consider using modal dialog here. - if( m_Running == true ) + if( m_Running ) return; dispatch_to_main_queue_after(g_ShowDelay, [=] { if( m_ClientClosed ) @@ -110,7 +110,7 @@ - (void)Close - (void)Discard { - if( m_Running == false ) + if( !m_Running ) return; dispatch_to_main_queue([=] { [self.window close]; }); diff --git a/Source/Config/source/ConfigImpl.cpp b/Source/Config/source/ConfigImpl.cpp index 9634e1bc7..fd47d2efc 100644 --- a/Source/Config/source/ConfigImpl.cpp +++ b/Source/Config/source/ConfigImpl.cpp @@ -280,7 +280,7 @@ void ConfigImpl::SetInternal(std::string_view _path, const Value &_value) if( _path.empty() ) return; - if( ReplaceOrInsert(_path, _value) == true ) { + if( ReplaceOrInsert(_path, _value) ) { FireObservers(_path); MarkDirty(); } @@ -401,7 +401,7 @@ void ConfigImpl::FireObservers(std::string_view _path) const if( const auto observers = FindObservers(_path) ) { for( const auto &observer : observers->observers ) { const auto lock = std::lock_guard{observer->lock}; - if( observer->was_removed == false ) { + if( !observer->was_removed ) { observer->callback(); } } @@ -419,7 +419,7 @@ base::intrusive_ptr ConfigImpl::FindObservers(std:: void ConfigImpl::MarkDirty() { - if( m_WriteScheduled.test_and_set() == false ) { + if( !m_WriteScheduled.test_and_set() ) { m_OverwritesDumpExecutor->Execute([this] { WriteOverwrites(); }); } } @@ -456,14 +456,14 @@ void ConfigImpl::ResetToDefaults() void ConfigImpl::Commit() { - if( m_WriteScheduled.test_and_set() == true ) { + if( m_WriteScheduled.test_and_set() ) { WriteOverwrites(); } } void ConfigImpl::OverwritesDidChange() { - if( m_ReadScheduled.test_and_set() == false ) { + if( !m_ReadScheduled.test_and_set() ) { m_OverwritesReloadExecutor->Execute([this] { ReloadOverwrites(); }); } } diff --git a/Source/NimbleCommander/NimbleCommander/Bootstrap/AppDelegate+MainWindowCreation.mm b/Source/NimbleCommander/NimbleCommander/Bootstrap/AppDelegate+MainWindowCreation.mm index 71314bbc9..646d70bcf 100644 --- a/Source/NimbleCommander/NimbleCommander/Bootstrap/AppDelegate+MainWindowCreation.mm +++ b/Source/NimbleCommander/NimbleCommander/Bootstrap/AppDelegate+MainWindowCreation.mm @@ -337,7 +337,7 @@ static bool RestoreFilePanelStateFromLastOpenedWindow(MainWindowFilePanelState * VFSHost &_host) { // at this moment we (thankfully) care only about sanboxed versions - if( nc::base::AmISandboxed() == false ) + if( !nc::base::AmISandboxed() ) return true; if( _host.IsNativeFS() ) @@ -350,7 +350,7 @@ static bool RestoreFilePanelStateFromLastOpenedWindow(MainWindowFilePanelState * const std::string &_directory_path, VFSHost &_host) { - if( nc::base::AmISandboxed() == false ) + if( !nc::base::AmISandboxed() ) return true; if( _host.IsNativeFS() ) diff --git a/Source/NimbleCommander/NimbleCommander/Bootstrap/AppDelegate.mm b/Source/NimbleCommander/NimbleCommander/Bootstrap/AppDelegate.mm index 5603bc99e..43ad59cb6 100644 --- a/Source/NimbleCommander/NimbleCommander/Bootstrap/AppDelegate.mm +++ b/Source/NimbleCommander/NimbleCommander/Bootstrap/AppDelegate.mm @@ -824,7 +824,7 @@ - (IBAction)onMainMenuPerformShowFavorites:(id) [[maybe_unused]] _sender apt->SetProgressCallback([](double _progress) { g_Me.dock.SetProgress(_progress); }); return apt; }(); - return *apt.get(); + return *apt; } - (nc::core::Dock &)dock @@ -880,7 +880,7 @@ - (NCMainWindowController *)windowForExternalRevealRequest static void DoTemporaryFileStoragePurge() { assert(g_TemporaryFileStorage != nullptr); - const auto deadline = time(nullptr) - 60 * 60 * 24; // 24 hours back + const auto deadline = time(nullptr) - (60 * 60 * 24); // 24 hours back g_TemporaryFileStorage->Purge(deadline); dispatch_after(6h, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), DoTemporaryFileStoragePurge); diff --git a/Source/NimbleCommander/NimbleCommander/Bootstrap/Interactions.mm b/Source/NimbleCommander/NimbleCommander/Bootstrap/Interactions.mm index 07e16f3bf..7caf6aba3 100644 --- a/Source/NimbleCommander/NimbleCommander/Bootstrap/Interactions.mm +++ b/Source/NimbleCommander/NimbleCommander/Bootstrap/Interactions.mm @@ -19,9 +19,7 @@ bool AskUserToResetDefaults() [alert addButtonWithTitle:NSLocalizedString(@"OK", "")]; [alert addButtonWithTitle:NSLocalizedString(@"Cancel", "")]; [alert.buttons objectAtIndex:0].keyEquivalent = @""; - if( [alert runModal] == NSAlertFirstButtonReturn ) - return true; - return false; + return [alert runModal] == NSAlertFirstButtonReturn; } bool AskToExitWithRunningOperations() diff --git a/Source/NimbleCommander/NimbleCommander/Core/ActionsShortcutsManager.mm b/Source/NimbleCommander/NimbleCommander/Core/ActionsShortcutsManager.mm index be45ae45b..382bc739e 100644 --- a/Source/NimbleCommander/NimbleCommander/Core/ActionsShortcutsManager.mm +++ b/Source/NimbleCommander/NimbleCommander/Core/ActionsShortcutsManager.mm @@ -423,7 +423,7 @@ // clang-format on template -static constexpr auto make_array_n_impl(T &&value, std::index_sequence) +static constexpr auto make_array_n_impl(T &&value, std::index_sequence /*unused*/) { return std::array, size>{(static_cast(indexes), value)..., std::forward(value)}; } diff --git a/Source/NimbleCommander/NimbleCommander/Core/SandboxManager.mm b/Source/NimbleCommander/NimbleCommander/Core/SandboxManager.mm index 16d16ad5c..109bac763 100644 --- a/Source/NimbleCommander/NimbleCommander/Core/SandboxManager.mm +++ b/Source/NimbleCommander/NimbleCommander/Core/SandboxManager.mm @@ -225,10 +225,7 @@ - (BOOL)panel:(id) [[maybe_unused]] _sender shouldEnableURL:(NSURL *)_url return true; // special treating for /Volumes dir - can browse it by default, but not dirs inside it - if( p == "/Volumes" ) - return true; - - return false; + return p == "/Volumes"; } bool SandboxManager::CanAccessFolder(const std::string &_path) const @@ -270,7 +267,5 @@ - (BOOL)panel:(id) [[maybe_unused]] _sender shouldEnableURL:(NSURL *)_url bool SandboxManager::EnsurePathAccess(const std::string &_path) { - if( !SandboxManager::Instance().CanAccessFolder(_path) && !SandboxManager::Instance().AskAccessForPathSync(_path) ) - return false; - return true; + return SandboxManager::Instance().CanAccessFolder(_path) || SandboxManager::Instance().AskAccessForPathSync(_path); } diff --git a/Source/NimbleCommander/NimbleCommander/Core/ServicesHandler.mm b/Source/NimbleCommander/NimbleCommander/Core/ServicesHandler.mm index 8d36caa39..4708203fc 100644 --- a/Source/NimbleCommander/NimbleCommander/Core/ServicesHandler.mm +++ b/Source/NimbleCommander/NimbleCommander/Core/ServicesHandler.mm @@ -73,7 +73,7 @@ static bool IsASingleDirectoryPath(const std::vector &_paths, VFSHost &_native_host) { - return _paths.size() == 1 && _native_host.IsDirectory(_paths[0].c_str(), 0); + return _paths.size() == 1 && _native_host.IsDirectory(_paths[0], 0); } void ServicesHandler::RevealItem(NSPasteboard *_pboard, diff --git a/Source/NimbleCommander/NimbleCommander/Core/SimpleComboBoxPersistentDataSource.mm b/Source/NimbleCommander/NimbleCommander/Core/SimpleComboBoxPersistentDataSource.mm index 5e07a7e00..eda9a877c 100644 --- a/Source/NimbleCommander/NimbleCommander/Core/SimpleComboBoxPersistentDataSource.mm +++ b/Source/NimbleCommander/NimbleCommander/Core/SimpleComboBoxPersistentDataSource.mm @@ -40,7 +40,7 @@ - (void)dealloc Value arr(rapidjson::kArrayType); for( auto &s : m_Items ) arr.PushBack(Value(s.UTF8String, g_CrtAllocator), g_CrtAllocator); - StateConfig().Set(m_ConfigPath.c_str(), arr); + StateConfig().Set(m_ConfigPath, arr); } } diff --git a/Source/NimbleCommander/NimbleCommander/Core/TemporaryNativeFileChangesSentinel.cpp b/Source/NimbleCommander/NimbleCommander/Core/TemporaryNativeFileChangesSentinel.cpp index ee8d679e2..cc4ca4c37 100644 --- a/Source/NimbleCommander/NimbleCommander/Core/TemporaryNativeFileChangesSentinel.cpp +++ b/Source/NimbleCommander/NimbleCommander/Core/TemporaryNativeFileChangesSentinel.cpp @@ -14,7 +14,7 @@ static std::optional> CalculateFileHash(const std::string & { const int chunk_sz = 1 * 1024 * 1024; VFSFilePtr file; - int rc = nc::bootstrap::NativeVFSHostInstance().CreateFile(_path.c_str(), file, nullptr); + int rc = nc::bootstrap::NativeVFSHostInstance().CreateFile(_path, file, nullptr); if( rc != 0 ) return std::nullopt; diff --git a/Source/NimbleCommander/NimbleCommander/Core/Theming/ThemesManager.mm b/Source/NimbleCommander/NimbleCommander/Core/Theming/ThemesManager.mm index 580f158a1..0c4ef46d1 100644 --- a/Source/NimbleCommander/NimbleCommander/Core/Theming/ThemesManager.mm +++ b/Source/NimbleCommander/NimbleCommander/Core/Theming/ThemesManager.mm @@ -18,7 +18,7 @@ [[clang::no_destroy]] static std::shared_ptr g_CurrentTheme; template -static constexpr auto make_array_n_impl(T &&value, std::index_sequence) +static constexpr auto make_array_n_impl(T &&value, std::index_sequence /*unused*/) { return std::array, size>{(static_cast(indexes), value)..., std::forward(value)}; } @@ -462,7 +462,7 @@ static uint64_t NotificationMaskForKey(std::string_view _key) noexcept const auto themes = ThemeNames(); const ankerl::unordered_dense::set names(themes.begin(), themes.end()); - if( names.contains(_current_theme_name) == false ) { + if( !names.contains(_current_theme_name) ) { // no collision, accept as-is return _current_theme_name; } @@ -475,14 +475,14 @@ static uint64_t NotificationMaskForKey(std::string_view _key) noexcept std::from_chars(cn.data() + sp_idx + 1, cn.data() + cn.length(), current_idx).ec == std::errc{} ) { for( ; current_idx < 99; ++current_idx ) { auto name = fmt::format("{} {}", std::string_view(cn.data(), sp_idx), current_idx); - if( names.contains(name) == false ) + if( !names.contains(name) ) return name; } } else { for( ; current_idx < 99; ++current_idx ) { auto name = fmt::format("{} {}", cn, current_idx); - if( names.contains(name) == false ) + if( !names.contains(name) ) return name; } } @@ -582,7 +582,7 @@ static uint64_t NotificationMaskForKey(std::string_view _key) noexcept void ThemesManager::NotifyAboutSystemAppearanceChange(ThemeAppearance _appearance) { - if( m_AutomaticSwitchingEnabled == false ) + if( !m_AutomaticSwitchingEnabled ) return; // nothing to do, ignore the notification if( _appearance == ThemeAppearance::Light ) { diff --git a/Source/NimbleCommander/NimbleCommander/GeneralUI/DetailedVolumeInformationSheetController.mm b/Source/NimbleCommander/NimbleCommander/GeneralUI/DetailedVolumeInformationSheetController.mm index e20ff8209..0748804eb 100644 --- a/Source/NimbleCommander/NimbleCommander/GeneralUI/DetailedVolumeInformationSheetController.mm +++ b/Source/NimbleCommander/NimbleCommander/GeneralUI/DetailedVolumeInformationSheetController.mm @@ -54,7 +54,7 @@ @implementation DetailedVolumeInformationSheetController { static NSString *Bool2ToString(const bool b[2]) { // guess that if FS don't support something on interface level then it also doesn't support it on layout level - if( b[0] == false ) + if( !b[0] ) return @"no"; return [NSString stringWithFormat:@"yes native: %@", b[1] ? @"yes" : @"no"]; } diff --git a/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowExternalEditorsTab.mm b/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowExternalEditorsTab.mm index cdd6da922..f27955e52 100644 --- a/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowExternalEditorsTab.mm +++ b/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowExternalEditorsTab.mm @@ -30,9 +30,7 @@ static bool AskUserToDeleteEditor() [alert addButtonWithTitle:NSLocalizedString(@"OK", "")]; [alert addButtonWithTitle:NSLocalizedString(@"Cancel", "")]; [alert.buttons objectAtIndex:0].keyEquivalent = @""; - if( [alert runModal] == NSAlertFirstButtonReturn ) - return true; - return false; + return [alert runModal] == NSAlertFirstButtonReturn; } @implementation PreferencesWindowExternalEditorsTab { @@ -108,7 +106,7 @@ - (void)setExtEditors:(NSMutableArray *)ExtEditors - (PreferencesWindowExternalEditorsTabNewEditorSheet *)createEditor { PreferencesWindowExternalEditorsTabNewEditorSheet *sheet = [PreferencesWindowExternalEditorsTabNewEditorSheet new]; - sheet.hasTerminal = nc::base::AmISandboxed() == false; + sheet.hasTerminal = !nc::base::AmISandboxed(); ; return sheet; } diff --git a/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowHotkeysTab.mm b/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowHotkeysTab.mm index 2c8a26ce4..4fc2fb80e 100644 --- a/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowHotkeysTab.mm +++ b/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowHotkeysTab.mm @@ -95,7 +95,7 @@ - (id)initWithToolsStorage:(std::function)_ if( _t.first.find_first_of("menu.") != 0 ) return false; const auto menu_item = [NSApp.mainMenu itemWithTagHierarchical:_t.second]; - return menu_item == nil || menu_item.isHidden == true; + return menu_item == nil || menu_item.isHidden; }; std::erase_if(m_Shortcuts, absent); } @@ -162,7 +162,7 @@ - (void)buildData int conflicts_amount = 0; for( auto &v : m_AllNodes ) { if( auto node = std::any_cast(&v) ) { - if( node->participates_in_conflicts == false ) + if( !node->participates_in_conflicts ) continue; node->is_conflicted = node->current_shortcut && counts[node->current_shortcut] > 1; @@ -446,10 +446,7 @@ static bool ValidateNodeForFilter(const std::any &_node, NSString *_filter) return true; const auto prettry_hotkey = node->current_shortcut.PrettyString(); - if( [prettry_hotkey rangeOfString:_filter options:NSCaseInsensitiveSearch].length != 0 ) - return true; - - return false; + return [prettry_hotkey rangeOfString:_filter options:NSCaseInsensitiveSearch].length != 0; } if( auto node = std::any_cast(&_node) ) { const auto label = node->label; @@ -461,10 +458,7 @@ static bool ValidateNodeForFilter(const std::any &_node, NSString *_filter) return true; const auto app_path = [NSString stringWithUTF8StdString:node->tool->m_ExecutablePath]; - if( [app_path rangeOfString:_filter options:NSCaseInsensitiveSearch].length != 0 ) - return true; - - return false; + return [app_path rangeOfString:_filter options:NSCaseInsensitiveSearch].length != 0; } return false; diff --git a/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowPanelsTab.mm b/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowPanelsTab.mm index 00a48f166..875feb15e 100644 --- a/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowPanelsTab.mm +++ b/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowPanelsTab.mm @@ -1,21 +1,21 @@ // Copyright (C) 2013-2024 Michael Kazakov. Subject to GNU General Public License version 3. #include "PreferencesWindowPanelsTab.h" -#include -#include +#include "ConfigBinder.h" +#include "PreferencesWindowPanelsTabOperationsConcurrencySheet.h" +#include +#include #include #include -#include "PreferencesWindowPanelsTabOperationsConcurrencySheet.h" +#include +#include #include +#include +#include #include #include -#include -#include -#include -#include -#include #include #include -#include "ConfigBinder.h" +#include using namespace nc::panel; @@ -693,20 +693,11 @@ - (PanelBriefViewColumnsLayout)gatherBriefLayoutInfo if( self.layoutsBriefDynamicRadioChoosen ) l.mode = PanelBriefViewColumnsLayout::Mode::DynamicWidth; - l.fixed_mode_width = static_cast(self.layoutsBriefFixedValueTextField.intValue); - if( l.fixed_mode_width < 40 ) - l.fixed_mode_width = 40; - l.fixed_amount_value = static_cast(self.layoutsBriefAmountValueTextField.intValue); - if( l.fixed_amount_value < 1 ) - l.fixed_amount_value = 1; - l.dynamic_width_min = static_cast(self.layoutsBriefDynamicMinValueTextField.intValue); - if( l.dynamic_width_min < 40 ) - l.dynamic_width_min = 40; - l.dynamic_width_max = static_cast(self.layoutsBriefDynamicMaxValueTextField.intValue); - if( l.dynamic_width_max < 40 ) - l.dynamic_width_max = 40; - if( l.dynamic_width_max < l.dynamic_width_min ) - l.dynamic_width_max = l.dynamic_width_min; + l.fixed_mode_width = static_cast(std::max(self.layoutsBriefFixedValueTextField.intValue, 40)); + l.fixed_amount_value = static_cast(std::max(self.layoutsBriefAmountValueTextField.intValue, 1)); + l.dynamic_width_min = static_cast(std::max(self.layoutsBriefDynamicMinValueTextField.intValue, 40)); + l.dynamic_width_max = + std::max(static_cast(self.layoutsBriefDynamicMaxValueTextField.intValue), l.dynamic_width_min); l.dynamic_width_equal = self.layoutsBriefDynamicEqualCheckbox.state; l.icon_scale = [&]() -> uint8_t { if( self.layoutsBriefIcon2x.state ) diff --git a/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowTerminalTab.mm b/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowTerminalTab.mm index 13dc1d20e..3eeebf6c5 100644 --- a/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowTerminalTab.mm +++ b/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowTerminalTab.mm @@ -45,7 +45,7 @@ - (NSToolbarItem *)toolbarItem NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier:self.identifier]; item.image = self.toolbarItemImage; item.label = self.toolbarItemLabel; - item.enabled = nc::base::AmISandboxed() == false; + item.enabled = !nc::base::AmISandboxed(); return item; } diff --git a/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowThemesTab.mm b/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowThemesTab.mm index 8d9967d04..6485e44a4 100644 --- a/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowThemesTab.mm +++ b/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowThemesTab.mm @@ -331,7 +331,7 @@ - (nullable NSView *)outlineView:(NSOutlineView *) [[maybe_unused]] outlineView It (hopefuly) will reduce astonishment when user changes UI appearance of *current* theme instead of choosing a needed theme instead. */ - v.enabled = m_SelectedThemeCanBeReverted == false; + v.enabled = !m_SelectedThemeCanBeReverted; return v; } diff --git a/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowToolsTab.mm b/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowToolsTab.mm index 3c71b02f1..28c042177 100644 --- a/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowToolsTab.mm +++ b/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowToolsTab.mm @@ -38,9 +38,7 @@ static bool AskUserToDeleteTool() [alert addButtonWithTitle:NSLocalizedString(@"OK", "")]; [alert addButtonWithTitle:NSLocalizedString(@"Cancel", "")]; [alert.buttons objectAtIndex:0].keyEquivalent = @""; - if( [alert runModal] == NSAlertFirstButtonReturn ) - return true; - return false; + return [alert runModal] == NSAlertFirstButtonReturn; } @implementation PreferencesWindowToolsTab { @@ -392,7 +390,7 @@ - (BOOL)tableView:(NSTableView *) [[maybe_unused]] aTableView - (bool)haveCommandLineTools { - return nc::base::AmISandboxed() == false; + return !nc::base::AmISandboxed(); } @end diff --git a/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowViewerTab.mm b/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowViewerTab.mm index 4acca1c62..160f45653 100644 --- a/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowViewerTab.mm +++ b/Source/NimbleCommander/NimbleCommander/Preferences/PreferencesWindowViewerTab.mm @@ -31,7 +31,7 @@ - (id)transformedValue:(id)value - (id)reverseTransformedValue:(id)value { if( auto n = nc::objc_cast(value) ) - return [NSNumber numberWithBool:n.intValue == 0 ? false : true]; + return [NSNumber numberWithBool:n.intValue != 0]; return nil; } @end diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/BatchRename.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/BatchRename.mm index 78430a714..8ba6de14a 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/BatchRename.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/BatchRename.mm @@ -25,7 +25,7 @@ return true; } -void BatchRename::Perform(PanelController *_target, id) const +void BatchRename::Perform(PanelController *_target, id /*_sender*/) const { const auto items = _target.selectedEntriesOrFocusedEntry; if( items.empty() ) diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/CalculateSizes.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/CalculateSizes.mm index bde54912c..78aafb7be 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/CalculateSizes.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/CalculateSizes.mm @@ -15,14 +15,14 @@ return i && (i.IsDir() || _target.data.Stats().selected_dirs_amount > 0); } -void CalculateSizes::Perform(PanelController *_target, id) const +void CalculateSizes::Perform(PanelController *_target, id /*_sender*/) const { auto selected = _target.selectedEntriesOrFocusedEntryWithDotDot; std::erase_if(selected, [](auto &v) { return !v.IsDir(); }); [_target calculateSizesOfItems:selected]; } -void CalculateAllSizes::Perform(PanelController *_target, id) const +void CalculateAllSizes::Perform(PanelController *_target, id /*_sender*/) const { std::vector items; auto &data = _target.data; diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Compress.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Compress.mm index 2bb19f5cc..f360d839c 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Compress.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Compress.mm @@ -57,7 +57,7 @@ return !i.IsDotDot() || _target.data.Stats().selected_entries_amount > 0; } -void CompressHere::Perform(PanelController *_target, id) const +void CompressHere::Perform(PanelController *_target, id /*_sender*/) const { auto entries = _target.selectedEntriesOrFocusedEntry; if( entries.empty() ) @@ -105,7 +105,7 @@ return opposite.isUniform && opposite.vfs->IsWritable(); } -void CompressToOpposite::Perform(PanelController *_target, id) const +void CompressToOpposite::Perform(PanelController *_target, id /*_sender*/) const { const auto opposite_panel = FindVisibleOppositeController(_target); if( !opposite_panel.isUniform || !opposite_panel.vfs->IsWritable() ) @@ -165,7 +165,7 @@ return Predicate(_target); } -void context::CompressHere::Perform(PanelController *_target, id) const +void context::CompressHere::Perform(PanelController *_target, id /*_sender*/) const { auto entries = m_Items; auto op = std::make_shared(std::move(entries), _target.currentDirectoryPath, _target.vfs); @@ -212,7 +212,7 @@ return Predicate(_target); } -void context::CompressToOpposite::Perform(PanelController *_target, id) const +void context::CompressToOpposite::Perform(PanelController *_target, id /*_sender*/) const { const auto opposite_panel = FindVisibleOppositeController(_target); if( !opposite_panel.isUniform || !opposite_panel.vfs->IsWritable() ) diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/CopyFile.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/CopyFile.mm index 23d38a4fb..e385bff16 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/CopyFile.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/CopyFile.mm @@ -62,7 +62,7 @@ return true; } -void CopyTo::Perform(MainWindowFilePanelState *_target, id) const +void CopyTo::Perform(MainWindowFilePanelState *_target, id /*_sender*/) const { const auto act_pc = _target.activePanelController; const auto opp_pc = _target.oppositePanelController; @@ -126,7 +126,7 @@ return true; } -void CopyAs::Perform(MainWindowFilePanelState *_target, id) const +void CopyAs::Perform(MainWindowFilePanelState *_target, id /*_sender*/) const { const auto act_pc = _target.activePanelController; if( !act_pc ) @@ -203,7 +203,7 @@ return true; } -void MoveTo::Perform(MainWindowFilePanelState *_target, id) const +void MoveTo::Perform(MainWindowFilePanelState *_target, id /*_sender*/) const { const auto act_pc = _target.activePanelController; const auto opp_pc = _target.oppositePanelController; @@ -264,7 +264,7 @@ return true; } -void MoveAs::Perform(MainWindowFilePanelState *_target, id) const +void MoveAs::Perform(MainWindowFilePanelState *_target, id /*_sender*/) const { const auto act_pc = _target.activePanelController; if( !act_pc ) diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/CopyFilePaths.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/CopyFilePaths.mm index 8fd9d2d8f..40f7ed9f4 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/CopyFilePaths.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/CopyFilePaths.mm @@ -38,7 +38,7 @@ static void WriteSingleStringToClipboard(const std::string &_s) return _source.view.item; } -void CopyFileName::Perform(PanelController *_source, id) const +void CopyFileName::Perform(PanelController *_source, id /*_sender*/) const { const auto entries = _source.selectedEntriesOrFocusedEntry; const auto result = @@ -48,7 +48,7 @@ static void WriteSingleStringToClipboard(const std::string &_s) WriteSingleStringToClipboard(result); } -void CopyFilePath::Perform(PanelController *_source, id) const +void CopyFilePath::Perform(PanelController *_source, id /*_sender*/) const { const auto entries = _source.selectedEntriesOrFocusedEntry; const auto result = @@ -58,7 +58,7 @@ static void WriteSingleStringToClipboard(const std::string &_s) WriteSingleStringToClipboard(result); } -void CopyFileDirectory::Perform(PanelController *_source, id) const +void CopyFileDirectory::Perform(PanelController *_source, id /*_sender*/) const { const auto entries = _source.selectedEntriesOrFocusedEntry; const auto result = diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/CopyToPasteboard.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/CopyToPasteboard.mm index f00a4e30c..b178c0bd4 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/CopyToPasteboard.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/CopyToPasteboard.mm @@ -45,7 +45,7 @@ NSBeep(); } -void CopyToPasteboard::Perform(PanelController *_target, id) const +void CopyToPasteboard::Perform(PanelController *_target, id /*_sender*/) const { PerformWithItems(_target.selectedEntriesOrFocusedEntryWithDotDot); } @@ -77,7 +77,7 @@ return Predicate(_target); } -void context::CopyToPasteboard::Perform([[maybe_unused]] PanelController *_target, id) const +void context::CopyToPasteboard::Perform([[maybe_unused]] PanelController *_target, id /*_sender*/) const { PerformWithItems(m_Items); } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/DefaultAction.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/DefaultAction.mm index f2cf90994..7629295ea 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/DefaultAction.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/DefaultAction.mm @@ -1,37 +1,37 @@ -// Copyright (C) 2017-2019 Michael Kazakov. Subject to GNU General Public License version 3. +// Copyright (C) 2017-2024 Michael Kazakov. Subject to GNU General Public License version 3. #include "DefaultAction.h" namespace nc::panel::actions { PanelAction::~PanelAction() = default; -bool PanelAction::Predicate(PanelController *) const +bool PanelAction::Predicate(PanelController * /*_target*/) const { return true; } -bool PanelAction::ValidateMenuItem(PanelController *_target, NSMenuItem *) const +bool PanelAction::ValidateMenuItem(PanelController *_target, NSMenuItem * /*_item*/) const { return Predicate(_target); } -void PanelAction::Perform(PanelController *, id) const +void PanelAction::Perform(PanelController * /*_target*/, id /*_sender*/) const { } StateAction::~StateAction() = default; -bool StateAction::Predicate(MainWindowFilePanelState *) const +bool StateAction::Predicate(MainWindowFilePanelState * /*_target*/) const { return true; } -bool StateAction::ValidateMenuItem(MainWindowFilePanelState *_target, NSMenuItem *) const +bool StateAction::ValidateMenuItem(MainWindowFilePanelState *_target, NSMenuItem * /*_item*/) const { return Predicate(_target); } -void StateAction::Perform(MainWindowFilePanelState *, id) const +void StateAction::Perform(MainWindowFilePanelState * /*_target*/, id /*_sender*/) const { } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Delete.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Delete.mm index 674877402..b37fcdc93 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Delete.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Delete.mm @@ -32,7 +32,7 @@ return CommonDeletePredicate(_target); } -void Delete::Perform(PanelController *_target, id) const +void Delete::Perform(PanelController *_target, id /*_sender*/) const { auto items = to_shared_ptr(_target.selectedEntriesOrFocusedEntry); if( items->empty() ) @@ -103,12 +103,12 @@ m_AllAreNative = AllAreNative(m_Items); } -bool context::MoveToTrash::Predicate(PanelController *) const +bool context::MoveToTrash::Predicate(PanelController * /*_target*/) const { return m_AllAreNative; } -void context::MoveToTrash::Perform(PanelController *_target, id) const +void context::MoveToTrash::Perform(PanelController *_target, id /*_sender*/) const { const auto operation = std::make_shared(m_Items, nc::ops::DeletionType::Trash); AddPanelRefreshEpilog(_target, *operation); @@ -120,12 +120,12 @@ m_AllWriteable = std::ranges::all_of(m_Items, [](const auto &i) { return i.Host()->IsWritable(); }); } -bool context::DeletePermanently::Predicate(PanelController *) const +bool context::DeletePermanently::Predicate(PanelController * /*_target*/) const { return m_AllWriteable; } -void context::DeletePermanently::Perform(PanelController *_target, id) const +void context::DeletePermanently::Perform(PanelController *_target, id /*_sender*/) const { const auto operation = std::make_shared(m_Items, nc::ops::DeletionType::Permanent); AddPanelRefreshEpilog(_target, *operation); diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Duplicate.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Duplicate.mm index 1e7b1e60a..23ab0686a 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Duplicate.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Duplicate.mm @@ -88,7 +88,7 @@ static void CommonPerform(PanelController *_target, const std::vectorIsWritable(); } -void context::Duplicate::Perform(PanelController *_target, id) const +void context::Duplicate::Perform(PanelController *_target, id /*_sender*/) const { CommonPerform(_target, m_Items, m_Config.GetBool(g_DeselectConfigFlag)); } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ExecuteInTerminal.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ExecuteInTerminal.mm index 4c6db5eeb..a47bcb8f1 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ExecuteInTerminal.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ExecuteInTerminal.mm @@ -30,7 +30,7 @@ return Predicate(_target); } -void ExecuteInTerminal::Perform(PanelController *_target, id) const +void ExecuteInTerminal::Perform(PanelController *_target, id /*_sender*/) const { if( !Predicate(_target) ) return; diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/FindFiles.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/FindFiles.mm index 8efca013d..b22ee29a0 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/FindFiles.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/FindFiles.mm @@ -36,7 +36,7 @@ static VFSListingPtr FetchSearchResultsAsListing(const std::vector for( auto &p : _filepaths ) { VFSListingPtr listing; - const int ret = p.Host()->FetchSingleItemListing(p.Path().c_str(), listing, _fetch_flags, _cancel_checker); + const int ret = p.Host()->FetchSingleItemListing(p.Path(), listing, _fetch_flags, _cancel_checker); if( ret == 0 ) listings.emplace_back(listing); @@ -47,7 +47,7 @@ static VFSListingPtr FetchSearchResultsAsListing(const std::vector return VFSListing::Build(VFSListing::Compose(listings)); } -void FindFiles::Perform(PanelController *_target, id) const +void FindFiles::Perform(PanelController *_target, id /*_sender*/) const { FindFilesSheetController *const sheet = [FindFilesSheetController new]; sheet.vfsInstanceManager = &_target.vfsInstanceManager; diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/FollowSymlink.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/FollowSymlink.mm index 0cea38e58..6de606ec9 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/FollowSymlink.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/FollowSymlink.mm @@ -30,7 +30,7 @@ if( !item ) return; - if( item.IsSymlink() == false || item.HasSymlink() == false ) + if( !item.IsSymlink() || !item.HasSymlink() ) return; // poor man's symlink resolution: diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/GoToFolder.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/GoToFolder.mm index 07a809ef0..7be9ab9a6 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/GoToFolder.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/GoToFolder.mm @@ -22,7 +22,7 @@ using namespace std::literals; -void GoToFolder::Perform(PanelController *_target, id) const +void GoToFolder::Perform(PanelController *_target, id /*_sender*/) const { GoToFolderSheetController *const sheet = [GoToFolderSheetController new]; sheet.panel = _target; @@ -51,27 +51,27 @@ static void GoToNativeDir(const std::string &_path, PanelController *_target) [_target GoToDirWithContext:request]; } -void GoToHomeFolder::Perform(PanelController *_target, id) const +void GoToHomeFolder::Perform(PanelController *_target, id /*_sender*/) const { GoToNativeDir(base::CommonPaths::Home(), _target); } -void GoToDocumentsFolder::Perform(PanelController *_target, id) const +void GoToDocumentsFolder::Perform(PanelController *_target, id /*_sender*/) const { GoToNativeDir(base::CommonPaths::Documents(), _target); } -void GoToDesktopFolder::Perform(PanelController *_target, id) const +void GoToDesktopFolder::Perform(PanelController *_target, id /*_sender*/) const { GoToNativeDir(base::CommonPaths::Desktop(), _target); } -void GoToDownloadsFolder::Perform(PanelController *_target, id) const +void GoToDownloadsFolder::Perform(PanelController *_target, id /*_sender*/) const { GoToNativeDir(base::CommonPaths::Downloads(), _target); } -void GoToApplicationsFolder::Perform(PanelController *_target, id) const +void GoToApplicationsFolder::Perform(PanelController *_target, id /*_sender*/) const { if( utility::GetOSXVersion() < utility::OSXVersion::OSX_15 ) { GoToNativeDir(base::CommonPaths::Applications(), _target); @@ -89,7 +89,7 @@ static void GoToNativeDir(const std::string &_path, PanelController *_target) } } -void GoToUtilitiesFolder::Perform(PanelController *_target, id) const +void GoToUtilitiesFolder::Perform(PanelController *_target, id /*_sender*/) const { if( utility::GetOSXVersion() < utility::OSXVersion::OSX_15 ) { GoToNativeDir(base::CommonPaths::Utilities(), _target); @@ -107,17 +107,17 @@ static void GoToNativeDir(const std::string &_path, PanelController *_target) } } -void GoToLibraryFolder::Perform(PanelController *_target, id) const +void GoToLibraryFolder::Perform(PanelController *_target, id /*_sender*/) const { GoToNativeDir(base::CommonPaths::Library(), _target); } -void GoToRootFolder::Perform(PanelController *_target, id) const +void GoToRootFolder::Perform(PanelController *_target, id /*_sender*/) const { GoToNativeDir(base::CommonPaths::Root(), _target); } -void GoToProcessesList::Perform(PanelController *_target, id) const +void GoToProcessesList::Perform(PanelController *_target, id /*_sender*/) const { auto request = std::make_shared(); request->RequestedDirectory = "/"; @@ -256,7 +256,7 @@ static bool IsItemInArchivesWhitelist(const VFSListingItem &_item) noexcept return Predicate(_target); } -void GoIntoFolder::Perform(PanelController *_target, id) const +void GoIntoFolder::Perform(PanelController *_target, id /*_sender*/) const { const auto item = _target.view.item; if( !item ) diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Link.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Link.mm index 1db16429c..b28c9bd8b 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Link.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Link.mm @@ -39,7 +39,7 @@ return true; } -void CreateSymlink::Perform(PanelController *_target, id) const +void CreateSymlink::Perform(PanelController *_target, id /*_sender*/) const { const auto item = _target.view.item; if( !item ) @@ -81,7 +81,7 @@ return item && item.IsSymlink() && item.Host()->IsWritable(); } -void AlterSymlink::Perform(PanelController *_target, id) const +void AlterSymlink::Perform(PanelController *_target, id /*_sender*/) const { const auto item = _target.view.item; if( !item || !item.IsSymlink() ) @@ -113,7 +113,7 @@ return item && !item.IsDir() && item.Host()->IsNativeFS(); } -void CreateHardlink::Perform(PanelController *_target, id) const +void CreateHardlink::Perform(PanelController *_target, id /*_sender*/) const { if( !Predicate(_target) ) return; diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/MakeNew.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/MakeNew.mm index b97a4b396..c7d315089 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/MakeNew.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/MakeNew.mm @@ -116,7 +116,7 @@ static void ScheduleFocus(const std::string &_filename, PanelController *_panel) return _target.isUniform && _target.vfs->IsWritable(); } -void MakeNewFile::Perform(PanelController *_target, id) const +void MakeNewFile::Perform(PanelController *_target, id /*_sender*/) const { const std::filesystem::path dir = _target.currentDirectoryPath; const VFSHostPtr vfs = _target.vfs; @@ -156,7 +156,7 @@ static void ScheduleFocus(const std::string &_filename, PanelController *_panel) return _target.isUniform && _target.vfs->IsWritable(); } -void MakeNewFolder::Perform(PanelController *_target, id) const +void MakeNewFolder::Perform(PanelController *_target, id /*_sender*/) const { const std::filesystem::path dir = _target.currentDirectoryPath; const VFSHostPtr vfs = _target.vfs; @@ -188,7 +188,7 @@ static void ScheduleFocus(const std::string &_filename, PanelController *_panel) (!item.IsDotDot() || _target.data.Stats().selected_entries_amount > 0); } -void MakeNewFolderWithSelection::Perform(PanelController *_target, id) const +void MakeNewFolderWithSelection::Perform(PanelController *_target, id /*_sender*/) const { const std::filesystem::path dir = _target.currentDirectoryPath; const VFSHostPtr vfs = _target.vfs; @@ -234,7 +234,7 @@ static bool ValidateDirectoryInput(const std::string &_text) return _text.find_first_of(invalid_chars) == std::string::npos; } -void MakeNewNamedFolder::Perform(PanelController *_target, id) const +void MakeNewNamedFolder::Perform(PanelController *_target, id /*_sender*/) const { const auto cd = [[NCOpsDirectoryCreationDialog alloc] init]; if( const auto item = _target.view.item ) diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/NavigateHistory.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/NavigateHistory.mm index 1500b6f9d..a304dc331 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/NavigateHistory.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/NavigateHistory.mm @@ -12,7 +12,7 @@ return _target.history.CanMoveBack(); } -void GoBack::Perform(PanelController *_target, id) const +void GoBack::Perform(PanelController *_target, id /*_sender*/) const { auto &history = _target.history; if( !history.CanMoveBack() ) @@ -28,7 +28,7 @@ return _target.history.CanMoveForth(); } -void GoForward::Perform(PanelController *_target, id) const +void GoForward::Perform(PanelController *_target, id /*_sender*/) const { auto &history = _target.history; if( !history.CanMoveForth() ) diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/OpenFile.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/OpenFile.mm index 79bd76b76..5e554f213 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/OpenFile.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/OpenFile.mm @@ -26,7 +26,7 @@ static bool CommonPredicate(PanelController *_target) static bool ShouldRebuildSubmenu(NSMenuItem *_item) noexcept { - return _item.hasSubmenu == false || objc_cast(_item.submenu.delegate) == nil; + return !_item.hasSubmenu || objc_cast(_item.submenu.delegate) == nil; } OpenFileWithSubmenu::OpenFileWithSubmenu(NCPanelOpenWithMenuDelegate *_menu_delegate) : m_MenuDelegate(_menu_delegate) @@ -97,7 +97,7 @@ static bool ShouldRebuildSubmenu(NSMenuItem *_item) noexcept return Predicate(_target); } -void OpenFilesWithDefaultHandler::Perform(PanelController *_target, id) const +void OpenFilesWithDefaultHandler::Perform(PanelController *_target, id /*_sender*/) const { if( !Predicate(_target) ) { NSBeep(); @@ -149,7 +149,7 @@ static void PerformOpeningFilesWithDefaultHandler(const std::vectorOpenInTerminal() == false ) + if( !ed->OpenInTerminal() ) m_FileOpener.Open(item.Path(), item.Host(), ed->Path(), _target); else m_FileOpener.OpenInExternalEditorTerminal(item.Path(), item.Host(), ed, item.Filename(), _target); diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/OpenXAttr.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/OpenXAttr.mm index dc96d335e..27674c124 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/OpenXAttr.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/OpenXAttr.mm @@ -13,7 +13,7 @@ return i && i.Host()->IsNativeFS(); } -void OpenXAttr::Perform(PanelController *_target, id) const +void OpenXAttr::Perform(PanelController *_target, id /*_sender*/) const { if( !Predicate(_target) ) return; diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/RefreshPanel.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/RefreshPanel.mm index 4e466e9be..2085d2a9f 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/RefreshPanel.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/RefreshPanel.mm @@ -4,7 +4,7 @@ namespace nc::panel::actions { -void RefreshPanel::Perform(PanelController *_target, id) const +void RefreshPanel::Perform(PanelController *_target, id /*_sender*/) const { [_target forceRefreshPanel]; } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/RenameInPlace.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/RenameInPlace.mm index 8086f5e39..92ac62335 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/RenameInPlace.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/RenameInPlace.mm @@ -12,7 +12,7 @@ return item && !item.IsDotDot() && item.Host()->IsWritable(); } -void RenameInPlace::Perform(PanelController *_target, id) const +void RenameInPlace::Perform(PanelController *_target, id /*_sender*/) const { [_target.view startFieldEditorRenaming]; } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/RevealInOppositePanel.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/RevealInOppositePanel.mm index 516a9d96f..dae249696 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/RevealInOppositePanel.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/RevealInOppositePanel.mm @@ -39,7 +39,7 @@ static void RevealItem(const VFSListingItem &_item, PanelController *_panel) [_panel GoToDirWithContext:request]; } -void RevealInOppositePanel::Perform(MainWindowFilePanelState *_target, id) const +void RevealInOppositePanel::Perform(MainWindowFilePanelState *_target, id /*_sender*/) const { const auto current = _target.activePanelController; const auto opposite = _target.oppositePanelController; @@ -81,7 +81,7 @@ static void RevealItem(const VFSListingItem &_item, PanelController *_panel) return nil; } -void RevealInOppositePanelTab::Perform(MainWindowFilePanelState *_target, id) const +void RevealInOppositePanelTab::Perform(MainWindowFilePanelState *_target, id /*_sender*/) const { const auto current = _target.activePanelController; if( !current ) diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Select.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Select.mm index c8642abaf..9f91aa251 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Select.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/Select.mm @@ -57,17 +57,17 @@ static ptrdiff_t ToNumber(NSWindow *_wnd) noexcept static const auto g_SelectWithMaskHistoryPath = "filePanel.selectWithMaskPopup.masks"; [[clang::no_destroy]] static PerWindowMaskStorage g_PerWindowMasks; -void SelectAll::Perform(PanelController *_target, id) const +void SelectAll::Perform(PanelController *_target, id /*_sender*/) const { [_target setEntriesSelection:std::vector(_target.data.SortedEntriesCount(), true)]; } -void DeselectAll::Perform(PanelController *_target, id) const +void DeselectAll::Perform(PanelController *_target, id /*_sender*/) const { [_target setEntriesSelection:std::vector(_target.data.SortedEntriesCount(), false)]; } -void InvertSelection::Perform(PanelController *_target, id) const +void InvertSelection::Perform(PanelController *_target, id /*_sender*/) const { auto selector = data::SelectionBuilder(_target.data); [_target setEntriesSelection:selector.InvertSelection()]; @@ -82,7 +82,7 @@ static ptrdiff_t ToNumber(NSWindow *_wnd) noexcept return _target.view.item; } -void SelectAllByExtension::Perform(PanelController *_target, id) const +void SelectAllByExtension::Perform(PanelController *_target, id /*_sender*/) const { auto item = _target.view.item; if( !item ) @@ -108,7 +108,7 @@ static void CommitRecentFindFilesMask(const nc::panel::FindFilesMask &_mask) StoreFindFilesMasks(StateConfig(), g_SelectWithMaskHistoryPath, history); } -void SelectAllByMask::Perform(PanelController *_target, id) const +void SelectAllByMask::Perform(PanelController *_target, id /*_sender*/) const { const auto history = LoadFindFilesMasks(StateConfig(), g_SelectWithMaskHistoryPath); const auto initial = g_PerWindowMasks.InitialMask(_target.window); diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowGoToPopup.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowGoToPopup.mm index 731e02099..6875a6db6 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowGoToPopup.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowGoToPopup.mm @@ -215,7 +215,7 @@ - (void)commandPopoverDidClose:(NCCommandPopover *_Nonnull)_popover { std::vector> volumes; for( auto &i : _native_fs_manager.Volumes() ) - if( i->mount_flags.dont_browse == false ) + if( !i->mount_flags.dont_browse ) volumes.emplace_back(i); return volumes; } @@ -559,19 +559,19 @@ static void PopupQuickList(NCCommandPopover *_popover, GoToPopupListActionMediat alignment:NCCommandPopoverAlignment::Center]; } -void ShowConnectionsQuickList::Perform(PanelController *_target, id) const +void ShowConnectionsQuickList::Perform(PanelController *_target, id /*_sender*/) const { const auto menu = BuildConnectionsQuickList(_target); PopupQuickList(menu.first, menu.second, _target); } -void ShowFavoritesQuickList::Perform(PanelController *_target, id) const +void ShowFavoritesQuickList::Perform(PanelController *_target, id /*_sender*/) const { const auto menu = BuildFavoritesQuickList(_target); PopupQuickList(menu.first, menu.second, _target); } -void ShowVolumesQuickList::Perform(PanelController *_target, id) const +void ShowVolumesQuickList::Perform(PanelController *_target, id /*_sender*/) const { const auto menu = BuildVolumesQuickList(_target); PopupQuickList(menu.first, menu.second, _target); @@ -582,13 +582,13 @@ static void PopupQuickList(NCCommandPopover *_popover, GoToPopupListActionMediat return _target.isUniform; } -void ShowParentFoldersQuickList::Perform(PanelController *_target, id) const +void ShowParentFoldersQuickList::Perform(PanelController *_target, id /*_sender*/) const { const auto menu = BuildParentFoldersQuickList(_target); PopupQuickList(menu.first, menu.second, _target); } -void ShowHistoryQuickList::Perform(PanelController *_target, id) const +void ShowHistoryQuickList::Perform(PanelController *_target, id /*_sender*/) const { const auto menu = BuildHistoryQuickList(_target); PopupQuickList(menu.first, menu.second, _target); @@ -602,12 +602,12 @@ static void PopupQuickList(NCCommandPopover *_popover, GoToPopupListActionMediat { } -bool ShowTagsQuickList::Predicate(PanelController *) const +bool ShowTagsQuickList::Predicate(PanelController * /*_target*/) const { return m_Config.GetBool("filePanel.FinderTags.enable"); } -void ShowTagsQuickList::Perform(PanelController *_target, id) const +void ShowTagsQuickList::Perform(PanelController *_target, id /*_sender*/) const { const auto menu = BuildTagsQuickList(_target); PopupQuickList(menu.first, menu.second, _target); diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowQuickLook.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowQuickLook.mm index c35b55ec1..1a517a037 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowQuickLook.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowQuickLook.mm @@ -10,17 +10,14 @@ bool ShowQuickLook::Predicate(PanelController *_target) const { - if( !_target.view.item ) - return false; - - return true; + return _target.view.item; } void ShowQuickLook::Perform(PanelController *_target, [[maybe_unused]] id _sender) const { const auto state = _target.state; - if( ShowQuickLookAsFloatingPanel() == false ) { + if( !ShowQuickLookAsFloatingPanel() ) { if( state.anyPanelCollapsed ) { if( [state isLeftController:_target] ) [state.splitView expandRightView]; diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowSystemOverview.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowSystemOverview.mm index 32dd33660..1a89c67f0 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowSystemOverview.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowSystemOverview.mm @@ -10,7 +10,7 @@ return !_target.state.anyPanelCollapsed; } -void ShowSystemOverview::Perform(PanelController *_target, id) const +void ShowSystemOverview::Perform(PanelController *_target, id /*_sender*/) const { const auto state = _target.state; diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowTabs.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowTabs.mm index f65566922..73e75355f 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowTabs.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowTabs.mm @@ -14,7 +14,7 @@ return Predicate(_target); } -void ShowTabs::Perform([[maybe_unused]] MainWindowFilePanelState *_target, id) const +void ShowTabs::Perform([[maybe_unused]] MainWindowFilePanelState *_target, id /*_sender*/) const { const auto shown = GlobalConfig().GetBool(g_ConfigGeneralShowTabs); GlobalConfig().Set(g_ConfigGeneralShowTabs, !shown); diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowTerminal.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowTerminal.mm index 459a903ff..4ed0fa713 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowTerminal.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowTerminal.mm @@ -17,7 +17,7 @@ void ShowTerminal::Perform(MainWindowFilePanelState *_target, [[maybe_unused]] id _sender) const { - std::string path = ""; + std::string path; if( auto pc = _target.activePanelController ) if( pc.isUniform && pc.vfs->IsNativeFS() ) diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowVolumeInformation.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowVolumeInformation.mm index 89af657f7..90a2ea481 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowVolumeInformation.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ShowVolumeInformation.mm @@ -16,7 +16,7 @@ return _target.isUniform && _target.vfs->IsNativeFS(); } -void ShowVolumeInformation::Perform(PanelController *_target, id) const +void ShowVolumeInformation::Perform(PanelController *_target, id /*_sender*/) const { std::string path; if( auto i = _target.view.item ) { diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/SpotlightSearch.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/SpotlightSearch.mm index a954a736b..b2f958696 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/SpotlightSearch.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/SpotlightSearch.mm @@ -92,7 +92,7 @@ static VFSListingPtr FetchSearchResultsAsListing(const std::vector for( auto &p : _file_paths ) { VFSListingPtr listing; - const int ret = _vfs.FetchSingleItemListing(p.c_str(), listing, _fetch_flags, _cancel_checker); + const int ret = _vfs.FetchSingleItemListing(p, listing, _fetch_flags, _cancel_checker); if( ret == 0 ) listings.emplace_back(listing); } @@ -100,7 +100,7 @@ static VFSListingPtr FetchSearchResultsAsListing(const std::vector return VFSListing::Build(VFSListing::Compose(listings)); } -void SpotlightSearch::Perform(PanelController *_target, id) const +void SpotlightSearch::Perform(PanelController *_target, id /*_sender*/) const { const auto view = [[SpotlightSearchPopupViewController alloc] init]; __weak PanelController *wp = _target; diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/SyncPanels.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/SyncPanels.mm index e6d8cb5ba..b5425562d 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/SyncPanels.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/SyncPanels.mm @@ -19,7 +19,7 @@ return true; } -void SyncPanels::Perform(MainWindowFilePanelState *_target, id) const +void SyncPanels::Perform(MainWindowFilePanelState *_target, id /*_sender*/) const { if( _target.splitView.anyCollapsedOrOverlayed ) return; @@ -48,7 +48,7 @@ return _target.isPanelActive && !_target.splitView.anyCollapsedOrOverlayed; } -void SwapPanels::Perform(MainWindowFilePanelState *_target, id) const +void SwapPanels::Perform(MainWindowFilePanelState *_target, id /*_sender*/) const { [_target swapPanels]; } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/TabsManagement.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/TabsManagement.mm index bca6b4f89..8d158952d 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/TabsManagement.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/TabsManagement.mm @@ -16,12 +16,12 @@ return _target.currentSideTabsCount > 1; } -bool ShowNextTab::ValidateMenuItem(MainWindowFilePanelState *_target, NSMenuItem *) const +bool ShowNextTab::ValidateMenuItem(MainWindowFilePanelState *_target, NSMenuItem * /*_item*/) const { return Predicate(_target); } -void ShowNextTab::Perform(MainWindowFilePanelState *_target, id) const +void ShowNextTab::Perform(MainWindowFilePanelState *_target, id /*_sender*/) const { [_target selectNextFilePanelTab]; } @@ -31,12 +31,12 @@ return _target.currentSideTabsCount > 1; } -bool ShowPreviousTab::ValidateMenuItem(MainWindowFilePanelState *_target, NSMenuItem *) const +bool ShowPreviousTab::ValidateMenuItem(MainWindowFilePanelState *_target, NSMenuItem * /*_item*/) const { return Predicate(_target); } -void ShowPreviousTab::Perform(MainWindowFilePanelState *_target, id) const +void ShowPreviousTab::Perform(MainWindowFilePanelState *_target, id /*_sender*/) const { [_target selectPreviousFilePanelTab]; } @@ -123,7 +123,7 @@ return amount_of_tab_on_this_side > 1; } -void CloseOtherTabs::Perform(MainWindowFilePanelState *_target, id) const +void CloseOtherTabs::Perform(MainWindowFilePanelState *_target, id /*_sender*/) const { if( !Predicate(_target) ) return; @@ -141,7 +141,7 @@ [_target.window performClose:_sender]; } -void AddNewTab::Perform(MainWindowFilePanelState *_target, id) const +void AddNewTab::Perform(MainWindowFilePanelState *_target, id /*_sender*/) const { const auto active_pc = _target.activePanelController; if( !active_pc ) @@ -164,7 +164,7 @@ { } -void context::AddNewTab::Perform(MainWindowFilePanelState *_target, id) const +void context::AddNewTab::Perform(MainWindowFilePanelState *_target, id /*_sender*/) const { NSTabView *target_tab_view = nil; @@ -192,7 +192,7 @@ return false; } -void context::CloseTab::Perform(MainWindowFilePanelState *_target, id) const +void context::CloseTab::Perform(MainWindowFilePanelState *_target, id /*_sender*/) const { [_target closeTabForController:m_CurrentPC]; } @@ -210,7 +210,7 @@ return false; } -void context::CloseOtherTabs::Perform(MainWindowFilePanelState *_target, id) const +void context::CloseOtherTabs::Perform(MainWindowFilePanelState *_target, id /*_sender*/) const { [_target closeOtherTabsForController:m_CurrentPC]; } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ToggleSingleOrDualMode.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ToggleSingleOrDualMode.mm index cc6a7721f..8ded81dd9 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ToggleSingleOrDualMode.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ToggleSingleOrDualMode.mm @@ -17,7 +17,7 @@ return Predicate(_target); } -void ToggleSingleOrDualMode::Perform(MainWindowFilePanelState *_target, id) const +void ToggleSingleOrDualMode::Perform(MainWindowFilePanelState *_target, id /*_sender*/) const { const auto split_view = _target.splitView; if( split_view.anyCollapsed ) { diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ToggleSort.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ToggleSort.mm index 238ba628c..eb82a9e2e 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ToggleSort.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ToggleSort.mm @@ -70,7 +70,7 @@ return Predicate(_target); } -void ToggleSortingByName::Perform(PanelController *_target, id) const +void ToggleSortingByName::Perform(PanelController *_target, id /*_sender*/) const { [_target changeSortingModeTo:EnforceAndSwitch(_target.data.SortMode(), data::SortMode::SortByName, @@ -83,7 +83,7 @@ return Predicate(_target); } -void ToggleSortingByExtension::Perform(PanelController *_target, id) const +void ToggleSortingByExtension::Perform(PanelController *_target, id /*_sender*/) const { [_target changeSortingModeTo:EnforceAndSwitch( _target.data.SortMode(), data::SortMode::SortByExt, data::SortMode::SortByExtRev)]; @@ -95,7 +95,7 @@ return Predicate(_target); } -void ToggleSortingBySize::Perform(PanelController *_target, id) const +void ToggleSortingBySize::Perform(PanelController *_target, id /*_sender*/) const { [_target changeSortingModeTo:EnforceAndSwitch(_target.data.SortMode(), data::SortMode::SortBySize, @@ -108,7 +108,7 @@ return Predicate(_target); } -void ToggleSortingByModifiedTime::Perform(PanelController *_target, id) const +void ToggleSortingByModifiedTime::Perform(PanelController *_target, id /*_sender*/) const { [_target changeSortingModeTo:EnforceAndSwitch(_target.data.SortMode(), data::SortMode::SortByModTime, @@ -122,7 +122,7 @@ return Predicate(_target); } -void ToggleSortingByCreatedTime::Perform(PanelController *_target, id) const +void ToggleSortingByCreatedTime::Perform(PanelController *_target, id /*_sender*/) const { [_target changeSortingModeTo:EnforceAndSwitch(_target.data.SortMode(), data::SortMode::SortByBirthTime, @@ -135,7 +135,7 @@ return Predicate(_target); } -void ToggleSortingByAddedTime::Perform(PanelController *_target, id) const +void ToggleSortingByAddedTime::Perform(PanelController *_target, id /*_sender*/) const { [_target changeSortingModeTo:EnforceAndSwitch(_target.data.SortMode(), data::SortMode::SortByAddTime, @@ -149,7 +149,7 @@ return Predicate(_target); } -void ToggleSortingByAccessedTime::Perform(PanelController *_target, id) const +void ToggleSortingByAccessedTime::Perform(PanelController *_target, id /*_sender*/) const { [_target changeSortingModeTo:EnforceAndSwitch(_target.data.SortMode(), data::SortMode::SortByAccessTime, @@ -162,7 +162,7 @@ return Predicate(_target); } -void ToggleSortingNaturalCollation::Perform(PanelController *_target, id) const +void ToggleSortingNaturalCollation::Perform(PanelController *_target, id /*_sender*/) const { auto mode = _target.data.SortMode(); mode.collation = data::SortMode::Collation::Natural; @@ -175,7 +175,7 @@ return Predicate(_target); } -void ToggleSortingCaseInsensitiveCollation::Perform(PanelController *_target, id) const +void ToggleSortingCaseInsensitiveCollation::Perform(PanelController *_target, id /*_sender*/) const { auto mode = _target.data.SortMode(); mode.collation = data::SortMode::Collation::CaseInsensitive; @@ -188,7 +188,7 @@ return Predicate(_target); } -void ToggleSortingCaseSensitiveCollation::Perform(PanelController *_target, id) const +void ToggleSortingCaseSensitiveCollation::Perform(PanelController *_target, id /*_sender*/) const { auto mode = _target.data.SortMode(); mode.collation = data::SortMode::Collation::CaseSensitive; @@ -201,7 +201,7 @@ return Predicate(_target); } -void ToggleSortingFoldersSeparation::Perform(PanelController *_target, id) const +void ToggleSortingFoldersSeparation::Perform(PanelController *_target, id /*_sender*/) const { auto mode = _target.data.SortMode(); mode.sep_dirs = !mode.sep_dirs; @@ -214,7 +214,7 @@ return Predicate(_target); } -void ToggleSortingExtensionlessFolders::Perform(PanelController *_target, id) const +void ToggleSortingExtensionlessFolders::Perform(PanelController *_target, id /*_sender*/) const { auto mode = _target.data.SortMode(); mode.extensionless_dirs = !mode.extensionless_dirs; @@ -227,7 +227,7 @@ return Predicate(_target); } -void ToggleSortingShowHidden::Perform(PanelController *_target, id) const +void ToggleSortingShowHidden::Perform(PanelController *_target, id /*_sender*/) const { auto filtering = _target.data.HardFiltering(); filtering.show_hidden = !filtering.show_hidden; diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ViewFile.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ViewFile.mm index c3fdcd570..61f36fc2a 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ViewFile.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Actions/ViewFile.mm @@ -18,7 +18,7 @@ return true; } -void ViewFile::Perform(PanelController *_target, id) const +void ViewFile::Perform(PanelController *_target, id /*_sender*/) const { const auto item = _target.view.item; if( !item ) diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefView.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefView.mm index e19c243d2..7d21ab3c1 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefView.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefView.mm @@ -250,10 +250,10 @@ - (NSCollectionViewItem *)collectionView:(NSCollectionView *)collectionView auto &vd = m_Data->VolatileDataAtSortPosition(index); - if( m_IconsRepository->IsValidSlot(vd.icon) == false ) + if( !m_IconsRepository->IsValidSlot(vd.icon) ) vd.icon = m_IconsRepository->Register(vfs_item); - if( m_IconsRepository->IsValidSlot(vd.icon) == true ) { + if( m_IconsRepository->IsValidSlot(vd.icon) ) { [item setIcon:m_IconsRepository->AvailableIconForSlot(vd.icon)]; m_IconsRepository->ScheduleIconProduction(vd.icon, vfs_item); m_IconSlotToItemIndexMapping[vd.icon] = index; @@ -319,7 +319,7 @@ - (void)calculateFilenamesWidths assert(static_cast(widths.size()) == count); const auto &layout = m_ItemLayout; - const unsigned short width_addition = 2 * layout.inset_left + layout.icon_size + layout.inset_right; + const unsigned short width_addition = (2 * layout.inset_left) + layout.icon_size + layout.inset_right; if( m_ColumnsLayout.dynamic_width_equal ) { const auto max_width = *std::max_element(widths.begin(), widths.begin()); const unsigned short width = max_width + width_addition; @@ -480,7 +480,7 @@ - (void)ensureItemIsVisible:(int)_item_index } else { // center - scroll_to(NSMakePoint(item_rect.origin.x - (visible_rect.size.width - item_rect.size.width) / 2., 0.)); + scroll_to(NSMakePoint(item_rect.origin.x - ((visible_rect.size.width - item_rect.size.width) / 2.), 0.)); } } else { diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewCollectionView.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewCollectionView.mm index 8b8876c0e..cc5ff0280 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewCollectionView.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewCollectionView.mm @@ -75,7 +75,7 @@ - (void)mouseUp:(NSEvent *) [[maybe_unused]] _event - (void)scrollWheel:(NSEvent *)event { if( event.phase == NSEventPhaseNone && event.momentumPhase == NSEventPhaseNone && - event.hasPreciseScrollingDeltas == false && event.deltaX == 0.0 && event.deltaY != 0.0 ) { + !event.hasPreciseScrollingDeltas && event.deltaX == 0.0 && event.deltaY != 0.0 ) { // for vertical scroll coming from USB PC mice we swap the scroll asix, so user // can use mouse wheel without holding a Shift button if( auto new_event = SwapScrollAxis(event) ) diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewDynamicWidthLayout.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewDynamicWidthLayout.mm index 71b786765..c6f1251fc 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewDynamicWidthLayout.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewDynamicWidthLayout.mm @@ -68,7 +68,7 @@ - (bool)delegateProvidesIntrinsicWidths { const auto delegate = self.layoutDelegate; const auto selector = @selector(collectionViewProvideIntrinsicItemsWidths:); - if( [delegate respondsToSelector:selector] == false ) { + if( ![delegate respondsToSelector:selector] ) { static std::once_flag once; std::call_once(once, [] { NSLog(@"A delegate doesn't provide collectionViewProvideIntrinsicItemsWidths:, " @@ -81,7 +81,7 @@ - (bool)delegateProvidesIntrinsicWidths - (void)prepareLayout { - if( [self delegateProvidesIntrinsicWidths] == false ) + if( ![self delegateProvidesIntrinsicWidths] ) return; const auto collection_view = self.collectionView; diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewDynamicWidthLayoutEngine.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewDynamicWidthLayoutEngine.mm index 210b49d74..f45d6943e 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewDynamicWidthLayoutEngine.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewDynamicWidthLayoutEngine.mm @@ -14,7 +14,7 @@ } else { m_ColumnsNumber = - (m_ItemsNumber % m_RowsNumber != 0) ? (m_ItemsNumber / m_RowsNumber + 1) : (m_ItemsNumber / m_RowsNumber); + (m_ItemsNumber % m_RowsNumber != 0) ? ((m_ItemsNumber / m_RowsNumber) + 1) : (m_ItemsNumber / m_RowsNumber); PerformNormalLayout(_params); } } @@ -98,10 +98,7 @@ { const auto height = clip_view_bounds.size.height; const auto projected_rows_number = NumberOfRowsForViewHeight(height, m_ItemHeight); - if( projected_rows_number != m_RowsNumber ) - return true; - else - return false; + return projected_rows_number != m_RowsNumber; } NSArray * diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewFixedNumberLayoutEngine.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewFixedNumberLayoutEngine.mm index 54fc19da6..318c8179e 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewFixedNumberLayoutEngine.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewFixedNumberLayoutEngine.mm @@ -37,7 +37,7 @@ } else { m_ColumnsNumber = - (m_ItemsNumber % m_RowsNumber != 0) ? (m_ItemsNumber / m_RowsNumber + 1) : (m_ItemsNumber / m_RowsNumber); + (m_ItemsNumber % m_RowsNumber != 0) ? ((m_ItemsNumber / m_RowsNumber) + 1) : (m_ItemsNumber / m_RowsNumber); } } @@ -63,7 +63,7 @@ const auto column_width = base_width + (index_in_chunk < screen_remainder ? 1 : 0); for( int row_index = 0; row_index < rows_number; ++row_index ) { - const auto index = column_index * rows_number + row_index; + const auto index = (column_index * rows_number) + row_index; if( index == items_number ) break; @@ -110,10 +110,7 @@ const auto height = clip_view_bounds.size.height; const auto projected_rows_number = NumberOfRowsForViewHeight(height, m_ItemHeight); - if( projected_rows_number != m_RowsNumber ) - return true; - else - return false; + return projected_rows_number != m_RowsNumber; } NSArray * diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewFixedWidthLayoutEngine.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewFixedWidthLayoutEngine.mm index 117617147..591a304a3 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewFixedWidthLayoutEngine.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewFixedWidthLayoutEngine.mm @@ -50,7 +50,7 @@ static void FillColumnsWidths(std::vector &_widths, int _number, int _item_ } else { m_ColumnsNumber = - (m_ItemsNumber % m_RowsNumber != 0) ? (m_ItemsNumber / m_RowsNumber + 1) : (m_ItemsNumber / m_RowsNumber); + (m_ItemsNumber % m_RowsNumber != 0) ? ((m_ItemsNumber / m_RowsNumber) + 1) : (m_ItemsNumber / m_RowsNumber); m_ContentSize = NSMakeSize(m_ColumnsNumber * m_ItemWidth, m_RowsNumber * m_ItemHeight); FillColumnsPositions(m_ColumnsPositions, m_ColumnsNumber, m_ItemWidth); FillColumnsWidths(m_ColumnsWidths, m_ColumnsNumber, m_ItemWidth); @@ -90,10 +90,7 @@ static void FillColumnsWidths(std::vector &_widths, int _number, int _item_ { const auto height = clip_view_bounds.size.height; const auto projected_rows_number = NumberOfRowsForViewHeight(height, m_ItemHeight); - if( projected_rows_number != m_RowsNumber ) - return true; - else - return false; + return projected_rows_number != m_RowsNumber; } NSArray * @@ -108,7 +105,7 @@ static void FillColumnsWidths(std::vector &_widths, int _number, int _item_ NSMutableArray *const array = [[NSMutableArray alloc] init]; for( int column = first_column; column < last_column; ++column ) for( int row = first_row; row < last_row; ++row ) { - const auto index = column * m_RowsNumber + row; + const auto index = (column * m_RowsNumber) + row; if( index >= 0 && index < m_ItemsNumber ) { [array addObject:m_Attributes[index]]; } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewItemCarrier.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewItemCarrier.mm index 27f554dc5..58978530c 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewItemCarrier.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewItemCarrier.mm @@ -133,7 +133,7 @@ - (void)setFrame:(NSRect)_new_frame - (NSRect)calculateTextSegmentFromBounds:(NSRect)bounds { - const int origin = m_LayoutConstants.icon_size ? 2 * m_LayoutConstants.inset_left + m_LayoutConstants.icon_size + const int origin = m_LayoutConstants.icon_size ? (2 * m_LayoutConstants.inset_left) + m_LayoutConstants.icon_size : m_LayoutConstants.inset_left; const auto tags = m_Controller.item.Tags(); const auto tags_geom = TrailingTagsInplaceDisplay::Place(tags); @@ -152,9 +152,9 @@ - (NSRect)calculateTextSegmentFromBounds:(NSRect)bounds const auto cs = NSColorSpace.genericRGBColorSpace; _front = [_front colorUsingColorSpace:cs]; _back = [_back colorUsingColorSpace:cs]; - const auto r = _front.redComponent * alpha + _back.redComponent * (1. - alpha); - const auto g = _front.greenComponent * alpha + _back.greenComponent * (1. - alpha); - const auto b = _front.blueComponent * alpha + _back.blueComponent * (1. - alpha); + const auto r = (_front.redComponent * alpha) + (_back.redComponent * (1. - alpha)); + const auto g = (_front.greenComponent * alpha) + (_back.greenComponent * (1. - alpha)); + const auto b = (_front.blueComponent * alpha) + (_back.blueComponent * (1. - alpha)); return [NSColor colorWithCalibratedRed:r green:g blue:b alpha:1.]; } @@ -196,7 +196,7 @@ - (void)drawRect:(NSRect) [[maybe_unused]] _dirty_rect [m_AttrString drawWithRect:text_rect options:0]; const auto icon_rect = NSMakeRect(m_LayoutConstants.inset_left, - (bounds.size.height - m_LayoutConstants.icon_size) / 2. + 0.5, + ((bounds.size.height - m_LayoutConstants.icon_size) / 2.) + 0.5, m_LayoutConstants.icon_size, m_LayoutConstants.icon_size); [m_Icon drawInRect:icon_rect diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewLayoutEngineBase.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewLayoutEngineBase.mm index ffc6903c9..77c801ce2 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewLayoutEngineBase.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Brief/PanelBriefViewLayoutEngineBase.mm @@ -50,7 +50,7 @@ static It FindLastColumnPosForRect(It _first, It _last, NSRect _rect) noexcept NSMutableArray *const array = [[NSMutableArray alloc] init]; for( int column = first_col_index; column < last_col_index; ++column ) { for( int row = first_row_index; row < last_row_index; ++row ) { - const auto index = column * m_RowsNumber + row; + const auto index = (column * m_RowsNumber) + row; if( index >= 0 && index < m_ItemsNumber ) { [array addObject:m_Attributes[index]]; } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/ContextMenu.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/ContextMenu.mm index e03a3610d..8dffc258b 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/ContextMenu.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/ContextMenu.mm @@ -144,7 +144,7 @@ - (void)doStuffing "Menu item title to delete file, for English is 'Delete Permanently'"); delete_item.target = self; delete_item.action = @selector(OnDeletePermanently:); - delete_item.alternate = trash_item.hidden ? false : true; + delete_item.alternate = !trash_item.hidden; delete_item.keyEquivalent = @""; delete_item.keyEquivalentModifierMask = trash_item.hidden ? 0 : NSEventModifierFlagOption; [self addItem:delete_item]; diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/DragReceiver.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/DragReceiver.mm index cf4d18872..8aeada666 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/DragReceiver.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/DragReceiver.mm @@ -329,7 +329,7 @@ // currently fetching listings synchronously in main thread, which is BAAAD auto source_items = FetchListingItems(_source, m_NativeHost); - if( source_items.has_value() == false ) { + if( !source_items.has_value() ) { // failed to fetch the source items. // refuse the drag and show an error message asynchronously. const int vfs_error = source_items.error(); diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/DragSender.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/DragSender.mm index 6bcdd31b7..ed1df8d46 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/DragSender.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/DragSender.mm @@ -102,7 +102,7 @@ std::vector items; - if( dragged_item_vd.is_selected() == false ) + if( !dragged_item_vd.is_selected() ) items.emplace_back(dragged_item); // drag only clicked item else items = _data.SelectedEntriesSorted(); // drag all selected items diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/ExternalEditorInfo.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/ExternalEditorInfo.mm index c6fde509f..f5d3df975 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/ExternalEditorInfo.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/ExternalEditorInfo.mm @@ -222,13 +222,13 @@ - (void)encodeWithCoder:(NSCoder *)encoder bool ExternalEditorStartupInfo::IsValidForItem(const VFSListingItem &_item, bool _allow_terminal) const { - if( _allow_terminal == false && m_OpenInTerminal ) + if( !_allow_terminal && m_OpenInTerminal ) return false; if( m_Mask.empty() ) // why is this? return false; - if( m_OnlyFiles == true && _item.IsReg() == false ) + if( m_OnlyFiles && !_item.IsReg() ) return false; if( m_Mask != "*" ) { @@ -237,7 +237,7 @@ - (void)encodeWithCoder:(NSCoder *)encoder return false; } - if( m_OnlyFiles == true && m_MaxFileSize > 0 && _item.Size() > m_MaxFileSize ) + if( m_OnlyFiles && m_MaxFileSize > 0 && _item.Size() > m_MaxFileSize ) return false; return true; @@ -292,7 +292,7 @@ - (void)encodeWithCoder:(NSCoder *)encoder std::shared_ptr ExternalEditorsStorage::ViableEditorForItem(const VFSListingItem &_item) const { - const auto has_terminal = nc::base::AmISandboxed() == false; + const auto has_terminal = !nc::base::AmISandboxed(); for( auto &ed : m_ExternalEditors ) if( ed->IsValidForItem(_item, has_terminal) ) return ed; diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/FavoriteComposing.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/FavoriteComposing.mm index bf7eaaa4a..51749f4f0 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/FavoriteComposing.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/FavoriteComposing.mm @@ -167,8 +167,7 @@ if( url ) { auto path = StringFromURL(url); if( !path.empty() && !path.ends_with(".cannedSearch") && !path.ends_with(".cannedSearch/") && - !path.ends_with(".savedSearch") && - nc::bootstrap::NativeVFSHostInstance().IsDirectory(path.c_str(), 0) ) + !path.ends_with(".savedSearch") && nc::bootstrap::NativeVFSHostInstance().IsDirectory(path, 0) ) paths.emplace_back(TitleForURL(url), ensure_tr_slash(std::move(path))); CFRelease(url); } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/FavoritesImpl.cpp b/Source/NimbleCommander/NimbleCommander/States/FilePanels/FavoritesImpl.cpp index a523453ee..a46d2c364 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/FavoritesImpl.cpp +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/FavoritesImpl.cpp @@ -145,9 +145,9 @@ FavoriteLocationsStorageImpl::FrecentlyUsed(int _amount) const for( auto &v : recent_visits ) { // this is actually not a real frequency, but a normalized value of a visits count. - const auto frequency = static_cast(std::get<1>(v)) / max_visits; // [0..1] - const auto recency = 1. - float(now - std::get<2>(v)) / float(g_MaxTimeRange); // [0..1] - const auto score = frequency + recency; // [0..2] + const auto frequency = static_cast(std::get<1>(v)) / max_visits; // [0..1] + const auto recency = 1. - (float(now - std::get<2>(v)) / float(g_MaxTimeRange)); // [0..1] + const auto score = frequency + recency; // [0..2] std::get<3>(v) = static_cast(score); } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/FilesDraggingSource.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/FilesDraggingSource.mm index 9254026cf..e536a4852 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/FilesDraggingSource.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/FilesDraggingSource.mm @@ -254,11 +254,9 @@ - (void)pasteboard:(NSPasteboard *)sender item:(PanelDraggingItem *)item provide if( !item.item ) return; - if( false ) - ; // else if( [type isEqualToString:g_PasteboardFilenamesUTI] ) // [self provideFilenamesPasteboard:sender item:item]; - else if( [type isEqualToString:g_PasteboardFileURLPromiseUTI] ) + if( [type isEqualToString:g_PasteboardFileURLPromiseUTI] ) [self provideURLPromisePasteboard:sender item:item]; // else if( [type isEqualToString:g_PasteboardFileURLUTI] ) // [self provideFilenamesURLsPasteboard:sender item:item]; diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/FindFilesSheetController.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/FindFilesSheetController.mm index 69b631022..cf090e7b1 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/FindFilesSheetController.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/FindFilesSheetController.mm @@ -499,7 +499,7 @@ - (IBAction)OnSearch:(id) [[maybe_unused]] _sender // TODO: need some decent cancelling mechanics here auto stat_block = [self, it = std::move(it)]() mutable { // doing stat()'ing item in async background thread - it.host->Stat(it.full_filename.c_str(), it.st, 0, nullptr); + it.host->Stat(it.full_filename, it.st, 0, nullptr); FindFilesSheetFoundItem *const item = [[FindFilesSheetFoundItem alloc] initWithFoundItem:std::move(it)]; m_BatchQueue.Run([self, item] { diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Helpers/IconRepositoryCleaner.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Helpers/IconRepositoryCleaner.mm index 989f658cd..ea6c26843 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Helpers/IconRepositoryCleaner.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Helpers/IconRepositoryCleaner.mm @@ -16,7 +16,7 @@ const auto used_slots = m_Repository.AllSlots(); auto still_in_use = std::vector(used_slots.size(), false); - for( auto i = 0, e = static_cast(m_Data.RawEntriesCount()); i < e; ++i ) { + for( auto i = 0, e = m_Data.RawEntriesCount(); i < e; ++i ) { auto &vd = m_Data.VolatileDataAtRawPosition(i); if( vd.icon != vfsicon::IconRepository::InvalidKey ) { auto it = std::ranges::lower_bound(used_slots, vd.icon); @@ -26,7 +26,7 @@ } for( int i = 0, e = static_cast(used_slots.size()); i < e; ++i ) - if( still_in_use[i] == false ) { + if( !still_in_use[i] ) { m_Repository.Unregister(used_slots[i]); } } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/List/PanelListView.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/List/PanelListView.mm index e4cb0b0c5..059487ac1 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/List/PanelListView.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/List/PanelListView.mm @@ -515,13 +515,13 @@ - (void)fillDataForNameView:(PanelListViewNameView *)_view { [_view setFilename:_item.DisplayNameNS() andTags:_item.Tags()]; - if( m_IconRepository->IsValidSlot(_vd.icon) == true ) { + if( m_IconRepository->IsValidSlot(_vd.icon) ) { [_view setIcon:m_IconRepository->AvailableIconForSlot(_vd.icon)]; m_IconRepository->ScheduleIconProduction(_vd.icon, _item); } else { _vd.icon = m_IconRepository->Register(_item); - if( m_IconRepository->IsValidSlot(_vd.icon) == true ) { + if( m_IconRepository->IsValidSlot(_vd.icon) ) { [_view setIcon:m_IconRepository->AvailableIconForSlot(_vd.icon)]; m_IconRepository->ScheduleIconProduction(_vd.icon, _item); } @@ -1038,7 +1038,7 @@ - (BOOL)tableView:(NSTableView *) [[maybe_unused]] tableView shouldReorderColumn:(NSInteger)columnIndex toColumn:(NSInteger)newColumnIndex { - return !(columnIndex == 0 || newColumnIndex == 0); + return columnIndex != 0 && newColumnIndex != 0; } - (NSMenu *)columnsSelectionMenu diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/List/PanelListViewGeometry.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/List/PanelListViewGeometry.mm index 0117f4d6f..a4b1d88b0 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/List/PanelListViewGeometry.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/List/PanelListViewGeometry.mm @@ -82,7 +82,7 @@ short PanelListViewGeometry::FilenameOffsetInColumn() const noexcept { - return static_cast(IconSize() ? 2 * LeftInset() + IconSize() : LeftInset()); + return static_cast(IconSize() ? (2 * LeftInset()) + IconSize() : LeftInset()); } } // namespace nc::panel diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/List/PanelListViewNameView.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/List/PanelListViewNameView.mm index af3834e53..8c6736746 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/List/PanelListViewNameView.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/List/PanelListViewNameView.mm @@ -131,7 +131,7 @@ - (void)drawRect:(NSRect) [[maybe_unused]] _dirtyRect [m_AttrString drawWithRect:text_rect options:0]; const auto icon_rect = NSMakeRect(geometry.LeftInset(), - (bounds.size.height - geometry.IconSize()) / 2. + 0.5, + ((bounds.size.height - geometry.IconSize()) / 2.) + 0.5, geometry.IconSize(), geometry.IconSize()); [m_Icon drawInRect:icon_rect @@ -229,7 +229,7 @@ - (void)setupFieldEditor:(NCPanelViewFieldEditor *)_editor NSMakeRect(text_segment_rect.origin.x - line_padding, geometry.TextBaseLine() - fi.Descent(), text_segment_rect.size.width + 1, // cover for any roundings potentially caused by compressing - bounds.size.height - (geometry.TextBaseLine() - fi.Descent()) * 2.); + bounds.size.height - ((geometry.TextBaseLine() - fi.Descent()) * 2.)); _editor.frame = rc; NSTextView *tv = _editor.documentView; diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/List/PanelListViewRowView.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/List/PanelListViewRowView.mm index 17716b48f..4e8e6a25c 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/List/PanelListViewRowView.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/List/PanelListViewRowView.mm @@ -135,9 +135,9 @@ - (void)setSelected:(BOOL)selected const auto cs = NSColorSpace.genericRGBColorSpace; _front = [_front colorUsingColorSpace:cs]; _back = [_back colorUsingColorSpace:cs]; - const auto r = _front.redComponent * alpha + _back.redComponent * (1. - alpha); - const auto g = _front.greenComponent * alpha + _back.greenComponent * (1. - alpha); - const auto b = _front.blueComponent * alpha + _back.blueComponent * (1. - alpha); + const auto r = (_front.redComponent * alpha) + (_back.redComponent * (1. - alpha)); + const auto g = (_front.greenComponent * alpha) + (_back.greenComponent * (1. - alpha)); + const auto b = (_front.blueComponent * alpha) + (_back.blueComponent * (1. - alpha)); return [NSColor colorWithCalibratedRed:r green:g blue:b alpha:1.]; } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/ListingPromise.cpp b/Source/NimbleCommander/NimbleCommander/States/FilePanels/ListingPromise.cpp index 89941d51c..23c35b1ca 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/ListingPromise.cpp +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/ListingPromise.cpp @@ -93,7 +93,7 @@ VFSListingPtr ListingPromise::RestoreUniform(unsigned long _fetch_flags, return nullptr; VFSListingPtr listing; - const auto rc = host->FetchDirectoryListing(info->directory.c_str(), listing, _fetch_flags, _cancel_checker); + const auto rc = host->FetchDirectoryListing(info->directory, listing, _fetch_flags, _cancel_checker); if( rc != VFSError::Ok ) throw VFSErrorException{rc}; @@ -125,7 +125,7 @@ VFSListingPtr ListingPromise::RestoreNonUniform(unsigned long _fetch_flags, return nullptr; const auto path = directory + entries[i]; VFSListingPtr listing; - const auto rc = host->FetchSingleItemListing(path.c_str(), listing, _fetch_flags, _cancel_checker); + const auto rc = host->FetchSingleItemListing(path, listing, _fetch_flags, _cancel_checker); if( rc == VFSError::Ok && listing != nullptr ) listings.emplace_back(std::move(listing)); } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/MainWindowFilePanelState+OverlappedTerminalSupport.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/MainWindowFilePanelState+OverlappedTerminalSupport.mm index 388511859..9dbbf9758 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/MainWindowFilePanelState+OverlappedTerminalSupport.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/MainWindowFilePanelState+OverlappedTerminalSupport.mm @@ -169,7 +169,7 @@ - (void)updateOverlappedTerminalVisibility if( m_OverlappedTerminal->terminal == nullptr ) return; - if( m_OverlappedTerminal->bottom_gap == 0 && m_SplitView.hidden == false ) { + if( m_OverlappedTerminal->bottom_gap == 0 && !m_SplitView.hidden ) { m_OverlappedTerminal->terminal.hidden = true; } else { @@ -194,7 +194,7 @@ - (bool)overlappedTerminalVisible - (void)synchronizeOverlappedTerminalWithPanel:(PanelController *)_pc { if( _pc.isUniform && _pc.vfs->IsNativeFS() && self.overlappedTerminalVisible && - m_OverlappedTerminal->terminal.isShellVirgin == true ) + m_OverlappedTerminal->terminal.isShellVirgin ) [m_OverlappedTerminal->terminal changeWorkingDirectory:_pc.currentDirectoryPath]; } @@ -261,7 +261,7 @@ - (bool)executeInOverlappedTerminalIfPossible:(const std::string &)_filename at:(const std::string &) [[maybe_unused]] _path { if( self.overlappedTerminalVisible && m_OverlappedTerminal->terminal.state == ShellTask::TaskState::Shell && - m_OverlappedTerminal->terminal.isShellVirgin == true ) { + m_OverlappedTerminal->terminal.isShellVirgin ) { // assumes that _filename is eligible to execute in terminal (should be check by PanelController before) [m_OverlappedTerminal->terminal feedShellWithInput:"./"s + _filename]; [m_OverlappedTerminal->terminal commitShell]; @@ -286,7 +286,7 @@ - (int)bidForHandlingRoutedIntoOTKeyDown:(NSEvent *)_event const auto keycode = _event.keyCode; if( keycode == 36 ) { // Return button if( m_OverlappedTerminal->terminal.state == ShellTask::TaskState::Shell && - m_OverlappedTerminal->terminal.isShellVirgin == false ) { + !m_OverlappedTerminal->terminal.isShellVirgin ) { // if user has entered something in overlapped terminal, then executing this stuff // via Enter should be in high priority return nc::panel::view::BiddingPriority::Max; @@ -304,7 +304,7 @@ - (void)handleRoutedIntoOTKeyDown:(NSEvent *)_event const auto keycode = _event.keyCode; if( keycode == 36 ) { // Return button if( m_OverlappedTerminal->terminal.state == ShellTask::TaskState::Shell && - m_OverlappedTerminal->terminal.isShellVirgin == false ) { + !m_OverlappedTerminal->terminal.isShellVirgin ) { [m_OverlappedTerminal->terminal commitShell]; return; } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/MainWindowFilePanelState.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/MainWindowFilePanelState.mm index adead0bdf..612d02a7d 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/MainWindowFilePanelState.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/MainWindowFilePanelState.mm @@ -299,7 +299,7 @@ - (void)CreateControls m_MainSplitViewBottomConstraint.priority = NSLayoutPriorityDragThatCannotResizeWindow; [self addConstraint:m_MainSplitViewBottomConstraint]; - if( nc::base::AmISandboxed() == false ) { + if( !nc::base::AmISandboxed() ) { m_OverlappedTerminal->terminal = [[FilePanelOverlappedTerminal alloc] initWithFrame:self.bounds]; m_OverlappedTerminal->terminal.translatesAutoresizingMaskIntoConstraints = false; [self addSubview:m_OverlappedTerminal->terminal positioned:NSWindowBelow relativeTo:nil]; @@ -1076,7 +1076,7 @@ - (BOOL)performKeyEquivalent:(NSEvent *)theEvent const auto left = NSMaxX([_window standardWindowButton:NSWindowZoomButton].frame); const auto right = _window.frame.size.width; const auto padding = 8.; - const auto width = right - left - 2 * padding; + const auto width = right - left - (2 * padding); return StringByTruncatingToWidth(_title, static_cast(width), kTruncateAtStart, attributes); } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/MainWindowFilePanelsStateToolbarDelegate.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/MainWindowFilePanelsStateToolbarDelegate.mm index 92788f635..a008ac332 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/MainWindowFilePanelsStateToolbarDelegate.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/MainWindowFilePanelsStateToolbarDelegate.mm @@ -107,7 +107,7 @@ - (void)buildToolbar static NSImage *ImageForTool(const nc::panel::ExternalTool &_et) { std::filesystem::path tool_path = _et.m_ExecutablePath; - if( std::filesystem::exists(tool_path) == false ) { + if( !std::filesystem::exists(tool_path) ) { // presumably this is a short name of a CLI tool, i.e. 'zip'. let's resolve it const auto paths = nc::base::WhereIs(_et.m_ExecutablePath); if( paths.empty() ) diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/NCPanelOpenWithMenuDelegate.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/NCPanelOpenWithMenuDelegate.mm index 77fc8dc64..e4fdeedb0 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/NCPanelOpenWithMenuDelegate.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/NCPanelOpenWithMenuDelegate.mm @@ -24,7 +24,7 @@ std::string uti; }; -static void SortAndPurgeDuplicateHandlers(std::vector &_handlers) +void SortAndPurgeDuplicateHandlers(std::vector &_handlers) { std::ranges::sort( _handlers, [](const auto &_1st, const auto &_2nd) { return [_1st.Name() localizedCompare:_2nd.Name()] < 0; }); @@ -48,7 +48,7 @@ static void SortAndPurgeDuplicateHandlers(std::vector &_ha } } -static FetchResult FetchHandlers(const std::vector &_items, const UTIDB &_db) +FetchResult FetchHandlers(const std::vector &_items, const UTIDB &_db) { std::vector per_item_handlers; per_item_handlers.reserve(_items.size()); diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelAux.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelAux.mm index a2d06e6d7..3923f6111 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelAux.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelAux.mm @@ -138,13 +138,13 @@ static void RegisterRemoteFileUploading(const std::string &_original_path, dispatch_to_default([=, this] { auto activity_ticket = [_panel registerExtActivity]; - if( _host->IsDirectory(_filepath.c_str(), 0, nullptr) ) { + if( _host->IsDirectory(_filepath, 0, nullptr) ) { NSBeep(); return; } VFSStat st; - if( _host->Stat(_filepath.c_str(), st, 0, nullptr) < 0 ) { + if( _host->Stat(_filepath, st, 0, nullptr) < 0 ) { NSBeep(); return; } @@ -201,11 +201,11 @@ static void RegisterRemoteFileUploading(const std::string &_original_path, auto activity_ticket = [_panel registerExtActivity]; NSMutableArray *const arr = [NSMutableArray arrayWithCapacity:_filepaths.size()]; for( auto &i : _filepaths ) { - if( _host->IsDirectory(i.c_str(), 0, nullptr) ) + if( _host->IsDirectory(i, 0, nullptr) ) continue; VFSStat st; - if( _host->Stat(i.c_str(), st, 0, nullptr) < 0 ) + if( _host->Stat(i, st, 0, nullptr) < 0 ) continue; if( st.size > g_MaxFileSizeForVFSOpen ) @@ -246,13 +246,13 @@ static void RegisterRemoteFileUploading(const std::string &_original_path, this] { // do downloading down in a background thread auto activity_ticket = [_panel registerExtActivity]; - if( _host->IsDirectory(_filepath.c_str(), 0, nullptr) ) { + if( _host->IsDirectory(_filepath, 0, nullptr) ) { NSBeep(); return; } VFSStat st; - if( _host->Stat(_filepath.c_str(), st, 0, nullptr) < 0 ) { + if( _host->Stat(_filepath, st, 0, nullptr) < 0 ) { NSBeep(); return; } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelController.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelController.mm index 757c7eb49..ee96b81a1 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelController.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelController.mm @@ -279,17 +279,17 @@ - (void)dealloc - (void)configVFSFetchFlagsChanged { - if( ConfigShowDotDotEntry() == false ) + if( !ConfigShowDotDotEntry() ) m_VFSFetchingFlags |= VFSFlags::F_NoDotDot; else m_VFSFetchingFlags &= ~VFSFlags::F_NoDotDot; - if( ConfigShowLocalizedFilenames() == true ) + if( ConfigShowLocalizedFilenames() ) m_VFSFetchingFlags |= VFSFlags::F_LoadDisplayNames; else m_VFSFetchingFlags &= ~VFSFlags::F_LoadDisplayNames; - if( ConfigEnableFinderTags() == true ) + if( ConfigEnableFinderTags() ) m_VFSFetchingFlags |= VFSFlags::F_LoadTags; else m_VFSFetchingFlags &= ~VFSFlags::F_LoadTags; @@ -525,7 +525,7 @@ - (void)doCalculateSizesOfItems:(const std::vector &)_items const size_t items_count = _items.size(); const size_t batches = std::min(g_MaxSizeCalculationCommitBatches, items_count); const size_t items_per_batch = items_count / batches; - const size_t items_leftover = items_count - items_per_batch * batches; + const size_t items_leftover = items_count - (items_per_batch * batches); for( size_t batch = 0, items_first = 0, items_last = 0; batch != batches; ++batch ) { items_first = items_last; @@ -722,7 +722,7 @@ - (NCPanelContextMenu *)panelView:(PanelView *)_view requestsContextMenuForItemN const auto clicked_item_vd = m_Data.VolatileDataAtSortPosition(_sort_pos); std::vector vfs_items; - if( clicked_item_vd.is_selected() == false ) + if( !clicked_item_vd.is_selected() ) vfs_items.emplace_back(clicked_item); // only clicked item else vfs_items = m_Data.SelectedEntriesSorted(); // all selected items @@ -890,11 +890,11 @@ - (bool)probeDirectoryAccessForRequest:(DirectoryChangeRequest &)_request auto &vfs = *_request.VFS; auto &access_provider = *m_DirectoryAccessProvider; const auto has_access = access_provider.HasAccess(self, directory, vfs); - if( has_access == true ) { + if( has_access ) { return true; } else { - if( _request.InitiatedByUser == true ) + if( _request.InitiatedByUser ) return access_provider.RequestAccessSync(self, directory, vfs); else return false; @@ -908,7 +908,7 @@ - (void)doGoToDirWithContext:(std::shared_ptr)_request Log::Debug("[PanelController doGoToDirWithContext] was called with {}", *_request); try { - if( [self probeDirectoryAccessForRequest:*_request] == false ) { + if( ![self probeDirectoryAccessForRequest:*_request] ) { _request->LoadingResultCode = VFSError::FromErrno(EPERM); return; } @@ -959,7 +959,7 @@ - (int)GoToDirWithContext:(std::shared_ptr)_request assert(_request->VFS != nullptr); Log::Debug("[PanelController GoToDirWithContext] was called with {}", *_request); - if( _request->PerformAsynchronous == false ) { + if( !_request->PerformAsynchronous ) { assert(dispatch_is_main_queue()); m_DirectoryLoadingQ.Stop(); m_DirectoryLoadingQ.Wait(); @@ -1147,7 +1147,7 @@ - (void)quickSearch:(NCPanelQuickSearch *) [[maybe_unused]] _qs - (bool)isDoingBackgroundLoading { - return m_DirectoryLoadingQ.Empty() == false; + return !m_DirectoryLoadingQ.Empty(); } - (std::unique_ptr)panelView:(PanelView *) [[maybe_unused]] _view diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelControllerPersistency.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelControllerPersistency.mm index f72ba89f5..cfab30ec2 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelControllerPersistency.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelControllerPersistency.mm @@ -109,7 +109,7 @@ static void RecoverSavedPathAtVFSAsync(const VFSHostPtr &_host, const std::strin */ bool ControllerStateJSONDecoder::AllowSyncRecovery(const PersistentLocation &_location) const { - if( _location.is_native() == false ) + if( !_location.is_native() ) return false; const auto &path = _location.path; @@ -118,11 +118,7 @@ static void RecoverSavedPathAtVFSAsync(const VFSHostPtr &_host, const std::strin return false; const auto mount_flags = fs_info->mount_flags; - if( mount_flags.ejectable == false && mount_flags.removable == false && mount_flags.local == true && - mount_flags.internal == true ) - return true; - - return false; + return !mount_flags.ejectable && !mount_flags.removable && mount_flags.local && mount_flags.internal; } void ControllerStateJSONDecoder::RecoverSavedContentSync(const PersistentLocation &_location, PanelController *_panel) diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelView.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelView.mm index 1f706cb66..4710d047c 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelView.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelView.mm @@ -821,7 +821,7 @@ - (void)loadPathState return; const auto &storage = it->second; - int cursor = m_Data->SortedIndexForName(storage.focused_item.c_str()); + int cursor = m_Data->SortedIndexForName(storage.focused_item); if( cursor < 0 ) return; @@ -837,7 +837,7 @@ - (void)panelChangedWithFocusedFilename:(const std::string &)_focused_filename l if( _load ) [self loadPathState]; - const int cur = m_Data->SortedIndexForName(_focused_filename.c_str()); + const int cur = m_Data->SortedIndexForName(_focused_filename); if( cur >= 0 ) { [self setCurpos:cur]; } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelViewFooterVolumeInfoFetcher.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelViewFooterVolumeInfoFetcher.mm index 481077297..b9cf8865a 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelViewFooterVolumeInfoFetcher.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelViewFooterVolumeInfoFetcher.mm @@ -70,7 +70,7 @@ static void ScheduleIfNeed(LookPath &_lp, bool _hurry = false) VFSStatFS stat; int result = -1; if( auto h = host.lock() ) - result = h->StatFS(path.c_str(), stat, nullptr); + result = h->StatFS(path, stat, nullptr); dispatch_to_main_queue( [=] { AcceptResult(host, path, result == 0 ? std::optional{stat} : std::nullopt); }); }); diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelViewLayoutSupport.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelViewLayoutSupport.mm index 6b64514d4..8d81b094d 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelViewLayoutSupport.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/PanelViewLayoutSupport.mm @@ -367,7 +367,7 @@ - (void)menuNeedsUpdate:(NSMenu *)menu if( m_IsDirty && (menu.propertiesToUpdate & NSMenuPropertyItemTitle) ) { int index = 0; for( NSMenuItem *item in menu.itemArray ) { - if( auto l = m_Storage->GetLayout(static_cast(index)) ) { + if( auto l = m_Storage->GetLayout(index) ) { item.title = l->name.empty() ? [NSString stringWithFormat:@"Layout #%d", index + 1] : [NSString stringWithUTF8StdString:l->name]; } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/BriefSystemOverview.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/BriefSystemOverview.mm index 81752f719..2f58c4d73 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/BriefSystemOverview.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/BriefSystemOverview.mm @@ -660,7 +660,7 @@ - (void)updateData m_StatFS = {}; if( !m_TargetVFSPath.empty() && m_TargetVFSHost.get() ) - m_TargetVFSHost->StatFS(m_TargetVFSPath.c_str(), m_StatFS, nullptr); + m_TargetVFSHost->StatFS(m_TargetVFSPath, m_StatFS, nullptr); } - (void)updateControls @@ -711,7 +711,7 @@ - (void)UpdateVFSTarget:(const std::string &)_path host:(std::shared_ptrStatFS(m_TargetVFSPath.c_str(), m_StatFS, nullptr); + m_TargetVFSHost->StatFS(m_TargetVFSPath, m_StatFS, nullptr); [self updateControls]; } diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/ConnectToServer.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/ConnectToServer.mm index 20e390c35..1b89e8a36 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/ConnectToServer.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/ConnectToServer.mm @@ -29,27 +29,27 @@ } private: - void Visit(const nc::panel::NetworkConnectionsManager::FTP &) override + void Visit(const nc::panel::NetworkConnectionsManager::FTP & /*_ftp*/) override { m_Sheet = [[FTPConnectionSheetController alloc] init]; } - void Visit(const nc::panel::NetworkConnectionsManager::SFTP &) override + void Visit(const nc::panel::NetworkConnectionsManager::SFTP & /*_sftp*/) override { m_Sheet = [[SFTPConnectionSheetController alloc] init]; } - void Visit(const nc::panel::NetworkConnectionsManager::LANShare &) override + void Visit(const nc::panel::NetworkConnectionsManager::LANShare & /*_share*/) override { m_Sheet = [[NetworkShareSheetController alloc] init]; } - void Visit(const nc::panel::NetworkConnectionsManager::Dropbox &) override + void Visit(const nc::panel::NetworkConnectionsManager::Dropbox & /*_account*/) override { m_Sheet = [[DropboxAccountSheetController alloc] init]; } - void Visit(const nc::panel::NetworkConnectionsManager::WebDAV &) override + void Visit(const nc::panel::NetworkConnectionsManager::WebDAV & /*_webdav*/) override { m_Sheet = [[WebDAVConnectionSheetController alloc] init]; } @@ -359,7 +359,7 @@ - (void)keyDown:(NSEvent *)event - (bool)LANSharesEnabled { - return nc::base::AmISandboxed() == false; + return !nc::base::AmISandboxed(); } @end diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/FilePanelMainSplitView.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/FilePanelMainSplitView.mm index 6102c92cd..b6541e985 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/FilePanelMainSplitView.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/FilePanelMainSplitView.mm @@ -437,10 +437,10 @@ - (BOOL)validateUserInterfaceItem:(id)_item const long item_tag = _item.tag; if( item_tag == move_left_tag ) { - return self.isLeftCollapsed == false; + return !self.isLeftCollapsed; } if( item_tag == move_right_tag ) { - return self.isRightCollapsed == false; + return !self.isRightCollapsed; } return true; diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/GoToFolderSheetController.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/GoToFolderSheetController.mm index 617840b12..305de6016 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/GoToFolderSheetController.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/GoToFolderSheetController.mm @@ -252,7 +252,7 @@ - (const VFSListing *)listingFromDir:(const std::string &)_path auto vfs = self.panel.vfs; VFSListingPtr listing; - int ret = vfs->FetchDirectoryListing(path.c_str(), listing, VFSFlags::F_NoDotDot, nullptr); + int ret = vfs->FetchDirectoryListing(path, listing, VFSFlags::F_NoDotDot, nullptr); if( ret == 0 ) { m_LastListing = listing; return m_LastListing.get(); diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/QuickLookPanel.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/QuickLookPanel.mm index e9f9d8eea..157566137 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/QuickLookPanel.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/QuickLookPanel.mm @@ -81,7 +81,7 @@ - (void)doVFSPreview:(const std::string &)_path host:(const VFSHostPtr &)_host t - (bool)registerExistingQLPreviewPanelFor:(id)_controller { - if( QLPreviewPanel.sharedPreviewPanelExists == false ) + if( !QLPreviewPanel.sharedPreviewPanelExists ) return false; auto ql_panel = QLPreviewPanel.sharedPreviewPanel; diff --git a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/QuickLookVFSBridge.mm b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/QuickLookVFSBridge.mm index 112044bcf..ddb2cb46b 100644 --- a/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/QuickLookVFSBridge.mm +++ b/Source/NimbleCommander/NimbleCommander/States/FilePanels/Views/QuickLookVFSBridge.mm @@ -16,11 +16,11 @@ NSURL *QuickLookVFSBridge::FetchItem(const std::string &_path, VFSHost &_host) { - const auto is_dir = _host.IsDirectory(_path.c_str(), 0); + const auto is_dir = _host.IsDirectory(_path, 0); if( !is_dir ) { VFSStat st; - if( _host.Stat(_path.c_str(), st, 0, nullptr) < 0 ) + if( _host.Stat(_path, st, 0, nullptr) < 0 ) return nil; if( st.size > m_MaxSize ) return nil; diff --git a/Source/NimbleCommander/NimbleCommander/States/MainWindowController.mm b/Source/NimbleCommander/NimbleCommander/States/MainWindowController.mm index d4ce6f878..02c7ead6d 100644 --- a/Source/NimbleCommander/NimbleCommander/States/MainWindowController.mm +++ b/Source/NimbleCommander/NimbleCommander/States/MainWindowController.mm @@ -512,7 +512,7 @@ - (NSRect)window:(NSWindow *) [[maybe_unused]] _window * This leads to situation when dialogs look weird - like thay are placed wrongly. * To fix it - just offset the opening dialog window by 1px down. */ - if( self.window.toolbar != nil && self.window.toolbar.visible == true ) { + if( self.window.toolbar != nil && self.window.toolbar.visible ) { rect.origin.y -= 1.; } return rect; diff --git a/Source/Operations/source/AggregateProgressTracker.mm b/Source/Operations/source/AggregateProgressTracker.mm index 79d431556..34cb51f93 100644 --- a/Source/Operations/source/AggregateProgressTracker.mm +++ b/Source/Operations/source/AggregateProgressTracker.mm @@ -4,6 +4,7 @@ #include #include #include +#include namespace nc::ops { @@ -67,11 +68,10 @@ bool AggregateProgressTracker::ArePoolsEmpty() const { const auto lock = std::lock_guard{m_Lock}; - for( const auto &wp : m_Pools ) - if( const auto p = wp.lock() ) - if( !p->Empty() ) - return false; - return true; + return std::ranges::all_of(m_Pools, [](auto &wp) { + const auto p = wp.lock(); + return p ? p->Empty() : true; + }); } std::tuple AggregateProgressTracker::OperationsAmountAndProgress() const diff --git a/Source/Operations/source/AttrsChanging/AttrsChangingDialog.mm b/Source/Operations/source/AttrsChanging/AttrsChangingDialog.mm index a3abc7d02..57f7346a2 100644 --- a/Source/Operations/source/AttrsChanging/AttrsChangingDialog.mm +++ b/Source/Operations/source/AttrsChanging/AttrsChangingDialog.mm @@ -677,11 +677,9 @@ + (bool)canEditAnythingInItems:(const std::vector &)_items const auto &vfs = _items.front().Host(); const auto vfs_features = vfs->Features(); - if( (vfs_features & nc::vfs::HostFeatures::SetPermissions) || - (vfs_features & nc::vfs::HostFeatures::SetOwnership) || (vfs_features & nc::vfs::HostFeatures::SetFlags) || - (vfs_features & nc::vfs::HostFeatures::SetTimes) ) - return true; - return false; + return (vfs_features & nc::vfs::HostFeatures::SetPermissions) || + (vfs_features & nc::vfs::HostFeatures::SetOwnership) || (vfs_features & nc::vfs::HostFeatures::SetFlags) || + (vfs_features & nc::vfs::HostFeatures::SetTimes); } template diff --git a/Source/Operations/source/AttrsChanging/AttrsChangingJob.cpp b/Source/Operations/source/AttrsChanging/AttrsChangingJob.cpp index a718a1137..559032d56 100644 --- a/Source/Operations/source/AttrsChanging/AttrsChangingJob.cpp +++ b/Source/Operations/source/AttrsChanging/AttrsChangingJob.cpp @@ -54,7 +54,7 @@ void AttrsChangingJob::ScanItem(unsigned _origin_item) auto &vfs = *item.Host(); VFSStat st; while( true ) { - const auto stat_rc = vfs.Stat(path.c_str(), st, 0); + const auto stat_rc = vfs.Stat(path, st, 0); if( stat_rc == VFSError::Ok ) break; switch( m_OnSourceAccessError(stat_rc, path, vfs) ) { @@ -82,7 +82,7 @@ void AttrsChangingJob::ScanItem(unsigned _origin_item) dir_entries.emplace_back(_entry); return true; }; - const auto list_rc = vfs.IterateDirectoryListing(path.c_str(), callback); + const auto list_rc = vfs.IterateDirectoryListing(path, callback); if( list_rc == VFSError::Ok ) break; switch( m_OnSourceAccessError(list_rc, path, vfs) ) { @@ -112,7 +112,7 @@ void AttrsChangingJob::ScanItem(const std::string &_full_path, VFSStat st; while( true ) { - const auto stat_rc = vfs.Stat(_full_path.c_str(), st, 0); + const auto stat_rc = vfs.Stat(_full_path, st, 0); if( stat_rc == VFSError::Ok ) break; switch( m_OnSourceAccessError(stat_rc, _full_path, vfs) ) { @@ -140,7 +140,7 @@ void AttrsChangingJob::ScanItem(const std::string &_full_path, dir_entries.emplace_back(_entry); return true; }; - const auto list_rc = vfs.IterateDirectoryListing(_full_path.c_str(), callback); + const auto list_rc = vfs.IterateDirectoryListing(_full_path, callback); if( list_rc == VFSError::Ok ) break; switch( m_OnSourceAccessError(list_rc, _full_path, vfs) ) { @@ -211,7 +211,7 @@ bool AttrsChangingJob::ChmodSingleItem(const std::string &_path, VFSHost &_vfs, return true; while( true ) { - const auto chmod_rc = _vfs.SetPermissions(_path.c_str(), mode); + const auto chmod_rc = _vfs.SetPermissions(_path, mode); if( chmod_rc == VFSError::Ok ) break; switch( m_OnChmodError(chmod_rc, _path, _vfs) ) { @@ -237,7 +237,7 @@ bool AttrsChangingJob::ChownSingleItem(const std::string &_path, VFSHost &_vfs, return true; while( true ) { - const auto chown_rc = _vfs.SetOwnership(_path.c_str(), new_uid, new_gid); + const auto chown_rc = _vfs.SetOwnership(_path, new_uid, new_gid); if( chown_rc == VFSError::Ok ) break; switch( m_OnChownError(chown_rc, _path, _vfs) ) { @@ -263,7 +263,7 @@ bool AttrsChangingJob::ChflagSingleItem(const std::string &_path, VFSHost &_vfs, return true; while( true ) { - const auto chflags_rc = _vfs.SetFlags(_path.c_str(), flags, vfs::Flags::None); + const auto chflags_rc = _vfs.SetFlags(_path, flags, vfs::Flags::None); if( chflags_rc == VFSError::Ok ) break; switch( m_OnFlagsError(chflags_rc, _path, _vfs) ) { @@ -284,11 +284,8 @@ bool AttrsChangingJob::ChflagSingleItem(const std::string &_path, VFSHost &_vfs, bool AttrsChangingJob::ChtimesSingleItem(const std::string &_path, VFSHost &_vfs, [[maybe_unused]] const VFSStat &_stat) { while( true ) { - const auto set_times_rc = _vfs.SetTimes(_path.c_str(), - m_Command.times->btime, - m_Command.times->mtime, - m_Command.times->ctime, - m_Command.times->atime); + const auto set_times_rc = _vfs.SetTimes( + _path, m_Command.times->btime, m_Command.times->mtime, m_Command.times->ctime, m_Command.times->atime); if( set_times_rc == VFSError::Ok ) break; switch( m_OnTimesError(set_times_rc, _path, _vfs) ) { diff --git a/Source/Operations/source/BatchRenaming/BatchRenamingDialog.mm b/Source/Operations/source/BatchRenaming/BatchRenamingDialog.mm index 3ec290a4e..62989d7d2 100644 --- a/Source/Operations/source/BatchRenaming/BatchRenamingDialog.mm +++ b/Source/Operations/source/BatchRenaming/BatchRenamingDialog.mm @@ -642,10 +642,7 @@ - (BOOL)validateMenuItem:(NSMenuItem *)item { if( item.menu == self.FilenamesTable.menu ) { auto clicked_row = self.FilenamesTable.clickedRow; - if( clicked_row >= 0 && clicked_row < self.FilenamesTable.numberOfRows ) - return true; - else - return false; + return clicked_row >= 0 && clicked_row < self.FilenamesTable.numberOfRows; } return true; diff --git a/Source/Operations/source/BatchRenaming/BatchRenamingJob.cpp b/Source/Operations/source/BatchRenaming/BatchRenamingJob.cpp index ecb7e929f..1b4f39031 100644 --- a/Source/Operations/source/BatchRenaming/BatchRenamingJob.cpp +++ b/Source/Operations/source/BatchRenaming/BatchRenamingJob.cpp @@ -35,13 +35,13 @@ void BatchRenamingJob::Rename(const std::string &_src, const std::string &_dst) } while( true ) { - const auto dst_exists = m_VFS->Exists(_dst.c_str()); + const auto dst_exists = m_VFS->Exists(_dst); int rc = VFSError::Ok; - if( dst_exists && LowercaseEqual(_src, _dst) == false ) + if( dst_exists && !LowercaseEqual(_src, _dst) ) rc = VFSError::FromErrno(EEXIST); else - rc = m_VFS->Rename(_src.c_str(), _dst.c_str()); + rc = m_VFS->Rename(_src, _dst); if( rc == VFSError::Ok ) break; diff --git a/Source/Operations/source/BatchRenaming/BatchRenamingScheme.mm b/Source/Operations/source/BatchRenaming/BatchRenamingScheme.mm index 6d79a110e..71396b59f 100644 --- a/Source/Operations/source/BatchRenaming/BatchRenamingScheme.mm +++ b/Source/Operations/source/BatchRenaming/BatchRenamingScheme.mm @@ -3,6 +3,8 @@ #include #include +#include + namespace nc::ops { std::optional> @@ -540,9 +542,7 @@ n += stripe->second; } if( auto width = EatIntWithPreffix(_ph, _pos + n, ':') ) { - counter.width = width->first; - if( counter.width > 30 ) - counter.width = 30; + counter.width = std::min(width->first, 30); n += width->second; } @@ -565,8 +565,7 @@ auto str = [_from substringWithRange:res.toNSRange()]; if( (_te.zero_flag || _te.space_flag) && rr.length != Range::max_length() && str.length < rr.length ) { auto insufficient = rr.length - str.length; - if( insufficient > 300 ) - insufficient = 300; + insufficient = std::min(insufficient, 300); auto padding = [@"" stringByPaddingToLength:insufficient withString:(_te.zero_flag ? @"0" : @" ")startingAtIndex:0]; @@ -613,7 +612,7 @@ char *buf = static_cast(alloca(_c.width + 32)); // no heap allocs, for great justice! if( !buf ) return @""; - *fmt::format_to(buf, "{:0{}}", _c.start + _c.step * (_file_number / _c.stripe), _c.width) = 0; + *fmt::format_to(buf, "{:0{}}", _c.start + (_c.step * (_file_number / _c.stripe)), _c.width) = 0; return [NSString stringWithUTF8String:buf]; } @@ -956,7 +955,7 @@ { std::filesystem::path parent_path(item.Directory()); if( parent_path.filename().empty() ) { // play around trailing slash - if( parent_path.has_parent_path() == false ) + if( !parent_path.has_parent_path() ) return @""; // wtf? parent_path = parent_path.parent_path(); } @@ -967,7 +966,7 @@ { std::filesystem::path parent_path(item.Directory()); if( parent_path.filename().empty() ) { // play around trailing slash - if( parent_path.has_parent_path() == false ) + if( !parent_path.has_parent_path() ) return @""; // wtf? parent_path = parent_path.parent_path(); } diff --git a/Source/Operations/source/BriefOperationView.mm b/Source/Operations/source/BriefOperationView.mm index a3af1a721..6d1ae526a 100644 --- a/Source/Operations/source/BriefOperationView.mm +++ b/Source/Operations/source/BriefOperationView.mm @@ -38,7 +38,7 @@ - (void)updateTrackingAreas - (void)mouseEntered:(NSEvent *) [[maybe_unused]] _event { - if( m_MouseOver == true ) + if( m_MouseOver ) return; [self willChangeValueForKey:@"isMouseOver"]; @@ -48,7 +48,7 @@ - (void)mouseEntered:(NSEvent *) [[maybe_unused]] _event - (void)mouseExited:(NSEvent *) [[maybe_unused]] _event { - if( m_MouseOver == false ) + if( !m_MouseOver ) return; [self willChangeValueForKey:@"isMouseOver"]; diff --git a/Source/Operations/source/Compression/CompressionJob.cpp b/Source/Operations/source/Compression/CompressionJob.cpp index ba5160fa9..151c411ac 100644 --- a/Source/Operations/source/Compression/CompressionJob.cpp +++ b/Source/Operations/source/Compression/CompressionJob.cpp @@ -96,7 +96,7 @@ bool CompressionJob::BuildArchive() { const auto flags = VFSFlags::OF_Write | VFSFlags::OF_Create | VFSFlags::OF_IRUsr | VFSFlags::OF_IWUsr | VFSFlags::OF_IRGrp; - m_DstVFS->CreateFile(m_TargetArchivePath.c_str(), m_TargetFile, nullptr); + m_DstVFS->CreateFile(m_TargetArchivePath, m_TargetFile, nullptr); const auto open_rc = m_TargetFile->Open(flags); if( open_rc == VFSError::Ok ) { m_Archive = archive_write_new(); @@ -131,7 +131,7 @@ bool CompressionJob::BuildArchive() m_TargetFile->Close(); if( IsStopped() ) - m_DstVFS->Unlink(m_TargetArchivePath.c_str(), nullptr); + m_DstVFS->Unlink(m_TargetArchivePath, nullptr); } else { m_TargetWriteError(open_rc, m_TargetArchivePath, *m_DstVFS); @@ -187,7 +187,7 @@ CompressionJob::ProcessSymlinkItem(int _index, const std::string &_relative_path VFSStat stat; while( true ) { - const auto rc = vfs.Stat(_full_path.c_str(), stat, VFSFlags::F_NoFollow, nullptr); + const auto rc = vfs.Stat(_full_path, stat, VFSFlags::F_NoFollow, nullptr); if( rc == VFSError::Ok ) break; switch( m_SourceAccessError(rc, _full_path, vfs) ) { @@ -203,7 +203,7 @@ CompressionJob::ProcessSymlinkItem(int _index, const std::string &_relative_path char symlink[MAXPATHLEN]; while( true ) { - const auto rc = vfs.ReadSymlink(_full_path.c_str(), symlink, MAXPATHLEN, nullptr); + const auto rc = vfs.ReadSymlink(_full_path, symlink, MAXPATHLEN, nullptr); if( rc == VFSError::Ok ) break; switch( m_SourceAccessError(rc, _full_path, vfs) ) { @@ -235,7 +235,7 @@ CompressionJob::ProcessDirectoryItem(int _index, const std::string &_relative_pa VFSStat vfs_stat; while( true ) { - const auto rc = vfs.Stat(_full_path.c_str(), vfs_stat, 0, nullptr); + const auto rc = vfs.Stat(_full_path, vfs_stat, 0, nullptr); if( rc == VFSError::Ok ) break; switch( m_SourceAccessError(rc, _full_path, vfs) ) { @@ -259,10 +259,10 @@ CompressionJob::ProcessDirectoryItem(int _index, const std::string &_relative_pa Stop(); } - if( IsEncrypted() == false ) { + if( !IsEncrypted() ) { // we can't support encrypted EAs due to lack of read support in LA VFSFilePtr src_file; - vfs.CreateFile(_full_path.c_str(), src_file); + vfs.CreateFile(_full_path, src_file); if( src_file->Open(VFSFlags::OF_Read) == VFSError::Ok ) { const std::string name_wo_slash = {std::begin(_relative_path), std::end(_relative_path) - 1}; WriteEAsIfAny(*src_file, m_Archive, name_wo_slash.c_str()); @@ -280,7 +280,7 @@ CompressionJob::ProcessRegularItem(int _index, const std::string &_relative_path VFSStat stat; while( true ) { - const auto rc = vfs.Stat(_full_path.c_str(), stat, 0); + const auto rc = vfs.Stat(_full_path, stat, 0); if( rc == VFSError::Ok ) break; switch( m_SourceAccessError(rc, _full_path, vfs) ) { @@ -295,7 +295,7 @@ CompressionJob::ProcessRegularItem(int _index, const std::string &_relative_path } VFSFilePtr src_file; - vfs.CreateFile(_full_path.c_str(), src_file); + vfs.CreateFile(_full_path, src_file); while( true ) { const auto flags = VFSFlags::OF_Read | VFSFlags::OF_ShLock; @@ -359,7 +359,7 @@ CompressionJob::ProcessRegularItem(int _index, const std::string &_relative_path return StepResult::Skipped; } - if( IsEncrypted() == false ) { + if( !IsEncrypted() ) { // we can't support encrypted EAs due to lack of read support in LA WriteEAsIfAny(*src_file, m_Archive, _relative_path.c_str()); } @@ -371,12 +371,12 @@ std::string CompressionJob::FindSuitableFilename(const std::string &_proposed_ar { std::string fn = fmt::format("{}{}.zip", m_DstRoot, _proposed_arcname); VFSStat st; - if( m_DstVFS->Stat(fn.c_str(), st, VFSFlags::F_NoFollow, nullptr) != 0 ) + if( m_DstVFS->Stat(fn, st, VFSFlags::F_NoFollow, nullptr) != 0 ) return fn; for( int i = 2; i < 100; ++i ) { fn = fmt::format("{}{} {}.zip", m_DstRoot, _proposed_arcname, i); - if( m_DstVFS->Stat(fn.c_str(), st, VFSFlags::F_NoFollow, nullptr) != 0 ) + if( m_DstVFS->Stat(fn, st, VFSFlags::F_NoFollow, nullptr) != 0 ) return fn; } return {}; @@ -431,7 +431,7 @@ bool CompressionJob::ScanItem(const VFSListingItem &_item, Source &_ctx) directory_entries.emplace_back(_dirent.name); return true; }; - const auto rc = host.IterateDirectoryListing(_item.Path().c_str(), callback); + const auto rc = host.IterateDirectoryListing(_item.Path(), callback); if( rc == VFSError::Ok ) break; switch( m_SourceScanError(rc, _item.Path(), host) ) { @@ -467,7 +467,7 @@ bool CompressionJob::ScanItem(const std::string &_full_path, auto &vfs = _ctx.base_hosts[_vfs_no]; while( true ) { - const auto rc = vfs->Stat(_full_path.c_str(), stat_buffer, VFSFlags::F_NoFollow, nullptr); + const auto rc = vfs->Stat(_full_path, stat_buffer, VFSFlags::F_NoFollow, nullptr); if( rc == VFSError::Ok ) break; switch( m_SourceScanError(rc, _full_path, *vfs) ) { @@ -513,7 +513,7 @@ bool CompressionJob::ScanItem(const std::string &_full_path, directory_entries.emplace_back(_dirent.name); return true; }; - const auto rc = vfs->IterateDirectoryListing(_full_path.c_str(), callback); + const auto rc = vfs->IterateDirectoryListing(_full_path, callback); if( rc == VFSError::Ok ) break; switch( m_SourceScanError(rc, _full_path, *vfs) ) { @@ -541,7 +541,8 @@ bool CompressionJob::ScanItem(const std::string &_full_path, return true; } -ssize_t CompressionJob::WriteCallback(struct archive *, void *_client_data, const void *_buffer, size_t _length) +ssize_t +CompressionJob::WriteCallback(struct archive * /*_archive*/, void *_client_data, const void *_buffer, size_t _length) { const auto me = static_cast(_client_data); const ssize_t ret = me->m_TargetFile->Write(_buffer, _length); @@ -552,7 +553,7 @@ ssize_t CompressionJob::WriteCallback(struct archive *, void *_client_data, cons bool CompressionJob::IsEncrypted() const noexcept { - return m_Password.empty() == false; + return !m_Password.empty(); } static void archive_entry_copy_stat(struct archive_entry *_ae, const VFSStat &_vfs_stat) diff --git a/Source/Operations/source/Compression/CompressionJob.h b/Source/Operations/source/Compression/CompressionJob.h index 1dd6d87c9..a1341b6d1 100644 --- a/Source/Operations/source/Compression/CompressionJob.h +++ b/Source/Operations/source/Compression/CompressionJob.h @@ -77,7 +77,7 @@ class CompressionJob final : public Job, public CompressionJobCallbacks std::string FindSuitableFilename(const std::string &_proposed_arcname) const; bool IsEncrypted() const noexcept; - static ssize_t WriteCallback(struct archive *, void *_client_data, const void *_buffer, size_t _length); + static ssize_t WriteCallback(struct archive *_archive, void *_client_data, const void *_buffer, size_t _length); std::vector m_InitialListingItems; std::string m_DstRoot; diff --git a/Source/Operations/source/Copying/Copying.mm b/Source/Operations/source/Copying/Copying.mm index 141aee916..53596218c 100644 --- a/Source/Operations/source/Copying/Copying.mm +++ b/Source/Operations/source/Copying/Copying.mm @@ -603,7 +603,7 @@ break; } sheet.path = [NSString stringWithUTF8String:_path.c_str()]; - sheet.showApplyToAll = m_Job->IsSingleScannedItemProcessing() == false; + sheet.showApplyToAll = !m_Job->IsSingleScannedItemProcessing(); sheet.errorNo = _err; [sheet addButtonWithTitle:NSLocalizedString(@"Abort", "") responseCode:NSModalResponseStop]; [sheet addButtonWithTitle:NSLocalizedString(@"Unlock", "") responseCode:NSModalResponseUnlock]; @@ -642,7 +642,7 @@ void Copying::OnStageChanged() { const CopyingTitleBuilder b{m_Job->SourceItems(), m_Job->DestinationPath(), m_Job->Options()}; - std::string title = ""; + std::string title; switch( m_Job->Stage() ) { case CopyingJob::Stage::Default: case CopyingJob::Stage::Process: diff --git a/Source/Operations/source/Copying/CopyingJob.cpp b/Source/Operations/source/Copying/CopyingJob.cpp index 1d745260f..f249d9c9d 100644 --- a/Source/Operations/source/Copying/CopyingJob.cpp +++ b/Source/Operations/source/Copying/CopyingJob.cpp @@ -166,7 +166,7 @@ void CopyingJob::ProcessItems() for( auto &item : m_Checksums ) { bool matched = false; auto step_result = VerifyCopiedFile(item, matched); - if( step_result != StepResult::Ok || matched != true ) { + if( step_result != StepResult::Ok || !matched ) { m_OnFileVerificationFailed(item.destination_path, *m_DestinationHost); all_matched = false; } @@ -193,7 +193,7 @@ CopyingJob::StepResult CopyingJob::ProcessItemNo(int _item_number) auto source_path = m_SourceItems.ComposeFullPath(_item_number); const auto nonexistent_dst_req_handler = RequestNonexistentDst([&] { auto new_path = FindNonExistingItemPath(destination_path, *m_DestinationHost, [&] { return IsStopped(); }); - if( new_path.empty() == false ) + if( !new_path.empty() ) destination_path = std::move(new_path); }); const auto is_same_native_volume = [&]() { @@ -260,7 +260,7 @@ CopyingJob::StepResult CopyingJob::ProcessItemNo(int _item_number) destination_path, data_feedback, nonexistent_dst_req_handler); - if( m_Options.docopy == false ) { // move + if( !m_Options.docopy ) { // move if( step_result == StepResult::Ok ) m_SourceItemsToDelete.emplace_back(_item_number); // mark source file for deletion } @@ -409,13 +409,13 @@ CopyingJob::StepResult CopyingJob::ProcessSymlinkItem(VFSHost &_source_host, dynamic_cast(*m_DestinationHost), _destination_path, _new_dst_callback); - if( m_Options.docopy == false && result == StepResult::Ok ) + if( !m_Options.docopy && result == StepResult::Ok ) m_SourceItemsToDelete.emplace_back(m_CurrentlyProcessingSourceItemIndex); return result; } else { // vfs -> vfs const auto result = CopyVFSSymlinkToVFS(_source_host, _source_path, _destination_path, _new_dst_callback); - if( m_Options.docopy == false && result == StepResult::Ok ) + if( !m_Options.docopy && result == StepResult::Ok ) m_SourceItemsToDelete.emplace_back(m_CurrentlyProcessingSourceItemIndex); return result; } @@ -474,10 +474,10 @@ static bool IsSingleDirectoryCaseRenaming(const CopyingOptions &_options, return false; } else { - if( _dest_host.IsCaseSensitiveAtPath(_dest_path.c_str()) == true ) + if( _dest_host.IsCaseSensitiveAtPath(_dest_path) ) return false; - if( LowercaseEqual(_dest_path, item.Path()) == false ) + if( !LowercaseEqual(_dest_path, item.Path()) ) return false; } return true; @@ -487,7 +487,7 @@ CopyingJob::PathCompositionType CopyingJob::AnalyzeInitialDestination(std::strin bool &_need_to_build) { VFSStat st; - if( m_DestinationHost->Stat(m_InitialDestinationPath.c_str(), st, 0, nullptr) == 0 ) { + if( m_DestinationHost->Stat(m_InitialDestinationPath, st, 0, nullptr) == 0 ) { // destination entry already exist m_IsSingleDirectoryCaseRenaming = IsSingleDirectoryCaseRenaming( m_Options, m_VFSListingItems, *m_DestinationHost, m_InitialDestinationPath, st); @@ -543,7 +543,7 @@ CopyingJob::StepResult CopyingJob::BuildDestinationDirectory() const // find directories to build std::vector paths_to_build; ReverseForEachDirectoryInString(m_DestinationPath, [&](std::string _path) { - if( !m_DestinationHost->Exists(_path.c_str()) ) { + if( !m_DestinationHost->Exists(_path) ) { paths_to_build.emplace_back(std::move(_path)); return true; } @@ -557,7 +557,7 @@ CopyingJob::StepResult CopyingJob::BuildDestinationDirectory() const // build absent directories. no skipping here - all or nothing. for( auto &path : paths_to_build ) { while( true ) { - const auto rc = m_DestinationHost->CreateDirectory(path.c_str(), g_NewDirectoryMode); + const auto rc = m_DestinationHost->CreateDirectory(path, g_NewDirectoryMode); if( rc == VFSError::Ok ) break; switch( m_OnCantCreateDestinationRootDir(rc, path, *m_DestinationHost) ) { @@ -597,7 +597,7 @@ std::tuple CopyingJob::ScanSourceItems() // gather stat() information regarding current entry VFSStat st; while( true ) { - const auto rc = host.Stat(path.c_str(), st, stat_flags, nullptr); + const auto rc = host.Stat(path, st, stat_flags, nullptr); if( rc == VFSError::Ok ) break; switch( m_OnCantAccessSourceItem(rc, path, host) ) { @@ -642,7 +642,7 @@ std::tuple CopyingJob::ScanSourceItems() // if we're renaming, and there's a destination file already if( !m_IsSingleDirectoryCaseRenaming ) { const auto dest_path = ComposeDestinationNameForItemInDB(my_indx, db); - if( !LowercaseEqual(path, dest_path) && m_DestinationHost->Exists(dest_path.c_str()) ) + if( !LowercaseEqual(path, dest_path) && m_DestinationHost->Exists(dest_path) ) should_go_inside = true; } } @@ -654,7 +654,7 @@ std::tuple CopyingJob::ScanSourceItems() dir_ents.emplace_back(_.name); return true; }; - const auto rc = host.IterateDirectoryListing(path.c_str(), callback); + const auto rc = host.IterateDirectoryListing(path, callback); if( rc == VFSError::Ok ) break; switch( m_OnCantAccessSourceItem(rc, path, host) ) { @@ -1102,7 +1102,7 @@ CopyingJob::StepResult CopyingJob::CopyVFSFileToNativeFile(VFSHost &_src_vfs, // get information about the source file VFSStat src_stat_buffer; while( true ) { - const auto rc = _src_vfs.Stat(_src_path.c_str(), src_stat_buffer, 0); + const auto rc = _src_vfs.Stat(_src_path, src_stat_buffer, 0); if( rc == VFSError::Ok ) break; switch( m_OnCantAccessSourceItem(rc, _src_path, _src_vfs) ) { @@ -1118,7 +1118,7 @@ CopyingJob::StepResult CopyingJob::CopyVFSFileToNativeFile(VFSHost &_src_vfs, // create the source file object VFSFilePtr src_file; while( true ) { - const auto rc = _src_vfs.CreateFile(_src_path.c_str(), src_file); + const auto rc = _src_vfs.CreateFile(_src_path, src_file); if( rc == VFSError::Ok ) break; switch( m_OnCantAccessSourceItem(rc, _src_path, _src_vfs) ) { @@ -1471,7 +1471,7 @@ CopyingJob::StepResult CopyingJob::CopyVFSFileToVFSFile(VFSHost &_src_vfs, // get information about the source file VFSStat src_stat_buffer; while( true ) { - const auto rc = _src_vfs.Stat(_src_path.c_str(), src_stat_buffer, 0); + const auto rc = _src_vfs.Stat(_src_path, src_stat_buffer, 0); if( rc == VFSError::Ok ) break; switch( m_OnCantAccessSourceItem(rc, _src_path, _src_vfs) ) { @@ -1487,7 +1487,7 @@ CopyingJob::StepResult CopyingJob::CopyVFSFileToVFSFile(VFSHost &_src_vfs, // create the source file object VFSFilePtr src_file; while( true ) { - const auto rc = _src_vfs.CreateFile(_src_path.c_str(), src_file); + const auto rc = _src_vfs.CreateFile(_src_path, src_file); if( rc == VFSError::Ok ) break; switch( m_OnCantAccessSourceItem(rc, _src_path, _src_vfs) ) { @@ -1536,7 +1536,7 @@ CopyingJob::StepResult CopyingJob::CopyVFSFileToVFSFile(VFSHost &_src_vfs, // stat destination VFSStat dst_stat_buffer; - if( m_DestinationHost->Stat(_dst_path.c_str(), dst_stat_buffer, 0, nullptr) == 0 ) { + if( m_DestinationHost->Stat(_dst_path, dst_stat_buffer, 0, nullptr) == 0 ) { // file already exist. what should we do now? const auto setup_overwrite = [&] { dst_open_flags = VFSFlags::OF_Write | VFSFlags::OF_Truncate | VFSFlags::OF_NoCache; @@ -1587,7 +1587,7 @@ CopyingJob::StepResult CopyingJob::CopyVFSFileToVFSFile(VFSHost &_src_vfs, // open file object for destination VFSFilePtr dst_file; while( true ) { - const auto rc = m_DestinationHost->CreateFile(_dst_path.c_str(), dst_file); + const auto rc = m_DestinationHost->CreateFile(_dst_path, dst_file); if( rc == VFSError::Ok ) break; switch( m_OnCantOpenDestinationFile(rc, _dst_path, *m_DestinationHost) ) { @@ -1624,8 +1624,8 @@ CopyingJob::StepResult CopyingJob::CopyVFSFileToVFSFile(VFSHost &_src_vfs, // we need to revert what we've done dst_file->Close(); dst_file.reset(); - if( do_unlink_on_stop == true ) - m_DestinationHost->Unlink(_dst_path.c_str(), nullptr); + if( do_unlink_on_stop ) + m_DestinationHost->Unlink(_dst_path, nullptr); } }); @@ -1764,7 +1764,7 @@ CopyingJob::StepResult CopyingJob::CopyVFSFileToVFSFile(VFSHost &_src_vfs, dst_file.reset(); if( m_Options.copy_file_times && do_set_times && m_DestinationHost->Features() & vfs::HostFeatures::SetTimes ) - m_DestinationHost->SetTimes(_dst_path.c_str(), + m_DestinationHost->SetTimes(_dst_path, src_stat_buffer.btime.tv_sec, src_stat_buffer.mtime.tv_sec, src_stat_buffer.ctime.tv_sec, @@ -1936,7 +1936,7 @@ CopyingJob::StepResult CopyingJob::CopyVFSDirectoryToNativeDirectory(VFSHost &_s // we currently ignore possible errors on attributes copying, which is not great at all VFSStat src_stat_buffer; - if( _src_vfs.Stat(_src_path.c_str(), src_stat_buffer, 0, nullptr) < 0 ) + if( _src_vfs.Stat(_src_path, src_stat_buffer, 0, nullptr) < 0 ) return StepResult::Ok; if( m_Options.copy_unix_flags ) { @@ -1953,7 +1953,7 @@ CopyingJob::StepResult CopyingJob::CopyVFSDirectoryToNativeDirectory(VFSHost &_s // xattr processing if( m_Options.copy_xattrs ) { std::shared_ptr src_file; - if( _src_vfs.CreateFile(_src_path.c_str(), src_file, nullptr) >= 0 ) + if( _src_vfs.CreateFile(_src_path, src_file, nullptr) >= 0 ) if( src_file->Open(VFSFlags::OF_Read | VFSFlags::OF_Directory | VFSFlags::OF_ShLock) >= 0 ) if( src_file->XAttrCount() > 0 ) CopyXattrsFromVFSFileToPath(*src_file, _dst_path.c_str()); @@ -1977,7 +1977,7 @@ CopyingJob::StepResult CopyingJob::CopyVFSDirectoryToVFSDirectory(VFSHost &_src_ { VFSStat src_st; while( true ) { - const auto rc = _src_vfs.Stat(_src_path.c_str(), src_st, 0); + const auto rc = _src_vfs.Stat(_src_path, src_st, 0); if( rc == VFSError::Ok ) break; switch( m_OnCantAccessSourceItem(rc, _dst_path, _src_vfs) ) { @@ -1991,12 +1991,12 @@ CopyingJob::StepResult CopyingJob::CopyVFSDirectoryToVFSDirectory(VFSHost &_src_ } VFSStat dest_st; - if( m_DestinationHost->Stat(_dst_path.c_str(), dest_st, VFSFlags::F_NoFollow, nullptr) == 0 ) { + if( m_DestinationHost->Stat(_dst_path, dest_st, VFSFlags::F_NoFollow, nullptr) == 0 ) { // this directory already exist. currently do nothing, later - update it's attrs. } else { while( true ) { - const auto rc = m_DestinationHost->CreateDirectory(_dst_path.c_str(), g_NewDirectoryMode); + const auto rc = m_DestinationHost->CreateDirectory(_dst_path, g_NewDirectoryMode); if( rc == VFSError::Ok ) break; switch( m_OnCantCreateDestinationDir(rc, _dst_path, *m_DestinationHost) ) { @@ -2022,7 +2022,7 @@ CopyingJob::StepResult CopyingJob::CopyVFSDirectoryToVFSDirectory(VFSHost &_src_ if( m_Options.copy_file_times && (m_DestinationHost->Features() & vfs::HostFeatures::SetTimes) ) { // TODO: move to epilogue m_DestinationHost->SetTimes( - _dst_path.c_str(), src_st.btime.tv_sec, src_st.mtime.tv_sec, src_st.ctime.tv_sec, src_st.atime.tv_sec); + _dst_path, src_st.btime.tv_sec, src_st.mtime.tv_sec, src_st.ctime.tv_sec, src_st.atime.tv_sec); } return StepResult::Ok; @@ -2191,7 +2191,7 @@ CopyingJob::RenameVFSDirectory(VFSHost &_common_host, const std::string &_src_pa { // check if a destination item already exists VFSStat dst_stat_buffer; - const auto dst_exists = _common_host.Stat(_dst_path.c_str(), dst_stat_buffer, VFSFlags::F_NoFollow) == VFSError::Ok; + const auto dst_exists = _common_host.Stat(_dst_path, dst_stat_buffer, VFSFlags::F_NoFollow) == VFSError::Ok; auto dst_dir_is_dummy = false; if( dst_exists && !S_ISDIR(dst_stat_buffer.mode) ) { // if user agrees - remove exising file and create a directory with a same name @@ -2205,7 +2205,7 @@ CopyingJob::RenameVFSDirectory(VFSHost &_common_host, const std::string &_src_pa } while( true ) { - const auto rc = _common_host.Unlink(_dst_path.c_str()); + const auto rc = _common_host.Unlink(_dst_path); if( rc == VFSError::Ok ) break; @@ -2220,7 +2220,7 @@ CopyingJob::RenameVFSDirectory(VFSHost &_common_host, const std::string &_src_pa } while( true ) { - const auto rc = _common_host.CreateDirectory(_dst_path.c_str(), g_NewDirectoryMode); + const auto rc = _common_host.CreateDirectory(_dst_path, g_NewDirectoryMode); if( rc == VFSError::Ok ) break; switch( m_OnCantCreateDestinationDir(rc, _dst_path, _common_host) ) { @@ -2238,12 +2238,12 @@ CopyingJob::RenameVFSDirectory(VFSHost &_common_host, const std::string &_src_pa if( dst_exists ) { // Destination file already exists. - const auto case_renaming = _common_host.IsCaseSensitiveAtPath(_dst_path.c_str()) == false && - LowercaseEqual(_dst_path, _src_path) == true; + const auto case_renaming = + !_common_host.IsCaseSensitiveAtPath(_dst_path) && LowercaseEqual(_dst_path, _src_path); if( !case_renaming ) { VFSStat src_stat; while( true ) { - const auto rc = _common_host.Stat(_src_path.c_str(), src_stat, VFSFlags::F_NoFollow); + const auto rc = _common_host.Stat(_src_path, src_stat, VFSFlags::F_NoFollow); if( rc == VFSError::Ok ) break; switch( m_OnCantAccessSourceItem(rc, _src_path, _common_host) ) { @@ -2277,17 +2277,17 @@ CopyingJob::RenameVFSDirectory(VFSHost &_common_host, const std::string &_src_pa // copy attributes and sentence the source to death if( m_Options.copy_file_times && m_DestinationHost->Features() & vfs::HostFeatures::SetTimes ) - m_DestinationHost->SetTimes(_dst_path.c_str(), + m_DestinationHost->SetTimes(_dst_path, src_stat.btime.tv_sec, src_stat.mtime.tv_sec, src_stat.ctime.tv_sec, src_stat.atime.tv_sec); if( m_Options.copy_unix_owners && m_DestinationHost->Features() & vfs::HostFeatures::SetOwnership ) - m_DestinationHost->SetOwnership(_dst_path.c_str(), src_stat.uid, src_stat.gid); + m_DestinationHost->SetOwnership(_dst_path, src_stat.uid, src_stat.gid); if( m_Options.copy_unix_flags && m_DestinationHost->Features() & vfs::HostFeatures::SetPermissions ) - m_DestinationHost->SetPermissions(_dst_path.c_str(), src_stat.mode); + m_DestinationHost->SetPermissions(_dst_path, src_stat.mode); return {StepResult::Ok, SourceItemAftermath::NeedsToBeDeleted}; } @@ -2295,7 +2295,7 @@ CopyingJob::RenameVFSDirectory(VFSHost &_common_host, const std::string &_src_pa // do rename itself while( true ) { - const auto rc = _common_host.Rename(_src_path.c_str(), _dst_path.c_str()); + const auto rc = _common_host.Rename(_src_path, _dst_path); if( rc == VFSError::Ok ) break; switch( m_OnDestinationFileWriteError(rc, _dst_path, _common_host) ) { @@ -2408,12 +2408,12 @@ CopyingJob::StepResult CopyingJob::RenameVFSFile(VFSHost &_common_host, { // check if destination file already exist VFSStat dst_stat_buffer; - if( _common_host.Stat(_dst_path.c_str(), dst_stat_buffer, VFSFlags::F_NoFollow) == 0 ) { + if( _common_host.Stat(_dst_path, dst_stat_buffer, VFSFlags::F_NoFollow) == 0 ) { // Destination file already exists. VFSStat src_stat_buffer; while( true ) { - const auto rc = _common_host.Stat(_src_path.c_str(), src_stat_buffer, VFSFlags::F_NoFollow); + const auto rc = _common_host.Stat(_src_path, src_stat_buffer, VFSFlags::F_NoFollow); if( rc == VFSError::Ok ) break; switch( m_OnCantAccessSourceItem(rc, _src_path, _common_host) ) { @@ -2448,7 +2448,7 @@ CopyingJob::StepResult CopyingJob::RenameVFSFile(VFSHost &_common_host, // do rename itself while( true ) { - const auto rc = _common_host.Rename(_src_path.c_str(), _dst_path.c_str()); + const auto rc = _common_host.Rename(_src_path, _dst_path); if( rc == VFSError::Ok ) break; switch( m_OnDestinationFileWriteError(rc, _dst_path, _common_host) ) { @@ -2482,7 +2482,7 @@ void CopyingJob::ClearSourceItem(const std::string &_path, mode_t _mode, VFSHost { while( true ) { const auto is_dir = S_ISDIR(_mode); - const auto vfs_rc = is_dir ? _host.RemoveDirectory(_path.c_str()) : _host.Unlink(_path.c_str()); + const auto vfs_rc = is_dir ? _host.RemoveDirectory(_path) : _host.Unlink(_path); if( vfs_rc == VFSError::Ok ) break; @@ -2568,7 +2568,7 @@ CopyingJob::StepResult CopyingJob::VerifyCopiedFile(const ChecksumExpectation &_ _matched = false; VFSFilePtr file; int rc; - if( (rc = m_DestinationHost->CreateFile(_exp.destination_path.c_str(), file, nullptr)) != 0 ) + if( (rc = m_DestinationHost->CreateFile(_exp.destination_path, file, nullptr)) != 0 ) switch( m_OnDestinationFileReadError(rc, _exp.destination_path, *m_DestinationHost) ) { case DestinationFileReadErrorResolution::Skip: return StepResult::Skipped; @@ -2682,7 +2682,7 @@ CopyingJob::StepResult CopyingJob::CopyNativeSymlinkToNative(vfs::NativeHost &_n return StepResult::Stop; } - if( new_path == false ) { + if( !new_path ) { if( io.trash(_dst_path.c_str()) != 0 ) { while( true ) { const auto rc = @@ -2729,7 +2729,7 @@ CopyingJob::StepResult CopyingJob::CopyVFSSymlinkToNative(VFSHost &_src_vfs, char linkpath[MAXPATHLEN]; while( true ) { - const auto rc = _src_vfs.ReadSymlink(_src_path.c_str(), linkpath, MAXPATHLEN); + const auto rc = _src_vfs.ReadSymlink(_src_path, linkpath, MAXPATHLEN); if( rc == VFSError::Ok ) break; switch( m_OnCantAccessSourceItem(rc, _src_path, _src_vfs) ) { @@ -2746,7 +2746,7 @@ CopyingJob::StepResult CopyingJob::CopyVFSSymlinkToNative(VFSHost &_src_vfs, if( io.lstat(_dst_path.c_str(), &dst_stat_buffer) == 0 ) { VFSStat src_stat_buffer; while( true ) { - const auto rc = _src_vfs.Stat(_src_path.c_str(), src_stat_buffer, VFSFlags::F_NoFollow); + const auto rc = _src_vfs.Stat(_src_path, src_stat_buffer, VFSFlags::F_NoFollow); if( rc == VFSError::Ok ) break; switch( m_OnCantAccessSourceItem(rc, _src_path, _src_vfs) ) { @@ -2782,7 +2782,7 @@ CopyingJob::StepResult CopyingJob::CopyVFSSymlinkToNative(VFSHost &_src_vfs, return StepResult::Stop; } - if( new_dst_path == false ) { + if( !new_dst_path ) { if( io.trash(_dst_path.c_str()) != 0 ) { while( true ) { const auto rc = @@ -2828,7 +2828,7 @@ CopyingJob::StepResult CopyingJob::CopyVFSSymlinkToVFS(VFSHost &_src_vfs, char linkpath[MAXPATHLEN]; while( true ) { - const auto rc = _src_vfs.ReadSymlink(_src_path.c_str(), linkpath, MAXPATHLEN); + const auto rc = _src_vfs.ReadSymlink(_src_path, linkpath, MAXPATHLEN); if( rc == VFSError::Ok ) break; switch( m_OnCantAccessSourceItem(rc, _src_path, _src_vfs) ) { @@ -2842,10 +2842,10 @@ CopyingJob::StepResult CopyingJob::CopyVFSSymlinkToVFS(VFSHost &_src_vfs, } VFSStat dst_stat_buffer; - if( dst_host.Stat(_dst_path.c_str(), dst_stat_buffer, VFSFlags::F_NoFollow) == VFSError::Ok ) { + if( dst_host.Stat(_dst_path, dst_stat_buffer, VFSFlags::F_NoFollow) == VFSError::Ok ) { VFSStat src_stat_buffer; while( true ) { - const auto rc = _src_vfs.Stat(_src_path.c_str(), src_stat_buffer, VFSFlags::F_NoFollow); + const auto rc = _src_vfs.Stat(_src_path, src_stat_buffer, VFSFlags::F_NoFollow); if( rc == VFSError::Ok ) break; switch( m_OnCantAccessSourceItem(rc, _src_path, _src_vfs) ) { @@ -2883,11 +2883,11 @@ CopyingJob::StepResult CopyingJob::CopyVFSSymlinkToVFS(VFSHost &_src_vfs, return StepResult::Stop; } - if( new_path == false ) { - if( dst_host.Trash(_dst_path.c_str(), nullptr) != VFSError::Ok ) { + if( !new_path ) { + if( dst_host.Trash(_dst_path, nullptr) != VFSError::Ok ) { while( true ) { - const auto rc = dst_stat_buffer.mode_bits.dir ? dst_host.RemoveDirectory(_dst_path.c_str()) - : dst_host.Unlink(_dst_path.c_str()); + const auto rc = dst_stat_buffer.mode_bits.dir ? dst_host.RemoveDirectory(_dst_path) + : dst_host.Unlink(_dst_path); if( rc == VFSError::Ok ) break; switch( m_OnCantDeleteDestinationFile(rc, _dst_path, dst_host) ) { @@ -2904,7 +2904,7 @@ CopyingJob::StepResult CopyingJob::CopyVFSSymlinkToVFS(VFSHost &_src_vfs, } while( true ) { - const auto rc = dst_host.CreateSymlink(_dst_path.c_str(), linkpath); + const auto rc = dst_host.CreateSymlink(_dst_path, linkpath); if( rc == VFSError::Ok ) break; switch( m_OnDestinationFileWriteError(rc, _dst_path, dst_host) ) { @@ -2961,11 +2961,11 @@ CopyingJob::StepResult CopyingJob::UnlockNativeItemNoFollow(const std::string &_ { auto unlock = [&]() -> int { VFSStat st; - const int stat_rc = _native_host.Stat(_path.c_str(), st, VFSFlags::F_NoFollow, {}); + const int stat_rc = _native_host.Stat(_path, st, VFSFlags::F_NoFollow, {}); if( stat_rc != VFSError::Ok ) return stat_rc; st.flags = (st.flags & ~UF_IMMUTABLE); - return _native_host.SetFlags(_path.c_str(), st.flags, VFSFlags::F_NoFollow, {}); + return _native_host.SetFlags(_path, st.flags, VFSFlags::F_NoFollow, {}); }; while( true ) { const int unlock_rc = unlock(); diff --git a/Source/Operations/source/Copying/Helpers.cpp b/Source/Operations/source/Copying/Helpers.cpp index 0af4b0e59..169750a5c 100644 --- a/Source/Operations/source/Copying/Helpers.cpp +++ b/Source/Operations/source/Copying/Helpers.cpp @@ -21,7 +21,7 @@ FindNonExistingItemPath(const std::string &_orig_existing_path, VFSHost &_host, if( _cancel_checker && _cancel_checker() ) return ""; auto path = fmt::format("{}{}{}", epilog, check_index, prologue); - if( _host.Exists(path.c_str(), _cancel_checker) == false ) { + if( !_host.Exists(path, _cancel_checker) ) { if( _cancel_checker && _cancel_checker() ) return ""; return path; diff --git a/Source/Operations/source/Copying/NativeFSHelpers.cpp b/Source/Operations/source/Copying/NativeFSHelpers.cpp index 546b2bfec..198232154 100644 --- a/Source/Operations/source/Copying/NativeFSHelpers.cpp +++ b/Source/Operations/source/Copying/NativeFSHelpers.cpp @@ -28,10 +28,7 @@ bool TryToPreallocateSpace(int64_t _preallocate_delta, int _file_des) noexcept // now try to preallocate the space in some chunks preallocstore.fst_flags = F_ALLOCATEALL; - if( fcntl(_file_des, F_PREALLOCATE, &preallocstore) == 0 ) - return true; - - return false; + return fcntl(_file_des, F_PREALLOCATE, &preallocstore) == 0; } bool SupportsFastTruncationAfterPreallocation(const utility::NativeFileSystemInfo &_fs_info) noexcept @@ -100,7 +97,7 @@ bool IsAnExternalExtenedAttributesStorage(VFSHost &_host, // check if current filesystem uses external eas assert(_native_fs_man); auto fs_info = _native_fs_man->VolumeFromPath(_path); - if( !fs_info || fs_info->interfaces.extended_attr == true ) + if( !fs_info || fs_info->interfaces.extended_attr ) return false; // check if a 'main' file exists diff --git a/Source/Operations/source/Deletion/DeletionJob.cpp b/Source/Operations/source/Deletion/DeletionJob.cpp index d0c70c01c..2ac46b7f9 100644 --- a/Source/Operations/source/Deletion/DeletionJob.cpp +++ b/Source/Operations/source/Deletion/DeletionJob.cpp @@ -51,7 +51,7 @@ void DeletionJob::DoScan() m_Script.emplace(si); const auto nonempty_rm = bool(item.Host()->Features() & vfs::HostFeatures::NonEmptyRmDir); - if( m_Type == DeletionType::Permanent && nonempty_rm == false ) + if( m_Type == DeletionType::Permanent && !nonempty_rm ) ScanDirectory(item.Path(), i, si.filename); } else { @@ -83,7 +83,7 @@ void DeletionJob::ScanDirectory(const std::string &_path, if( BlockIfPaused(); IsStopped() ) return; - if( auto rc = vfs.IterateDirectoryListing(_path.c_str(), it_callback); rc == VFSError::Ok ) + if( auto rc = vfs.IterateDirectoryListing(_path, it_callback); rc == VFSError::Ok ) break; else switch( m_OnReadDirError(rc, _path, vfs) ) { @@ -175,7 +175,7 @@ bool DeletionJob::DoUnlock(const std::string &_path, VFSHost &_vfs) void DeletionJob::DoUnlink(const std::string &_path, VFSHost &_vfs) { while( true ) { - const auto rc = _vfs.Unlink(_path.c_str()); + const auto rc = _vfs.Unlink(_path); if( rc == VFSError::Ok ) { Statistics().CommitProcessed(Statistics::SourceType::Items, 1); break; @@ -183,7 +183,7 @@ void DeletionJob::DoUnlink(const std::string &_path, VFSHost &_vfs) else if( IsNativeLockedItem(rc, _path, _vfs) ) { switch( m_OnLockedItem(rc, _path, _vfs, DeletionType::Permanent) ) { case LockedItemResolution::Unlock: { - if( DoUnlock(_path, _vfs) == false ) + if( !DoUnlock(_path, _vfs) ) return; continue; } @@ -215,7 +215,7 @@ void DeletionJob::DoUnlink(const std::string &_path, VFSHost &_vfs) void DeletionJob::DoRmDir(const std::string &_path, VFSHost &_vfs) { while( true ) { - const auto rc = _vfs.RemoveDirectory(_path.c_str()); + const auto rc = _vfs.RemoveDirectory(_path); if( rc == VFSError::Ok ) { Statistics().CommitProcessed(Statistics::SourceType::Items, 1); break; @@ -223,7 +223,7 @@ void DeletionJob::DoRmDir(const std::string &_path, VFSHost &_vfs) else if( IsNativeLockedItem(rc, _path, _vfs) ) { switch( m_OnLockedItem(rc, _path, _vfs, DeletionType::Permanent) ) { case LockedItemResolution::Unlock: { - if( DoUnlock(_path, _vfs) == false ) + if( !DoUnlock(_path, _vfs) ) return; continue; } @@ -255,14 +255,14 @@ void DeletionJob::DoRmDir(const std::string &_path, VFSHost &_vfs) void DeletionJob::DoTrash(const std::string &_path, VFSHost &_vfs, SourceItem _src) { while( true ) { - const auto rc = _vfs.Trash(_path.c_str()); + const auto rc = _vfs.Trash(_path); if( rc == VFSError::Ok ) { Statistics().CommitProcessed(Statistics::SourceType::Items, 1); } else if( IsNativeLockedItem(rc, _path, _vfs) ) { switch( m_OnLockedItem(rc, _path, _vfs, DeletionType::Trash) ) { case LockedItemResolution::Unlock: { - if( DoUnlock(_path, _vfs) == false ) + if( !DoUnlock(_path, _vfs) ) return; continue; } @@ -310,11 +310,11 @@ bool DeletionJob::IsNativeLockedItem(int vfs_err, const std::string &_path, VFSH if( vfs_err != VFSError::FromErrno(EPERM) ) return false; - if( _vfs.IsNativeFS() == false ) + if( !_vfs.IsNativeFS() ) return false; VFSStat st; - const int stat_rc = _vfs.Stat(_path.c_str(), st, nc::vfs::Flags::F_NoFollow); + const int stat_rc = _vfs.Stat(_path, st, nc::vfs::Flags::F_NoFollow); if( stat_rc != VFSError::Ok ) return false; @@ -326,12 +326,12 @@ int DeletionJob::UnlockItem(const std::string &_path, VFSHost &_vfs) // this is kind of stupid to call stat() essentially twice :-| VFSStat st; - const int stat_rc = _vfs.Stat(_path.c_str(), st, nc::vfs::Flags::F_NoFollow); + const int stat_rc = _vfs.Stat(_path, st, nc::vfs::Flags::F_NoFollow); if( stat_rc != VFSError::Ok ) return stat_rc; st.flags = (st.flags & ~UF_IMMUTABLE); - const int chflags_rc = _vfs.SetFlags(_path.c_str(), st.flags, vfs::Flags::F_NoFollow); + const int chflags_rc = _vfs.SetFlags(_path, st.flags, vfs::Flags::F_NoFollow); return chflags_rc; } diff --git a/Source/Operations/source/DirectoryCreation/DirectoryCreationJob.cpp b/Source/Operations/source/DirectoryCreation/DirectoryCreationJob.cpp index 910a950e7..7bf3b5c9f 100644 --- a/Source/Operations/source/DirectoryCreation/DirectoryCreationJob.cpp +++ b/Source/Operations/source/DirectoryCreation/DirectoryCreationJob.cpp @@ -36,7 +36,7 @@ bool DirectoryCreationJob::MakeDir(const std::string &_path) { while( true ) { VFSStat st; - const auto stat_rc = m_VFS->Stat(_path.c_str(), st, 0); + const auto stat_rc = m_VFS->Stat(_path, st, 0); if( stat_rc != VFSError::Ok ) break; if( st.mode_bits.dir ) { @@ -54,7 +54,7 @@ bool DirectoryCreationJob::MakeDir(const std::string &_path) } while( true ) { - const auto mkdir_rc = m_VFS->CreateDirectory(_path.c_str(), g_CreateMode); + const auto mkdir_rc = m_VFS->CreateDirectory(_path, g_CreateMode); if( mkdir_rc == VFSError::Ok ) return true; switch( m_OnError(mkdir_rc, _path, *m_VFS) ) { diff --git a/Source/Operations/source/FilenameTextControl.mm b/Source/Operations/source/FilenameTextControl.mm index 0cf3ec560..b49e8c66f 100644 --- a/Source/Operations/source/FilenameTextControl.mm +++ b/Source/Operations/source/FilenameTextControl.mm @@ -73,7 +73,7 @@ @implementation NCFilenameTextCell { - (NSTextView *)fieldEditorForView:(NSView *)aControlView { if( !m_FieldEditor ) { - if( m_IsBuilding == true ) + if( m_IsBuilding ) return nil; m_IsBuilding = true; @@ -270,7 +270,7 @@ - (void)updateTextView:(NSTextView *)_text_view withAutocompetion:(const std::st return m_LastListing; VFSListingPtr listing; - const int rc = m_VFS->FetchDirectoryListing(path.c_str(), listing, VFSFlags::F_NoDotDot); + const int rc = m_VFS->FetchDirectoryListing(path, listing, VFSFlags::F_NoDotDot); if( rc == VFSError::Ok ) { m_LastListing = listing; return m_LastListing; diff --git a/Source/Operations/source/Linkage/LinkageJob.cpp b/Source/Operations/source/Linkage/LinkageJob.cpp index 9cc36ae93..ebcaa50fc 100644 --- a/Source/Operations/source/Linkage/LinkageJob.cpp +++ b/Source/Operations/source/Linkage/LinkageJob.cpp @@ -31,7 +31,7 @@ void LinkageJob::Perform() void LinkageJob::DoSymlinkCreation() { - const auto rc = m_VFS->CreateSymlink(m_LinkPath.c_str(), m_LinkValue.c_str()); + const auto rc = m_VFS->CreateSymlink(m_LinkPath, m_LinkValue); if( rc == VFSError::Ok ) { Statistics().CommitProcessed(Statistics::SourceType::Items, 1); } @@ -44,7 +44,7 @@ void LinkageJob::DoSymlinkCreation() void LinkageJob::DoSymlinkAlteration() { VFSStat st; - const auto stat_rc = m_VFS->Stat(m_LinkPath.c_str(), st, VFSFlags::F_NoFollow); + const auto stat_rc = m_VFS->Stat(m_LinkPath, st, VFSFlags::F_NoFollow); if( stat_rc != VFSError::Ok ) { m_OnAlterSymlinkError(stat_rc, m_LinkPath, *m_VFS); Stop(); @@ -57,14 +57,14 @@ void LinkageJob::DoSymlinkAlteration() return; } - const auto unlink_rc = m_VFS->Unlink(m_LinkPath.c_str()); + const auto unlink_rc = m_VFS->Unlink(m_LinkPath); if( unlink_rc != VFSError::Ok ) { m_OnAlterSymlinkError(unlink_rc, m_LinkPath, *m_VFS); Stop(); return; } - const auto link_rc = m_VFS->CreateSymlink(m_LinkPath.c_str(), m_LinkValue.c_str()); + const auto link_rc = m_VFS->CreateSymlink(m_LinkPath, m_LinkValue); if( link_rc == VFSError::Ok ) { Statistics().CommitProcessed(Statistics::SourceType::Items, 1); } diff --git a/Source/Operations/source/Pool.mm b/Source/Operations/source/Pool.mm index f038610ce..3f79b0f37 100644 --- a/Source/Operations/source/Pool.mm +++ b/Source/Operations/source/Pool.mm @@ -84,7 +84,7 @@ void erase_from(C &_c, const T &_t) const auto guard = std::lock_guard{m_Lock}; for( auto &operation : m_PendingOperations ) { assert(operation != nullptr); - if( m_ShouldBeQueuedCallback(*operation) == false ) { + if( !m_ShouldBeQueuedCallback(*operation) ) { to_start.emplace_back(operation); m_RunningOperations.emplace_back(operation); operation.reset(); diff --git a/Source/Operations/tests/Archive_IT.mm b/Source/Operations/tests/Archive_IT.mm index dbd88006c..d98d190ce 100644 --- a/Source/Operations/tests/Archive_IT.mm +++ b/Source/Operations/tests/Archive_IT.mm @@ -79,7 +79,7 @@ Copying copy_operation( const auto host = std::make_shared(operation.ArchivePath().c_str(), TestEnv().vfs_native); VFSFilePtr file; - REQUIRE(host->CreateFile(("/"s + source_fn).c_str(), file, {}) == 0); + REQUIRE(host->CreateFile("/"s + source_fn, file, {}) == 0); REQUIRE(file != nullptr); REQUIRE(file->Open(nc::vfs::Flags::OF_Read) == 0); CHECK(file->Size() == 0); @@ -128,9 +128,7 @@ static int VFSCompareEntries(const std::filesystem::path &_file1_full_path, _file1_host->IterateDirectoryListing(_file1_full_path.c_str(), [&](const VFSDirEnt &_dirent) { const int ret = VFSCompareEntries( _file1_full_path / _dirent.name, _file1_host, _file2_full_path / _dirent.name, _file2_host, _result); - if( ret != 0 ) - return false; - return true; + return ret == 0; }); } return 0; diff --git a/Source/Operations/tests/Compression_IT.mm b/Source/Operations/tests/Compression_IT.mm index 666c133f5..1466564c8 100644 --- a/Source/Operations/tests/Compression_IT.mm +++ b/Source/Operations/tests/Compression_IT.mm @@ -36,7 +36,7 @@ static int VFSCompareEntries(const std::filesystem::path &_file1_full_path, operation.Wait(); REQUIRE(operation.State() == OperationState::Completed); - REQUIRE(native_host->Exists(operation.ArchivePath().c_str())); + REQUIRE(native_host->Exists(operation.ArchivePath())); std::shared_ptr arc_host; REQUIRE_NOTHROW(arc_host = std::make_shared(operation.ArchivePath().c_str(), native_host)); @@ -57,7 +57,7 @@ static int VFSCompareEntries(const std::filesystem::path &_file1_full_path, REQUIRE(operation.State() == OperationState::Completed); CHECK(operation.Statistics().ElapsedTime() > 1ms); CHECK(operation.Statistics().ElapsedTime() < 5s); - REQUIRE(native_host->Exists(operation.ArchivePath().c_str())); + REQUIRE(native_host->Exists(operation.ArchivePath())); std::shared_ptr arc_host; REQUIRE_NOTHROW(arc_host = std::make_shared(operation.ArchivePath().c_str(), native_host)); @@ -85,7 +85,7 @@ static int VFSCompareEntries(const std::filesystem::path &_file1_full_path, operation.Wait(); REQUIRE(operation.State() == OperationState::Completed); - REQUIRE(native_host->Exists(operation.ArchivePath().c_str())); + REQUIRE(native_host->Exists(operation.ArchivePath())); std::shared_ptr arc_host; REQUIRE_NOTHROW(arc_host = std::make_shared(operation.ArchivePath().c_str(), native_host)); @@ -111,7 +111,7 @@ static int VFSCompareEntries(const std::filesystem::path &_file1_full_path, operation.Wait(); REQUIRE(operation.State() == OperationState::Completed); - REQUIRE(native_host->Exists(operation.ArchivePath().c_str())); + REQUIRE(native_host->Exists(operation.ArchivePath())); std::shared_ptr arc_host; REQUIRE_NOTHROW(arc_host = std::make_shared(operation.ArchivePath().c_str(), native_host)); @@ -133,7 +133,7 @@ static int VFSCompareEntries(const std::filesystem::path &_file1_full_path, operation.Wait(); REQUIRE(operation.State() == OperationState::Completed); - REQUIRE(native_host->Exists(operation.ArchivePath().c_str())); + REQUIRE(native_host->Exists(operation.ArchivePath())); std::shared_ptr arc_host; REQUIRE_NOTHROW(arc_host = std::make_shared(operation.ArchivePath().c_str(), native_host)); @@ -158,7 +158,7 @@ static int VFSCompareEntries(const std::filesystem::path &_file1_full_path, operation.Wait(); REQUIRE(operation.State() == OperationState::Completed); - REQUIRE(native_host->Exists(operation.ArchivePath().c_str())); + REQUIRE(native_host->Exists(operation.ArchivePath())); try { std::make_shared(operation.ArchivePath().c_str(), native_host); @@ -189,7 +189,7 @@ static int VFSCompareEntries(const std::filesystem::path &_file1_full_path, operation.Wait(); REQUIRE(operation.State() == OperationState::Completed); - REQUIRE(native_host->Exists(operation.ArchivePath().c_str())); + REQUIRE(native_host->Exists(operation.ArchivePath())); std::shared_ptr arc_host; REQUIRE_NOTHROW(arc_host = @@ -220,7 +220,7 @@ static int VFSCompareEntries(const std::filesystem::path &_file1_full_path, operation.Resume(); operation.Wait(); REQUIRE(operation.State() == OperationState::Completed); - REQUIRE(native_host->Exists(operation.ArchivePath().c_str())); + REQUIRE(native_host->Exists(operation.ArchivePath())); std::shared_ptr arc_host; REQUIRE_NOTHROW(arc_host = std::make_shared(operation.ArchivePath().c_str(), native_host)); @@ -295,9 +295,7 @@ static int VFSCompareEntries(const std::filesystem::path &_file1_full_path, _file1_host->IterateDirectoryListing(_file1_full_path.c_str(), [&](const VFSDirEnt &_dirent) { const int ret = VFSCompareEntries( _file1_full_path / _dirent.name, _file1_host, _file2_full_path / _dirent.name, _file2_host, _result); - if( ret != 0 ) - return false; - return true; + return ret == 0; }); } return 0; diff --git a/Source/Operations/tests/Copying_IT.mm b/Source/Operations/tests/Copying_IT.mm index ce6041c1a..4adbcba23 100644 --- a/Source/Operations/tests/Copying_IT.mm +++ b/Source/Operations/tests/Copying_IT.mm @@ -862,7 +862,7 @@ Copying op(FetchItems("/System/Applications/Mail.app/Contents", {begin(files), e host, compare) == 0); REQUIRE(compare == 0); - REQUIRE(host->Unlink(("/Public/!FilesTesting/" + i).c_str(), nullptr) == 0); + REQUIRE(host->Unlink("/Public/!FilesTesting/" + i, nullptr) == 0); } VFSEasyDelete("/Public", host); @@ -1477,7 +1477,7 @@ Copying op(FetchItems("/System/Library/Kernels/", {"kernel"}, *TestEnv().vfs_nat std::thread t([&] { const int f = open(p.c_str(), O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR); REQUIRE(f >= 0); - for( size_t i = 0; stop == false && i < max_size; ++i ) { + for( size_t i = 0; !stop && i < max_size; ++i ) { write(f, &f, 1); if( i == 0 ) { @@ -1559,9 +1559,7 @@ static int VFSCompareEntries(const std::filesystem::path &_file1_full_path, _file1_host->IterateDirectoryListing(_file1_full_path.c_str(), [&](const VFSDirEnt &_dirent) { const int ret = VFSCompareEntries( _file1_full_path / _dirent.name, _file1_host, _file2_full_path / _dirent.name, _file2_host, _result); - if( ret != 0 ) - return false; - return true; + return ret == 0; }); } return 0; diff --git a/Source/Operations/tests/Linkage_IT.mm b/Source/Operations/tests/Linkage_IT.mm index 4dc99a39e..26c5be395 100644 --- a/Source/Operations/tests/Linkage_IT.mm +++ b/Source/Operations/tests/Linkage_IT.mm @@ -22,12 +22,12 @@ REQUIRE(operation.State() == OperationState::Completed); VFSStat st; - const auto st_rc = host->Stat(path.c_str(), st, VFSFlags::F_NoFollow); + const auto st_rc = host->Stat(path, st, VFSFlags::F_NoFollow); REQUIRE(st_rc == VFSError::Ok); REQUIRE((st.mode & S_IFMT) == S_IFLNK); char buf[MAXPATHLEN]; - REQUIRE(host->ReadSymlink(path.c_str(), buf, sizeof(buf)) == VFSError::Ok); + REQUIRE(host->ReadSymlink(path, buf, sizeof(buf)) == VFSError::Ok); REQUIRE(buf == value); } @@ -57,12 +57,12 @@ REQUIRE(operation.State() == OperationState::Completed); VFSStat st; - const auto st_rc = host->Stat(path.c_str(), st, VFSFlags::F_NoFollow); + const auto st_rc = host->Stat(path, st, VFSFlags::F_NoFollow); REQUIRE(st_rc == VFSError::Ok); REQUIRE((st.mode & S_IFMT) == S_IFLNK); char buf[MAXPATHLEN]; - REQUIRE(host->ReadSymlink(path.c_str(), buf, sizeof(buf)) == VFSError::Ok); + REQUIRE(host->ReadSymlink(path, buf, sizeof(buf)) == VFSError::Ok); REQUIRE(buf == value); } @@ -81,7 +81,7 @@ VFSStat st1; VFSStat st2; - REQUIRE(host->Stat(path.c_str(), st1, 0) == VFSError::Ok); - REQUIRE(host->Stat(value.c_str(), st2, 0) == VFSError::Ok); + REQUIRE(host->Stat(path, st1, 0) == VFSError::Ok); + REQUIRE(host->Stat(value, st2, 0) == VFSError::Ok); REQUIRE(st1.inode == st2.inode); } diff --git a/Source/Operations/tests/Pool_UT.mm b/Source/Operations/tests/Pool_UT.mm index 14afc8691..7294557c1 100644 --- a/Source/Operations/tests/Pool_UT.mm +++ b/Source/Operations/tests/Pool_UT.mm @@ -45,7 +45,7 @@ static bool check_until_or_die(std::function _predicate, std::chrono::na struct MyJob : public Job { void Perform() override { - while( done == false ) + while( !done ) std::this_thread::sleep_for(std::chrono::microseconds{100}); SetCompleted(); } @@ -89,7 +89,7 @@ void Perform() override struct MyJob : public Job { void Perform() override { - while( done == false ) + while( !done ) std::this_thread::sleep_for(std::chrono::microseconds{100}); SetCompleted(); } @@ -161,7 +161,7 @@ void Perform() override struct MyJob : public Job { void Perform() override { - while( done == false ) + while( !done ) std::this_thread::sleep_for(std::chrono::microseconds{100}); SetCompleted(); } @@ -209,7 +209,7 @@ void Perform() override struct MyJob : public Job { void Perform() override { - while( done == false ) + while( !done ) std::this_thread::sleep_for(std::chrono::microseconds{100}); SetCompleted(); } diff --git a/Source/Panel/include/Panel/ExternalTools.h b/Source/Panel/include/Panel/ExternalTools.h index 57e14d850..dc67ae78d 100644 --- a/Source/Panel/include/Panel/ExternalTools.h +++ b/Source/Panel/include/Panel/ExternalTools.h @@ -190,7 +190,7 @@ class ExternalToolExecution // (StartDetachedFork) std::expected StartDetached(); - std::expected StartDetachedFork(); + std::expected StartDetachedFork() const; std::expected StartDetachedUI(); diff --git a/Source/Panel/source/ExternalTools.mm b/Source/Panel/source/ExternalTools.mm index 606c10a4a..42514bff5 100644 --- a/Source/Panel/source/ExternalTools.mm +++ b/Source/Panel/source/ExternalTools.mm @@ -164,7 +164,7 @@ source.remove_prefix(1); } - if( user_defined != std::nullopt && (c == '%' || c == ' ') && escaped == false ) { + if( user_defined != std::nullopt && (c == '%' || c == ' ') && !escaped ) { // flush existing arg and continue parsing result.emplace_back(ExternalToolsParameters::UserDefined{std::move(*user_defined)}, true); user_defined.reset(); @@ -196,7 +196,7 @@ if( placeholder ) { if( c >= '0' && c <= '9' ) { - number = number.value_or(0) * 10 + c - '0'; + number = (number.value_or(0) * 10) + c - '0'; continue; } @@ -798,7 +798,7 @@ static bool IsRunnableExecutable(const std::string &_path) return StartDetachedFork(); } -std::expected ExternalToolExecution::StartDetachedFork() +std::expected ExternalToolExecution::StartDetachedFork() const { auto args = BuildArguments(); diff --git a/Source/Panel/source/NetworkConnectionsManager.mm b/Source/Panel/source/NetworkConnectionsManager.mm index 847b85bba..383b46ff2 100644 --- a/Source/Panel/source/NetworkConnectionsManager.mm +++ b/Source/Panel/source/NetworkConnectionsManager.mm @@ -97,23 +97,23 @@ void Visit(const NetworkConnectionsManager::WebDAV &webdav) override NetworkConnectionsManager::ConnectionVisitor::~ConnectionVisitor() = default; -void NetworkConnectionsManager::ConnectionVisitor::Visit(const NetworkConnectionsManager::FTP &) +void NetworkConnectionsManager::ConnectionVisitor::Visit(const NetworkConnectionsManager::FTP & /*unused*/) { } -void NetworkConnectionsManager::ConnectionVisitor::Visit(const NetworkConnectionsManager::SFTP &) +void NetworkConnectionsManager::ConnectionVisitor::Visit(const NetworkConnectionsManager::SFTP & /*unused*/) { } -void NetworkConnectionsManager::ConnectionVisitor::Visit(const NetworkConnectionsManager::LANShare &) +void NetworkConnectionsManager::ConnectionVisitor::Visit(const NetworkConnectionsManager::LANShare & /*unused*/) { } -void NetworkConnectionsManager::ConnectionVisitor::Visit(const NetworkConnectionsManager::Dropbox &) +void NetworkConnectionsManager::ConnectionVisitor::Visit(const NetworkConnectionsManager::Dropbox & /*unused*/) { } -void NetworkConnectionsManager::ConnectionVisitor::Visit(const NetworkConnectionsManager::WebDAV &) +void NetworkConnectionsManager::ConnectionVisitor::Visit(const NetworkConnectionsManager::WebDAV & /*unused*/) { } diff --git a/Source/Panel/source/PanelDataFilter.mm b/Source/Panel/source/PanelDataFilter.mm index 973adeab6..302d23754 100644 --- a/Source/Panel/source/PanelDataFilter.mm +++ b/Source/Panel/source/PanelDataFilter.mm @@ -71,9 +71,8 @@ static bool FuzzySearchSatisfiable(CFStringRef _hay, CFRange result = {0, 0}; const bool found = CFStringFindWithOptions( _hay, cs.get(), CFRangeMake(pos, _hay_len - pos), kCFCompareCaseInsensitive, &result); - if( found == false ) - return false; // cannot be satisfied - filename doesn't contain a sparse - // sequence of chars from text + if( !found ) + return false; // cannot be satisfied - filename doesn't contain a sparse sequence of chars from text pos = result.location + 1; } return true; @@ -248,7 +247,7 @@ static bool FuzzySearchSatisfiable(CFStringRef _hay, bool HardFilter::IsValidItem(const VFSListingItem &_item, QuickSearchHiglight &_found_range) const { - if( show_hidden == false && _item.IsHidden() ) + if( !show_hidden && _item.IsHidden() ) return false; return text.IsValidItem(_item, _found_range); diff --git a/Source/Panel/source/UI/TagsPresentation.mm b/Source/Panel/source/UI/TagsPresentation.mm index 026e9a0da..d8b7b11f6 100644 --- a/Source/Panel/source/UI/TagsPresentation.mm +++ b/Source/Panel/source/UI/TagsPresentation.mm @@ -46,7 +46,7 @@ auto count = std::ranges::count_if(_tags, [](auto &_tag) { return _tag.Color() != utility::Tags::Color::None; }); if( count == 0 ) return {}; - return {.width = Diameter + (std::min(static_cast(count), MaxDrawn) - 1) * Step, .margin = Margin}; + return {.width = Diameter + ((std::min(static_cast(count), MaxDrawn) - 1) * Step), .margin = Margin}; } void TrailingTagsInplaceDisplay::Draw(const double _offset_x, @@ -90,7 +90,7 @@ [currentContext saveGraphicsState]; NSAffineTransform *const tr = [NSAffineTransform transform]; - [tr translateXBy:_offset_x + static_cast(i) * spacing yBy:_view_height / 2.]; + [tr translateXBy:_offset_x + (static_cast(i) * spacing) yBy:_view_height / 2.]; [tr concat]; if( i < static_cast(num_colors_to_draw) - 1 ) { diff --git a/Source/Panel/tests/ExternalTools_IT.mm b/Source/Panel/tests/ExternalTools_IT.mm index 9276c967b..5b3b942c7 100644 --- a/Source/Panel/tests/ExternalTools_IT.mm +++ b/Source/Panel/tests/ExternalTools_IT.mm @@ -129,7 +129,7 @@ static bool WaitForChildProcess(int _pid, std::chrono::nanoseconds _deadline, st et.m_ExecutablePath = "/i/do/no/exist/hi"; { - ExternalToolExecution ex{ctx, et}; + const ExternalToolExecution ex{ctx, et}; auto pid = ex.StartDetachedFork(); CHECK(pid.has_value() == false); CHECK(pid.error().empty() == false); diff --git a/Source/Panel/tests/PanelData_UT.mm b/Source/Panel/tests/PanelData_UT.mm index 62d6e6a77..928b95b24 100644 --- a/Source/Panel/tests/PanelData_UT.mm +++ b/Source/Panel/tests/PanelData_UT.mm @@ -236,17 +236,17 @@ static VFSListingPtr ProduceDummyListing(const std::vectorCount(); ++i ) - CHECK(data.RawIndexForName(listing->Filename(i).c_str()) == static_cast(i)); + CHECK(data.RawIndexForName(listing->Filename(i)) == static_cast(i)); // testing basic sorting (direct by filename) auto sorting = data.SortMode(); sorting.sort = data::SortMode::SortByName; data.SetSortMode(sorting); - CHECK(data.SortedIndexForName(listing->Filename(0).c_str()) == 0); - CHECK(data.SortedIndexForName(listing->Filename(2).c_str()) == 1); - CHECK(data.SortedIndexForName(listing->Filename(3).c_str()) == 2); - CHECK(data.SortedIndexForName(listing->Filename(1).c_str()) == 3); + CHECK(data.SortedIndexForName(listing->Filename(0)) == 0); + CHECK(data.SortedIndexForName(listing->Filename(2)) == 1); + CHECK(data.SortedIndexForName(listing->Filename(3)) == 2); + CHECK(data.SortedIndexForName(listing->Filename(1)) == 3); } TEST_CASE(PREFIX "SortingWithCases") diff --git a/Source/RoutedIO/source/PrivilegedIOHelper.cpp b/Source/RoutedIO/source/PrivilegedIOHelper.cpp index 9e119e018..ec8bddaf1 100644 --- a/Source/RoutedIO/source/PrivilegedIOHelper.cpp +++ b/Source/RoutedIO/source/PrivilegedIOHelper.cpp @@ -537,7 +537,7 @@ static void XPC_Peer_Event_Handler(xpc_connection_t _peer, xpc_object_t _event) } if( xpc_dictionary_get_value(_event, "auth") != nullptr ) { - if( xpc_dictionary_get_bool(_event, "auth") == true ) { + if( xpc_dictionary_get_bool(_event, "auth") ) { context->authenticated = true; send_reply_ok(_event); } diff --git a/Source/RoutedIO/source/RoutedIO.cpp b/Source/RoutedIO/source/RoutedIO.cpp index 8ee5fd372..0f6e63e16 100644 --- a/Source/RoutedIO/source/RoutedIO.cpp +++ b/Source/RoutedIO/source/RoutedIO.cpp @@ -210,7 +210,7 @@ bool RoutedIO::SayImAuthenticated(xpc_connection_t _connection) noexcept bool result = false; if( xpc_get_type(reply) != XPC_TYPE_ERROR ) - if( xpc_dictionary_get_bool(reply, "ok") == true ) + if( xpc_dictionary_get_bool(reply, "ok") ) result = true; xpc_release(reply); @@ -320,7 +320,7 @@ bool RoutedIO::Connect() if( m_Connection ) return true; - if( m_AuthenticatedAsAdmin == false ) { + if( !m_AuthenticatedAsAdmin ) { Log::Error("RoutedIO::Connect() was called without being authenticated as admin"); return false; } @@ -381,7 +381,7 @@ bool RoutedIO::IsHelperAlive() bool result = false; if( xpc_get_type(reply) != XPC_TYPE_ERROR ) - if( xpc_dictionary_get_bool(reply, "ok") == true ) + if( xpc_dictionary_get_bool(reply, "ok") ) result = true; xpc_release(reply); diff --git a/Source/RoutedIO/source/RoutedIOInterfaces.cpp b/Source/RoutedIO/source/RoutedIOInterfaces.cpp index 61f8ccbba..bb2e741b8 100644 --- a/Source/RoutedIO/source/RoutedIOInterfaces.cpp +++ b/Source/RoutedIO/source/RoutedIOInterfaces.cpp @@ -357,7 +357,7 @@ int PosixIOInterfaceRouted::mkdir(const char *_path, mode_t _mode) noexcept return -1; } - if( xpc_dictionary_get_bool(reply, "ok") != true ) { + if( !xpc_dictionary_get_bool(reply, "ok") ) { xpc_release(reply); errno = EIO; return -1; @@ -398,7 +398,7 @@ int PosixIOInterfaceRouted::chown(const char *_path, uid_t _uid, gid_t _gid) noe return -1; } - if( xpc_dictionary_get_bool(reply, "ok") != true ) { + if( !xpc_dictionary_get_bool(reply, "ok") ) { xpc_release(reply); errno = EIO; return -1; @@ -434,7 +434,7 @@ int PosixIOInterfaceRouted::chflags(const char *_path, u_int _flags) noexcept return -1; } - if( xpc_dictionary_get_bool(reply, "ok") != true ) { + if( !xpc_dictionary_get_bool(reply, "ok") ) { xpc_release(reply); errno = EIO; return -1; @@ -470,7 +470,7 @@ int PosixIOInterfaceRouted::lchflags(const char *_path, u_int _flags) noexcept return -1; } - if( xpc_dictionary_get_bool(reply, "ok") != true ) { + if( !xpc_dictionary_get_bool(reply, "ok") ) { xpc_release(reply); errno = EIO; return -1; @@ -505,7 +505,7 @@ int PosixIOInterfaceRouted::rmdir(const char *_path) noexcept return -1; } - if( xpc_dictionary_get_bool(reply, "ok") != true ) { + if( !xpc_dictionary_get_bool(reply, "ok") ) { xpc_release(reply); errno = EIO; return -1; @@ -540,7 +540,7 @@ int PosixIOInterfaceRouted::unlink(const char *_path) noexcept return -1; } - if( xpc_dictionary_get_bool(reply, "ok") != true ) { + if( !xpc_dictionary_get_bool(reply, "ok") ) { xpc_release(reply); errno = EIO; return -1; @@ -576,7 +576,7 @@ int PosixIOInterfaceRouted::rename(const char *_old, const char *_new) noexcept return -1; } - if( xpc_dictionary_get_bool(reply, "ok") != true ) { + if( !xpc_dictionary_get_bool(reply, "ok") ) { xpc_release(reply); errno = EIO; return -1; @@ -652,7 +652,7 @@ int PosixIOInterfaceRouted::symlink(const char *_value, const char *_symlink_pat return -1; } - if( xpc_dictionary_get_bool(reply, "ok") != true ) { + if( !xpc_dictionary_get_bool(reply, "ok") ) { xpc_release(reply); errno = EIO; return -1; @@ -688,7 +688,7 @@ int PosixIOInterfaceRouted::link(const char *_path_exist, const char *_path_newn return -1; } - if( xpc_dictionary_get_bool(reply, "ok") != true ) { + if( !xpc_dictionary_get_bool(reply, "ok") ) { xpc_release(reply); errno = EIO; return -1; @@ -724,7 +724,7 @@ int PosixIOInterfaceRouted::chmod(const char *_path, mode_t _mode) noexcept return -1; } - if( xpc_dictionary_get_bool(reply, "ok") != true ) { + if( !xpc_dictionary_get_bool(reply, "ok") ) { xpc_release(reply); errno = EIO; return -1; @@ -760,7 +760,7 @@ int PosixIOInterfaceRouted::chmtime(const char *_path, time_t _time) noexcept return -1; } - if( xpc_dictionary_get_bool(reply, "ok") != true ) { + if( !xpc_dictionary_get_bool(reply, "ok") ) { xpc_release(reply); errno = EIO; return -1; @@ -796,7 +796,7 @@ int PosixIOInterfaceRouted::chatime(const char *_path, time_t _time) noexcept return -1; } - if( xpc_dictionary_get_bool(reply, "ok") != true ) { + if( !xpc_dictionary_get_bool(reply, "ok") ) { xpc_release(reply); errno = EIO; return -1; @@ -832,7 +832,7 @@ int PosixIOInterfaceRouted::chbtime(const char *_path, time_t _time) noexcept return -1; } - if( xpc_dictionary_get_bool(reply, "ok") != true ) { + if( !xpc_dictionary_get_bool(reply, "ok") ) { xpc_release(reply); errno = EIO; return -1; @@ -868,7 +868,7 @@ int PosixIOInterfaceRouted::chctime(const char *_path, time_t _time) noexcept return -1; } - if( xpc_dictionary_get_bool(reply, "ok") != true ) { + if( !xpc_dictionary_get_bool(reply, "ok") ) { xpc_release(reply); errno = EIO; return -1; @@ -905,7 +905,7 @@ int PosixIOInterfaceRouted::killpg(int _pid, int _signal) noexcept return -1; } - if( xpc_dictionary_get_bool(reply, "ok") != true ) { + if( !xpc_dictionary_get_bool(reply, "ok") ) { xpc_release(reply); errno = EIO; return -1; @@ -940,7 +940,7 @@ int PosixIOInterfaceRouted::trash(const char *_path) noexcept return -1; } - if( xpc_dictionary_get_bool(reply, "ok") != true ) { + if( !xpc_dictionary_get_bool(reply, "ok") ) { xpc_release(reply); errno = EIO; return -1; diff --git a/Source/Term/source/CTCache.cpp b/Source/Term/source/CTCache.cpp index 5ab1aa300..9971e6dfd 100644 --- a/Source/Term/source/CTCache.cpp +++ b/Source/Term/source/CTCache.cpp @@ -127,7 +127,7 @@ CTCache::DisplayChar CTCache::Internalize(CTLineRef _line) return {.kind = Kind::Complex, .index = static_cast(m_Complexes.size() - 1)}; }; - CFArrayRef runs = static_cast(CTLineGetGlyphRuns(_line)); + CFArrayRef runs = CTLineGetGlyphRuns(_line); if( runs == nullptr ) return {.kind = Kind::Empty, .index = 0}; diff --git a/Source/Term/source/ExtendedCharRegistry.mm b/Source/Term/source/ExtendedCharRegistry.mm index b13b8d609..9d440c972 100644 --- a/Source/Term/source/ExtendedCharRegistry.mm +++ b/Source/Term/source/ExtendedCharRegistry.mm @@ -46,9 +46,9 @@ // Fast path bypassing the heavy machinery of Core Foundation if( _input.length() > 1 ) { const bool second_potentially_composable = IsPotentiallyComposableCharacter(_input[1]); - if( second_potentially_composable == false ) { + if( !second_potentially_composable ) { const bool first_potentially_composable = IsPotentiallyComposableCharacter(_input[0]); - if( first_potentially_composable == false ) { + if( !first_potentially_composable ) { // 99.99% of cases should fall into this branch. return _initial == 0 ? AppendResult{.newchar = _input[0], .eaten = 1} : AppendResult{.newchar = _initial, .eaten = 0}; @@ -57,7 +57,7 @@ } else if( _input.length() == 1 ) { const bool first_potentially_composable = IsPotentiallyComposableCharacter(_input[0]); - if( first_potentially_composable == false ) { + if( !first_potentially_composable ) { return _initial == 0 ? AppendResult{.newchar = _input[0], .eaten = 1} : AppendResult{.newchar = _initial, .eaten = 0}; } @@ -232,7 +232,7 @@ is_double_width = utility::CharInfo::WCWidthMin1(static_cast(chars[0])) == 2; } - if( is_double_width == false ) { + if( !is_double_width ) { // also check for presense of variation selectors for( const char16_t c : str ) { if( c == g_VariationSelectorEmoji ) { diff --git a/Source/Term/source/InterpreterImpl.cpp b/Source/Term/source/InterpreterImpl.cpp index 4d4317622..5a3697df7 100644 --- a/Source/Term/source/InterpreterImpl.cpp +++ b/Source/Term/source/InterpreterImpl.cpp @@ -185,7 +185,7 @@ void InterpreterImpl::ProcessText(const input::UTF8Text &_text) continue; } - if( m_AutoWrapMode == true && m_Screen.LineOverflown() && + if( m_AutoWrapMode && m_Screen.LineOverflown() && (m_Screen.CursorX() >= sx - 1 || (m_Screen.CursorX() == sx - 2 && curr_line_ends_with_mcg())) ) { m_Screen.PutWrap(); ProcessCR(); @@ -457,41 +457,41 @@ void InterpreterImpl::ProcessChangeMode(const input::ModeChange _mode_change) } break; case Kind::SendMouseXYOnPress: - if( _mode_change.status == true && m_RequestedMouseEvents != RequestedMouseEvents::X10 ) { + if( _mode_change.status && m_RequestedMouseEvents != RequestedMouseEvents::X10 ) { m_RequestedMouseEvents = RequestedMouseEvents::X10; RequestMouseEventsChanged(); } - if( _mode_change.status == false && m_RequestedMouseEvents == RequestedMouseEvents::X10 ) { + if( !_mode_change.status && m_RequestedMouseEvents == RequestedMouseEvents::X10 ) { m_RequestedMouseEvents = RequestedMouseEvents::None; RequestMouseEventsChanged(); } break; case Kind::SendMouseXYOnPressAndRelease: - if( _mode_change.status == true && m_RequestedMouseEvents != RequestedMouseEvents::Normal ) { + if( _mode_change.status && m_RequestedMouseEvents != RequestedMouseEvents::Normal ) { m_RequestedMouseEvents = RequestedMouseEvents::Normal; RequestMouseEventsChanged(); } - if( _mode_change.status == false && m_RequestedMouseEvents == RequestedMouseEvents::Normal ) { + if( !_mode_change.status && m_RequestedMouseEvents == RequestedMouseEvents::Normal ) { m_RequestedMouseEvents = RequestedMouseEvents::None; RequestMouseEventsChanged(); } break; case Kind::SendMouseXYOnPressDragAndRelease: - if( _mode_change.status == true && m_RequestedMouseEvents != RequestedMouseEvents::ButtonTracking ) { + if( _mode_change.status && m_RequestedMouseEvents != RequestedMouseEvents::ButtonTracking ) { m_RequestedMouseEvents = RequestedMouseEvents::ButtonTracking; RequestMouseEventsChanged(); } - if( _mode_change.status == false && m_RequestedMouseEvents == RequestedMouseEvents::ButtonTracking ) { + if( !_mode_change.status && m_RequestedMouseEvents == RequestedMouseEvents::ButtonTracking ) { m_RequestedMouseEvents = RequestedMouseEvents::None; RequestMouseEventsChanged(); } break; case Kind::SendMouseXYAnyEvent: - if( _mode_change.status == true && m_RequestedMouseEvents != RequestedMouseEvents::Any ) { + if( _mode_change.status && m_RequestedMouseEvents != RequestedMouseEvents::Any ) { m_RequestedMouseEvents = RequestedMouseEvents::Any; RequestMouseEventsChanged(); } - if( _mode_change.status == false && m_RequestedMouseEvents == RequestedMouseEvents::Any ) { + if( !_mode_change.status && m_RequestedMouseEvents == RequestedMouseEvents::Any ) { m_RequestedMouseEvents = RequestedMouseEvents::None; RequestMouseEventsChanged(); } @@ -503,7 +503,7 @@ void InterpreterImpl::ProcessChangeMode(const input::ModeChange _mode_change) void InterpreterImpl::ProcessChangeColumnMode132(bool _on) { - if( m_AllowScreenResize == false ) + if( !m_AllowScreenResize ) return; const auto height = m_Screen.Height(); diff --git a/Source/Term/source/ParserImpl.cpp b/Source/Term/source/ParserImpl.cpp index f7722d682..2ef9b4c87 100644 --- a/Source/Term/source/ParserImpl.cpp +++ b/Source/Term/source/ParserImpl.cpp @@ -254,7 +254,7 @@ bool ParserImpl::SSEscConsume(unsigned char _byte) noexcept return true; case '8': - if( m_EscState.hash == true ) + if( m_EscState.hash ) /* DECALN – Screen Alignment Display (DEC Private) ESC # 8 This command fills the entire screen area with uppercase Es for screen focus and diff --git a/Source/Term/source/Screen.cpp b/Source/Term/source/Screen.cpp index 6a7da37ba..dbf526179 100644 --- a/Source/Term/source/Screen.cpp +++ b/Source/Term/source/Screen.cpp @@ -97,12 +97,10 @@ void Screen::GoTo(int _x, int _y) m_PosX = _x; m_PosY = _y; - if( m_PosX < 0 ) - m_PosX = 0; + m_PosX = std::max(m_PosX, 0); if( m_PosX >= Width() ) m_PosX = Width() - 1; - if( m_PosY < 0 ) - m_PosY = 0; + m_PosY = std::max(m_PosY, 0); if( m_PosY >= Height() ) m_PosY = Height() - 1; m_LineOverflown = false; diff --git a/Source/Term/source/ScreenBuffer.cpp b/Source/Term/source/ScreenBuffer.cpp index b876ae57e..c31e65f42 100644 --- a/Source/Term/source/ScreenBuffer.cpp +++ b/Source/Term/source/ScreenBuffer.cpp @@ -517,9 +517,9 @@ void ScreenBuffer::RevertToSnapshot(const Snapshot &_snapshot) else { // TODO: anchor? std::fill_n(m_OnScreenSpaces.get(), m_Width * m_Height, m_EraseChar); for( int y = 0, e = std::min(_snapshot.height, m_Height); y != e; ++y ) { - std::copy_n(_snapshot.chars.get() + y * _snapshot.width, + std::copy_n(_snapshot.chars.get() + (y * _snapshot.width), std::min(_snapshot.width, m_Width), - m_OnScreenSpaces.get() + y * m_Width); + m_OnScreenSpaces.get() + (y * m_Width)); } } } diff --git a/Source/Term/source/ScrollView.mm b/Source/Term/source/ScrollView.mm index 11d2b5704..79e472b25 100644 --- a/Source/Term/source/ScrollView.mm +++ b/Source/Term/source/ScrollView.mm @@ -188,7 +188,7 @@ - (void)tile rc.size.height -= g_Insets.top + g_Insets.bottom; rc.size.width -= g_Insets.left + g_Insets.right; - const auto rest = rc.size.height - std::floor(rc.size.height / m_View.charHeight) * m_View.charHeight; + const auto rest = rc.size.height - (std::floor(rc.size.height / m_View.charHeight) * m_View.charHeight); rc.size.height -= rest; self.contentView.frame = rc; diff --git a/Source/Term/source/ShellTask.cpp b/Source/Term/source/ShellTask.cpp index 54e709b45..c534370ed 100644 --- a/Source/Term/source/ShellTask.cpp +++ b/Source/Term/source/ShellTask.cpp @@ -218,8 +218,8 @@ struct ShellTask::Impl { std::string tcsh_semaphore_path; bool temporary_suppressed = false; // will give no output until a next bash prompt will show the requested_cwd path - std::string requested_cwd = ""; - std::string cwd = ""; + std::string requested_cwd; + std::string cwd; // accessible from main thread only (presumably) int term_sx = 80; @@ -239,7 +239,7 @@ struct ShellTask::Impl { std::shared_ptr on_child_output; void OnMasterSourceData(); - void OnMasterSourceCancellation(); + void OnMasterSourceCancellation() const; void OnCwdSourceData(); void OnCwdSourceCancellation(); void OnShellDied(); @@ -567,7 +567,7 @@ void ShellTask::Impl::OnCwdSourceData() } } -void ShellTask::Impl::OnMasterSourceCancellation() +void ShellTask::Impl::OnMasterSourceCancellation() const { dispatch_assert_background_queue(); // must be called on io_queue Log::Trace("ShellTask::Impl::OnMasterSourceCancellation() called"); @@ -599,7 +599,7 @@ void ShellTask::Impl::ProcessPwdPrompt(const void *_d, int _sz) bool current_wd_changed = false; std::string new_cwd(static_cast(_d), _sz); - while( new_cwd.empty() == false && (new_cwd.back() == '\n' || new_cwd.back() == '\r') ) + while( !new_cwd.empty() && (new_cwd.back() == '\n' || new_cwd.back() == '\r') ) new_cwd.pop_back(); new_cwd = EnsureTrailingSlash(new_cwd); Log::Info("pwd prompt from shell_pid={}: {}", shell_pid.load(), new_cwd); @@ -888,7 +888,7 @@ void ShellTask::ExecuteWithFullPath(const std::filesystem::path &_binary_path, s cmd += "\n"; I->SetState(TaskState::ProgramExternal); - WriteChildInput(cmd.c_str()); + WriteChildInput(cmd); } std::vector ShellTask::ChildrenList() const diff --git a/Source/Term/source/View.mm b/Source/Term/source/View.mm index 28200db68..cf40b783d 100644 --- a/Source/Term/source/View.mm +++ b/Source/Term/source/View.mm @@ -223,7 +223,7 @@ - (int)fullScreenLinesHeight - (void)adjustSizes:(bool)_mandatory { const int full_lines_height = self.fullScreenLinesHeight; - if( full_lines_height == m_LastScreenFullHeight && _mandatory == false ) + if( full_lines_height == m_LastScreenFullHeight && !_mandatory ) return; m_LastScreenFullHeight = full_lines_height; @@ -323,7 +323,8 @@ void flush() { if( clr ) { CGContextSetFillColorWithColor(ctx, clr); - auto rc = CGRectMake(origin_x + start * cell_width, origin_y, (end - start + 1) * cell_width, cell_height); + auto rc = + CGRectMake(origin_x + (start * cell_width), origin_y, (end - start + 1) * cell_width, cell_height); CGContextFillRect(ctx, rc); clr = nullptr; } @@ -379,7 +380,7 @@ - (void)DrawLine:(std::span)_line else if( _sel_y < m_SelEnd.y && _sel_y > m_SelStart.y ) rc = CGRectMake(0, _y * height, self.frame.size.width, height); else if( _sel_y == m_SelStart.y ) - rc = CGRectMake(m_SelStart.x * width, _y * height, self.frame.size.width - m_SelStart.x * width, height); + rc = CGRectMake(m_SelStart.x * width, _y * height, self.frame.size.width - (m_SelStart.x * width), height); else if( _sel_y == m_SelEnd.y ) rc = CGRectMake(0, _y * height, m_SelEnd.x * width, height); @@ -401,7 +402,7 @@ - (void)DrawLine:(std::span)_line const ScreenBuffer::Space attr = _line[_first]; if( attr.invisible ) return; - if( attr.blink && blink_visible == false ) + if( attr.blink && !blink_visible ) return; // gather all char codes and their coordinates from the run @@ -415,7 +416,7 @@ - (void)DrawLine:(std::span)_line if( !draw_glyph ) continue; const double rx = x * width; - const double ry = _y * height + height - descent; + const double ry = (_y * height) + height - descent; codes.push_back(cs.l); positions.push_back({rx, ry}); } @@ -490,7 +491,7 @@ - (void)DrawLine:(std::span)_line - (void)drawCursor:(NSRect)_char_rect context:(CGContextRef)_context { - if( m_ShowCursor == false ) + if( !m_ShowCursor ) return; const bool is_wnd_active = self.window.isKeyWindow; @@ -534,7 +535,7 @@ - (void)drawCursor:(NSRect)_char_rect context:(CGContextRef)_context - (NSRect)adjustScroll:(NSRect)proposedVisibleRect { const auto font_height = m_FontCache->Height(); - proposedVisibleRect.origin.y = floor(proposedVisibleRect.origin.y / font_height + 0.5) * font_height; + proposedVisibleRect.origin.y = floor((proposedVisibleRect.origin.y / font_height) + 0.5) * font_height; return proposedVisibleRect; } @@ -549,15 +550,13 @@ - (NSRect)adjustScroll:(NSRect)proposedVisibleRect - (SelPoint)projectPoint:(NSPoint)_point { auto y_pos = _point.y; - if( y_pos < 0 ) - y_pos = 0; + y_pos = std::max(y_pos, 0); const int line_predict = static_cast(std::floor(y_pos / m_FontCache->Height()) - m_Screen->Buffer().BackScreenLines()); auto x_pos = _point.x; - if( x_pos < 0 ) - x_pos = 0; + x_pos = std::max(x_pos, 0); const int col_predict = static_cast(std::floor(x_pos / m_FontCache->Width())); return SelPoint{col_predict, line_predict}; } @@ -719,7 +718,7 @@ - (void)handleSelectionWithMouseDragging:(NSEvent *)event { // TODO: not a precise selection modification. look at viewer, it has better implementation. - bool modifying_existing_selection = ([event modifierFlags] & NSEventModifierFlagShift) ? true : false; + bool modifying_existing_selection = ([event modifierFlags] & NSEventModifierFlagShift) != 0; NSPoint first_loc = [self convertPoint:[event locationInWindow] fromView:nil]; while( [event type] != NSEventTypeLeftMouseUp ) { @@ -1145,7 +1144,7 @@ - (void)passMouseEvent:(NSEvent *)_event if( !has(types, type) ) return; - if( location_cell_changed == false && has(movement_types, type) ) + if( !location_cell_changed && has(movement_types, type) ) return; InputTranslator::MouseEvent evt; @@ -1174,7 +1173,7 @@ - (void)passMouseEvent:(NSEvent *)_event if( !has(types, type) ) return; - if( location_cell_changed == false && has(movement_types, type) ) + if( !location_cell_changed && has(movement_types, type) ) return; InputTranslator::MouseEvent evt; diff --git a/Source/Term/tests/Term_IT.cpp b/Source/Term/tests/Term_IT.cpp index 8e47ebd72..1e4d5685e 100644 --- a/Source/Term/tests/Term_IT.cpp +++ b/Source/Term/tests/Term_IT.cpp @@ -2773,8 +2773,8 @@ U"Weather report: Houston REQUIRE(result.size() == h * w); REQUIRE(std::u32string_view(expectation).length() == h * w); for( size_t line = 0; line < h; ++line ) { - auto lhs = std::u32string_view(result.data() + line * w, w); - auto rhs = std::u32string_view(expectation + line * w, w); + auto lhs = std::u32string_view(result.data() + (line * w), w); + auto rhs = std::u32string_view(expectation + (line * w), w); INFO(std::to_string(line)); CHECK(lhs == rhs); } diff --git a/Source/Utility/source/BlinkScheduler.cpp b/Source/Utility/source/BlinkScheduler.cpp index 00fd70f10..f6b1a373a 100644 --- a/Source/Utility/source/BlinkScheduler.cpp +++ b/Source/Utility/source/BlinkScheduler.cpp @@ -112,7 +112,7 @@ void BlinkScheduler::Impl::Schedule() void BlinkScheduler::Impl::Fire() { m_Scheduled = false; - if( m_Enabled == false ) { + if( !m_Enabled ) { // was disabled after scheduled - don't do anything return; } @@ -121,7 +121,7 @@ void BlinkScheduler::Impl::Fire() m_OnBlink(); - if( m_Enabled == false ) { + if( !m_Enabled ) { // now check for reentrancy shenenigans return; } diff --git a/Source/Utility/source/ByteCountFormatter.mm b/Source/Utility/source/ByteCountFormatter.mm index b6543160a..c7d54d9ad 100644 --- a/Source/Utility/source/ByteCountFormatter.mm +++ b/Source/Utility/source/ByteCountFormatter.mm @@ -247,7 +247,7 @@ static constexpr unsigned chartouni(const char *_from, unsigned short *_to, unsi else if( _size < 9999lu * m_Exponent[1] ) { // kilobytes constexpr uint64_t div = m_Exponent[1]; const uint64_t res = _size / div; - const int len = static_cast(fmt::format_to(buf, "{}", res + (_size - res * div) / (div / 2)) - buf); + const int len = static_cast(fmt::format_to(buf, "{}", res + ((_size - res * div) / (div / 2))) - buf); chartouni(buf, _buf, len); _buf[len] = ' '; _buf[len + 1] = m_SI[1]; @@ -256,7 +256,7 @@ static constexpr unsigned chartouni(const char *_from, unsigned short *_to, unsi else if( _size < 9999lu * m_Exponent[2] ) { // megabytes constexpr uint64_t div = m_Exponent[2]; const uint64_t res = _size / div; - const int len = static_cast(fmt::format_to(buf, "{}", res + (_size - res * div) / (div / 2)) - buf); + const int len = static_cast(fmt::format_to(buf, "{}", res + ((_size - res * div) / (div / 2))) - buf); chartouni(buf, _buf, len); _buf[len] = ' '; _buf[len + 1] = m_SI[2]; @@ -265,7 +265,7 @@ static constexpr unsigned chartouni(const char *_from, unsigned short *_to, unsi else if( _size < 9999lu * m_Exponent[3] ) { // gigabytes constexpr uint64_t div = m_Exponent[3]; const uint64_t res = _size / div; - const int len = static_cast(fmt::format_to(buf, "{}", res + (_size - res * div) / (div / 2)) - buf); + const int len = static_cast(fmt::format_to(buf, "{}", res + ((_size - res * div) / (div / 2))) - buf); chartouni(buf, _buf, len); _buf[len] = ' '; _buf[len + 1] = m_SI[3]; @@ -274,7 +274,7 @@ static constexpr unsigned chartouni(const char *_from, unsigned short *_to, unsi else if( _size < 9999lu * m_Exponent[4] ) { // terabytes constexpr uint64_t div = m_Exponent[4]; const uint64_t res = _size / div; - const int len = static_cast(fmt::format_to(buf, "{}", res + (_size - res * div) / (div / 2)) - buf); + const int len = static_cast(fmt::format_to(buf, "{}", res + ((_size - res * div) / (div / 2))) - buf); chartouni(buf, _buf, len); _buf[len] = ' '; _buf[len + 1] = m_SI[4]; @@ -283,7 +283,7 @@ static constexpr unsigned chartouni(const char *_from, unsigned short *_to, unsi else if( _size < 9999lu * m_Exponent[5] ) { // petabytes constexpr uint64_t div = m_Exponent[5]; const uint64_t res = _size / div; - const int len = static_cast(fmt::format_to(buf, "{}", res + (_size - res * div) / (div / 2)) - buf); + const int len = static_cast(fmt::format_to(buf, "{}", res + ((_size - res * div) / (div / 2))) - buf); chartouni(buf, _buf, len); _buf[len] = ' '; _buf[len + 1] = m_SI[5]; diff --git a/Source/Utility/source/DataBlockAnalysis.mm b/Source/Utility/source/DataBlockAnalysis.mm index e945728a6..bdf174d9e 100644 --- a/Source/Utility/source/DataBlockAnalysis.mm +++ b/Source/Utility/source/DataBlockAnalysis.mm @@ -54,7 +54,7 @@ static int UTF8Errors(const unsigned char *_bytes, size_t _n) static int UTF16LEErrors(const unsigned char *_bytes, size_t _n) { const uint16_t *cur = reinterpret_cast(_bytes); - const uint16_t *end = cur + _n / sizeof(uint16_t); + const uint16_t *end = cur + (_n / sizeof(uint16_t)); int errors = 0; @@ -87,7 +87,7 @@ static int UTF16LEErrors(const unsigned char *_bytes, size_t _n) static int UTF16BEErrors(const unsigned char *_bytes, size_t _n) { const uint16_t *cur = reinterpret_cast(_bytes); - const uint16_t *end = cur + _n / sizeof(uint16_t); + const uint16_t *end = cur + (_n / sizeof(uint16_t)); int errors = 0; diff --git a/Source/Utility/source/DiskUtility.mm b/Source/Utility/source/DiskUtility.mm index 21aecc8d7..d814ef7ad 100644 --- a/Source/Utility/source/DiskUtility.mm +++ b/Source/Utility/source/DiskUtility.mm @@ -280,7 +280,7 @@ static std::string_view RoleToDiskUtilRepr(APFSTree::Role _role) noexcept { - static const std::string_view none = ""; + static const std::string_view none; static const std::string_view system = "System"; static const std::string_view user = "User"; static const std::string_view recovery = "Recovery"; diff --git a/Source/Utility/source/Encodings.cpp b/Source/Utility/source/Encodings.cpp index 1706afc08..5c51e3004 100644 --- a/Source/Utility/source/Encodings.cpp +++ b/Source/Utility/source/Encodings.cpp @@ -1341,7 +1341,7 @@ void InterpretUTF16LEBufferAsUniChar(const unsigned char *_input, ) { const uint16_t *cur = reinterpret_cast(_input); - const uint16_t *end = cur + _input_size / sizeof(uint16_t); + const uint16_t *end = cur + (_input_size / sizeof(uint16_t)); unsigned total = 0; @@ -1396,7 +1396,7 @@ void InterpretUTF16BEBufferAsUniChar(const unsigned char *_input, ) { const uint16_t *cur = reinterpret_cast(_input); - const uint16_t *end = cur + _input_size / sizeof(uint16_t); + const uint16_t *end = cur + (_input_size / sizeof(uint16_t)); unsigned total = 0; diff --git a/Source/Utility/source/ExtensionLowercaseComparison.cpp b/Source/Utility/source/ExtensionLowercaseComparison.cpp index 1cf2ca001..fa6d754a2 100644 --- a/Source/Utility/source/ExtensionLowercaseComparison.cpp +++ b/Source/Utility/source/ExtensionLowercaseComparison.cpp @@ -98,7 +98,7 @@ ExtensionsLowercaseList::ExtensionsLowercaseList(std::string_view _comma_separat if( auto trimmed = base::Trim(std::string_view{ext}); !trimmed.empty() ) exts.emplace_back(trimmed); for( auto &ext : exts ) { - if( ext.empty() == false ) + if( !ext.empty() ) m_List.emplace(i.ExtensionToLowercase(ext)); } } diff --git a/Source/Utility/source/FSEventsDirUpdateImpl.cpp b/Source/Utility/source/FSEventsDirUpdateImpl.cpp index 7d9a5db90..1f1fab4cf 100644 --- a/Source/Utility/source/FSEventsDirUpdateImpl.cpp +++ b/Source/Utility/source/FSEventsDirUpdateImpl.cpp @@ -199,7 +199,7 @@ uint64_t FSEventsDirUpdateImpl::AddWatchPath(std::string_view _path, std::functi Log::Trace("Creating a new watcher for '{}'", _path); auto ep = m_Watches.emplace(dir_path, std::make_unique()); assert(ep.second == true); - WatchData &w = *ep.first->second.get(); + WatchData &w = *ep.first->second; w.stream = CreateEventStream(dir_path, &w); if( w.stream == nullptr ) { // failed to creat the event stream, roll back the changes and return a failure indication diff --git a/Source/Utility/source/FSEventsFileUpdateImpl.cpp b/Source/Utility/source/FSEventsFileUpdateImpl.cpp index 9c6915858..52738afa4 100644 --- a/Source/Utility/source/FSEventsFileUpdateImpl.cpp +++ b/Source/Utility/source/FSEventsFileUpdateImpl.cpp @@ -86,7 +86,7 @@ uint64_t FSEventsFileUpdateImpl::AddWatchPath(const std::filesystem::path &_path m_Watches.emplace(_path, std::move(watch)); } - if( was_empty == true && m_KickstartIsOnline == false ) + if( was_empty && !m_KickstartIsOnline ) ScheduleScannerKickstart(); return token; diff --git a/Source/Utility/source/FileMask.cpp b/Source/Utility/source/FileMask.cpp index 1904d0718..8410d4cf0 100644 --- a/Source/Utility/source/FileMask.cpp +++ b/Source/Utility/source/FileMask.cpp @@ -50,13 +50,11 @@ static std::vector sub_masks(std::string_view _source) return masks; } -static bool string_needs_normalization(std::string_view _string) +static bool string_needs_normalization(std::string_view _string) noexcept { - for( const unsigned char c : _string ) - if( c > 127 || (c >= 0x41 && c <= 0x5A) ) // >= 'A' && <= 'Z' - return true; - - return false; + return std::ranges::any_of(_string, [](const unsigned char _c) { + return _c > 127 || (_c >= 0x41 && _c <= 0x5A); // >= 'A' && <= 'Z' + }); } class InplaceFormCLowercaseString @@ -230,7 +228,7 @@ bool FileMask::MatchName(std::string_view _name) const noexcept return false; const InplaceFormCLowercaseString normalized_name(_name); - for( auto &m : m_Masks ) + return std::ranges::any_of(m_Masks, [&](auto &m) { if( m.index() == 0 ) { const auto &re = std::get>(m); if( re2::RE2::FullMatch(normalized_name.str(), *re) ) @@ -241,8 +239,8 @@ bool FileMask::MatchName(std::string_view _name) const noexcept if( CompareAgainstSimpleMask(simple_mask, _name) ) // TODO: why the original string here?? return true; } - - return false; + return false; + }); } bool FileMask::IsWildCard(const std::string &_mask) diff --git a/Source/Utility/source/FontCache.cpp b/Source/Utility/source/FontCache.cpp index 976df7d2a..65ecaad28 100644 --- a/Source/Utility/source/FontCache.cpp +++ b/Source/Utility/source/FontCache.cpp @@ -110,7 +110,7 @@ static base::CFPtr CreateFallbackFontHardway(uint32_t _unicode, CTFon if( line == nullptr ) goto cleanup; - runs = static_cast(CTLineGetGlyphRuns(line)); + runs = CTLineGetGlyphRuns(line); if( runs == nullptr || CFArrayGetCount(runs) == 0 ) goto cleanup; @@ -195,7 +195,7 @@ FontCache::Pair FontCache::DoGetBMP(uint16_t _c) auto ctfont = CreateFallbackFontStraight(_c, m_CTFonts[0].get()); if( ctfont ) { r = CTFontGetGlyphsForCharacters(ctfont.get(), &_c, &g, 1); - if( r == true ) // it should be true always, but for confidence... + if( r ) // it should be true always, but for confidence... { // check if this font is new one, or we already have this one in dictionary for( size_t i = 1; i < m_CTFonts.size(); ++i ) { diff --git a/Source/Utility/source/FontExtras.mm b/Source/Utility/source/FontExtras.mm index beb6dc8c8..40892742f 100644 --- a/Source/Utility/source/FontExtras.mm +++ b/Source/Utility/source/FontExtras.mm @@ -104,7 +104,7 @@ - (NSString *)toStringDescription while( search_range.length > 0 ) { CFRange found_range; const bool found = CFStringFindCharacterFromSet(str.get(), newline_cs, search_range, 0, &found_range); - if( found == false ) + if( !found ) break; CFStringReplace(str.get(), found_range, _with); search_range.location = found_range.location + replacement_length; diff --git a/Source/Utility/source/FunctionKeysPass.mm b/Source/Utility/source/FunctionKeysPass.mm index a32768c20..a895a91c0 100644 --- a/Source/Utility/source/FunctionKeysPass.mm +++ b/Source/Utility/source/FunctionKeysPass.mm @@ -165,7 +165,7 @@ static CGEventRef NewFnButtonPress(CGKeyCode _vk, bool _key_down, CGEventFlags _ dispatch_assert_main_queue(); if( m_Port == nullptr ) { - if( ObtainAccessiblityRights() == false ) + if( !ObtainAccessiblityRights() ) return false; const auto interested_events = diff --git a/Source/Utility/source/HexadecimalColor.mm b/Source/Utility/source/HexadecimalColor.mm index 550e7bc6f..64abbe29a 100644 --- a/Source/Utility/source/HexadecimalColor.mm +++ b/Source/Utility/source/HexadecimalColor.mm @@ -32,7 +32,7 @@ static constexpr int HexToInt(char _c) noexcept static constexpr int DupHex(int _h) noexcept { - return _h * 16 + _h; + return (_h * 16) + _h; } static constexpr uint32_t HexadecimalColorStringToRGBA(std::string_view _string) noexcept @@ -41,14 +41,14 @@ static constexpr uint32_t HexadecimalColorStringToRGBA(std::string_view _string) return g_BlackColor; if( _string.length() >= 9 ) // #RRGGBBAA - return MakeRGBA(static_cast(HexToInt(_string[1]) * 16 + HexToInt(_string[2])), - static_cast(HexToInt(_string[3]) * 16 + HexToInt(_string[4])), - static_cast(HexToInt(_string[5]) * 16 + HexToInt(_string[6])), - static_cast(HexToInt(_string[7]) * 16 + HexToInt(_string[8]))); + return MakeRGBA(static_cast((HexToInt(_string[1]) * 16) + HexToInt(_string[2])), + static_cast((HexToInt(_string[3]) * 16) + HexToInt(_string[4])), + static_cast((HexToInt(_string[5]) * 16) + HexToInt(_string[6])), + static_cast((HexToInt(_string[7]) * 16) + HexToInt(_string[8]))); if( _string.length() >= 7 ) // #RRGGBB - return MakeRGBA(static_cast(HexToInt(_string[1]) * 16 + HexToInt(_string[2])), - static_cast(HexToInt(_string[3]) * 16 + HexToInt(_string[4])), - static_cast(HexToInt(_string[5]) * 16 + HexToInt(_string[6])), + return MakeRGBA(static_cast((HexToInt(_string[1]) * 16) + HexToInt(_string[2])), + static_cast((HexToInt(_string[3]) * 16) + HexToInt(_string[4])), + static_cast((HexToInt(_string[5]) * 16) + HexToInt(_string[6])), 255); if( _string.length() >= 5 ) // #RGBA return MakeRGBA(static_cast(DupHex(HexToInt(_string[1]))), diff --git a/Source/Utility/source/NativeFSManagerImpl.mm b/Source/Utility/source/NativeFSManagerImpl.mm index c5aa6b10a..fbd3fe5b5 100644 --- a/Source/Utility/source/NativeFSManagerImpl.mm +++ b/Source/Utility/source/NativeFSManagerImpl.mm @@ -60,7 +60,7 @@ - (void)volumeDidUnmount:(NSNotification *)_notification; const auto volume = std::make_shared(); volume->mounted_at_path = mount_path; m_Volumes.emplace_back(volume); - GetAllInfos(*volume.get()); + GetAllInfos(*volume); m_VolumeLookup.Insert(volume, EnsureTrailingSlash(mount_path)); } @@ -356,7 +356,7 @@ static bool GetVerboseInfo(NativeFileSystemInfo &_volume) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), [=, this] { auto volume = std::make_shared(); volume->mounted_at_path = _on_path; - GetAllInfos(*volume.get()); + GetAllInfos(*volume); const std::lock_guard lock(m_Lock); InsertNewVolume_Unlocked(volume); @@ -406,7 +406,7 @@ static bool GetVerboseInfo(NativeFileSystemInfo &_volume) if( it != std::end(m_Volumes) ) { const auto &volume = *it; volume->mounted_at_path = _new_path; - GetVerboseInfo(*volume.get()); + GetVerboseInfo(*volume); m_VolumeLookup.Remove(EnsureTrailingSlash(_old_path)); m_VolumeLookup.Insert(volume, EnsureTrailingSlash(_new_path)); } @@ -523,8 +523,8 @@ static bool UpdateSpaceInfo(NativeFileSystemInfo &_volume) if( std::ranges::find(excl_list, volume->mounted_at_path) != excl_list.end() ) return false; - return volume->mount_flags.ejectable == true || volume->mount_flags.removable == true || - volume->mount_flags.internal == false || volume->mount_flags.local == false; + return volume->mount_flags.ejectable || volume->mount_flags.removable || !volume->mount_flags.internal || + !volume->mount_flags.local; } void NativeFSManagerImpl::EjectVolumeContainingPath(const std::string &_path) diff --git a/Source/Utility/source/SystemInformation.mm b/Source/Utility/source/SystemInformation.mm index 71bb1fd92..d37a1e2a6 100644 --- a/Source/Utility/source/SystemInformation.mm +++ b/Source/Utility/source/SystemInformation.mm @@ -254,7 +254,7 @@ int GetBSDProcessList(kinfo_proc **procList, size_t *procCount) if( sysctl(mib, 2, &boottime_raw, &len, nullptr, 0) != 0 ) return {}; const auto boottime = std::chrono::system_clock::time_point( - std::chrono::microseconds(boottime_raw.tv_usec + boottime_raw.tv_sec * 1000000)); + std::chrono::microseconds(boottime_raw.tv_usec + (boottime_raw.tv_sec * 1000000))); const auto uptime = std::chrono::system_clock::now() - boottime; return std::chrono::duration_cast(uptime); } diff --git a/Source/Utility/source/Tags.cpp b/Source/Utility/source/Tags.cpp index ff40e0bc6..5a09793f4 100644 --- a/Source/Utility/source/Tags.cpp +++ b/Source/Utility/source/Tags.cpp @@ -502,7 +502,7 @@ static std::pmr::vector WritePListObject(const Tags::Tag &_tag, std:: assert(target_size % 2 == 0); const size_t len_color = _tag.Color() == Tags::Color::None ? 0 : 2; - const size_t len = target_size / 2 + len_color; + const size_t len = (target_size / 2) + len_color; // write the byte marker and size WriteVarSize(0x60, len, dst); @@ -664,10 +664,7 @@ bool Tags::WriteTags(int _fd, std::span _tags) noexcept } SetFinderInfoLabel(finder_info, _tags.front().Color()); - if( fsetxattr(_fd, g_FinderInfo, finder_info.data(), finder_info.size(), 0, 0) != 0 ) - return false; - - return true; + return fsetxattr(_fd, g_FinderInfo, finder_info.data(), finder_info.size(), 0, 0) == 0; } bool Tags::WriteTags(const std::filesystem::path &_path, std::span _tags) noexcept diff --git a/Source/Utility/source/TemporaryFileStorageImpl.cpp b/Source/Utility/source/TemporaryFileStorageImpl.cpp index b9ff11de1..fa548e08a 100644 --- a/Source/Utility/source/TemporaryFileStorageImpl.cpp +++ b/Source/Utility/source/TemporaryFileStorageImpl.cpp @@ -24,7 +24,7 @@ TemporaryFileStorageImpl::TemporaryFileStorageImpl(std::string_view _base_direct : m_BaseDirectory{EnsureTrailingSlash(std::string{_base_directory})}, m_SubDirectoriesPrefix{_sub_directories_prefix} { - if( CheckRWAccess(m_BaseDirectory) == false ) + if( !CheckRWAccess(m_BaseDirectory) ) throw std::invalid_argument("TemporaryFileStorageImpl: can't access the base directory"); if( m_SubDirectoriesPrefix.empty() ) throw std::invalid_argument("TemporaryFileStorageImpl: empty sub directories prefix"); @@ -93,14 +93,14 @@ std::optional TemporaryFileStorageImpl::FindSuitableExistingTempDir // traverse each temp dir to check if this entry is already in there for( size_t i = 0, e = m_TempDirectories.size(); i != e; ++i ) { auto &directory = m_TempDirectories[i]; - if( CheckRWAccess(directory) == false ) { + if( !CheckRWAccess(directory) ) { // either this directory was purged or tampered in some other way - so remove it indices_to_remove.push_back(i); continue; } auto full_path = directory; full_path += _for_filename; - if( CheckExistence(full_path) == false ) { + if( !CheckExistence(full_path) ) { // there's no such entry in this directory - use this one then chosen_dir = directory; break; @@ -143,7 +143,7 @@ void TemporaryFileStorageImpl::Purge(time_t _older_than) { const auto directories = FindExistingTempDirectories(); for( const auto &directory : directories ) { - if( PurgeSubDirectory(directory, _older_than) == true ) + if( PurgeSubDirectory(directory, _older_than) ) RMRF(directory); } } @@ -221,7 +221,7 @@ static std::string MakeRandomFilename() // TODO: write something more reasonable std::string filename; for( int i = 0; i < 6; ++i ) - filename += 'A' + rand() % ('Z' - 'A'); + filename += 'A' + (rand() % ('Z' - 'A')); return filename; } diff --git a/Source/Utility/source/UTIImpl.cpp b/Source/Utility/source/UTIImpl.cpp index a6a020959..5689494f1 100644 --- a/Source/Utility/source/UTIImpl.cpp +++ b/Source/Utility/source/UTIImpl.cpp @@ -64,7 +64,7 @@ static void TraverseConformingUTIs( if( object != nullptr && CFGetTypeID(object) == CFStringGetTypeID() ) { const auto conforming_cf_string = static_cast(object); const auto conforming_std_string = base::CFStringGetUTF8StdString(conforming_cf_string); - if( _target.contains(conforming_std_string) == false ) { + if( !_target.contains(conforming_std_string) ) { _target.emplace(conforming_std_string); TraverseConformingUTIs(conforming_std_string, _target); } @@ -74,7 +74,7 @@ static void TraverseConformingUTIs( else if( CFGetTypeID(conforms_to) == CFStringGetTypeID() ) { const auto conforming_cf_string = static_cast(conforms_to); const auto conforming_std_string = base::CFStringGetUTF8StdString(conforming_cf_string); - if( _target.contains(conforming_std_string) == false ) { + if( !_target.contains(conforming_std_string) ) { _target.emplace(conforming_std_string); TraverseConformingUTIs(conforming_std_string, _target); } diff --git a/Source/Utility/source/VersionCompare.mm b/Source/Utility/source/VersionCompare.mm index bb851e6d1..44280c386 100644 --- a/Source/Utility/source/VersionCompare.mm +++ b/Source/Utility/source/VersionCompare.mm @@ -78,12 +78,12 @@ } else { // different part - if( std::holds_alternative(left_token) == true && - std::holds_alternative(right_token) == false ) { + if( std::holds_alternative(left_token) && + !std::holds_alternative(right_token) ) { return -1; } - else if( std::holds_alternative(left_token) == false && - std::holds_alternative(right_token) == true ) { + else if( !std::holds_alternative(left_token) && + std::holds_alternative(right_token) ) { return 1; } else if( std::holds_alternative(left_token) ) { diff --git a/Source/Utility/source/VolumeInformation.cpp b/Source/Utility/source/VolumeInformation.cpp index 42b8028b3..96e5fa6bf 100644 --- a/Source/Utility/source/VolumeInformation.cpp +++ b/Source/Utility/source/VolumeInformation.cpp @@ -335,8 +335,8 @@ int FetchVolumeAttributesInformation(const char *_path, CFURLRef cfurl = CFURLCreateFromFileSystemRepresentation( nullptr, reinterpret_cast(_path), std::strlen(_path), false); CFStringRef fsverbname; - if( CFURLCopyResourcePropertyForKey(cfurl, kCFURLVolumeLocalizedFormatDescriptionKey, &fsverbname, nullptr) == - false ) { + if( !static_cast( + CFURLCopyResourcePropertyForKey(cfurl, kCFURLVolumeLocalizedFormatDescriptionKey, &fsverbname, nullptr)) ) { CFRelease(cfurl); return -1; // what to return??? } diff --git a/Source/Utility/tests/ByteCountFormatter_UT.mm b/Source/Utility/tests/ByteCountFormatter_UT.mm index 6292a3afb..e87d18b7e 100644 --- a/Source/Utility/tests/ByteCountFormatter_UT.mm +++ b/Source/Utility/tests/ByteCountFormatter_UT.mm @@ -28,8 +28,8 @@ {.size = 5949ull, .expected = @"5.8 KB"}, {.size = 6000ull, .expected = @"5.9 KB"}, {.size = 1024ull * 1024ull, .expected = @"1.0 MB"}, - {.size = 1024ull * 1024ull - 10, .expected = @"1.0 MB"}, - {.size = 1024ull * 1024ull + 10, .expected = @"1.0 MB"}, + {.size = (1024ull * 1024ull) - 10, .expected = @"1.0 MB"}, + {.size = (1024ull * 1024ull) + 10, .expected = @"1.0 MB"}, {.size = static_cast(1024 * 1024 * 1.5), .expected = @"1.5 MB"}, {.size = static_cast(1024 * 9.9), .expected = @"9.9 KB"}, {.size = static_cast(1024 * 9.97), .expected = @"10 KB"}, diff --git a/Source/VFS/include/VFS/SearchInFile.h b/Source/VFS/include/VFS/SearchInFile.h index 1e0c799c7..3ce778a50 100644 --- a/Source/VFS/include/VFS/SearchInFile.h +++ b/Source/VFS/include/VFS/SearchInFile.h @@ -41,7 +41,7 @@ class SearchInFile void MoveCurrentPosition(uint64_t _pos); void SetSearchOptions(Options _options); - Options SearchOptions(); + Options SearchOptions() const; bool IsEOF() const; diff --git a/Source/VFS/source/AppleDoubleEA.cpp b/Source/VFS/source/AppleDoubleEA.cpp index 7019df412..3b4a6b471 100644 --- a/Source/VFS/source/AppleDoubleEA.cpp +++ b/Source/VFS/source/AppleDoubleEA.cpp @@ -195,12 +195,9 @@ static void swap_attrhdr(attr_header_t *ah) static bool IsAppleDouble(const void *_memory_buf, size_t _memory_size) { const apple_double_header_t *adhdr = static_cast(_memory_buf); - if( _memory_size < sizeof(apple_double_header_t) - 2 || SWAP32(adhdr->magic) != ADH_MAGIC || - SWAP32(adhdr->version) != ADH_VERSION || SWAP16(adhdr->numEntries) != 2 || - SWAP32(adhdr->entries[0].type) != AD_FINDERINFO ) - return false; - - return true; + return _memory_size >= sizeof(apple_double_header_t) - 2 && SWAP32(adhdr->magic) == ADH_MAGIC && + SWAP32(adhdr->version) == ADH_VERSION && SWAP16(adhdr->numEntries) == 2 && + SWAP32(adhdr->entries[0].type) == AD_FINDERINFO; } std::vector ExtractEAFromAppleDouble(const void *_memory_buf, size_t _memory_size) diff --git a/Source/VFS/source/ArcLA/File.cpp b/Source/VFS/source/ArcLA/File.cpp index 665860bdd..4c2df77ff 100644 --- a/Source/VFS/source/ArcLA/File.cpp +++ b/Source/VFS/source/ArcLA/File.cpp @@ -37,7 +37,7 @@ int File::Open(unsigned long _open_flags, const VFSCancelChecker &_cancel_checke if( res < 0 ) return res; - if( host->IsDirectory(file_path.c_str(), _open_flags, _cancel_checker) && !(_open_flags & VFSFlags::OF_Directory) ) + if( host->IsDirectory(file_path, _open_flags, _cancel_checker) && !(_open_flags & VFSFlags::OF_Directory) ) return VFSError::FromErrno(EISDIR); std::unique_ptr state; diff --git a/Source/VFS/source/ArcLA/Host.cpp b/Source/VFS/source/ArcLA/Host.cpp index ffae0e0a1..ad26487d4 100644 --- a/Source/VFS/source/ArcLA/Host.cpp +++ b/Source/VFS/source/ArcLA/Host.cpp @@ -118,7 +118,7 @@ ArchiveHost::ArchiveHost(const std::string_view _path, } ArchiveHost::ArchiveHost(const VFSHostPtr &_parent, const VFSConfiguration &_config, VFSCancelChecker _cancel_checker) - : Host(_config.Get().path.c_str(), _parent, UniqueTag), I(std::make_unique()), + : Host(_config.Get().path, _parent, UniqueTag), I(std::make_unique()), m_Configuration(_config) { assert(_parent); @@ -174,14 +174,14 @@ int ArchiveHost::DoInit(VFSCancelChecker _cancel_checker) { VFSStat st; - res = Parent()->Stat(path.c_str(), st, 0); + res = Parent()->Stat(path, st, 0); if( res < 0 ) return res; VFSStat::ToSysStat(st, I->m_SrcFileStat); } VFSFilePtr source_file; - res = Parent()->CreateFile(path.c_str(), source_file, {}); + res = Parent()->CreateFile(path, source_file, {}); if( res < 0 ) return res; @@ -530,7 +530,7 @@ int ArchiveHost::CreateFile(std::string_view _path, int ArchiveHost::FetchDirectoryListing(std::string_view _path, VFSListingPtr &_target, unsigned long _flags, - const VFSCancelChecker &) + const VFSCancelChecker & /*_cancel_checker*/) { StackAllocator alloc; std::pmr::string path(&alloc); @@ -621,7 +621,10 @@ bool ArchiveHost::IsDirectory(std::string_view _path, unsigned long _flags, cons return Host::IsDirectory(_path, _flags, _cancel_checker); } -int ArchiveHost::Stat(std::string_view _path, VFSStat &_st, unsigned long _flags, const VFSCancelChecker &) +int ArchiveHost::Stat(std::string_view _path, + VFSStat &_st, + unsigned long _flags, + const VFSCancelChecker & /*_cancel_checker*/) { if( _path.empty() ) return VFSError::InvalidCall; @@ -642,7 +645,7 @@ int ArchiveHost::Stat(std::string_view _path, VFSStat &_st, unsigned long _flags if( res < 0 ) return res; - if( auto it = FindEntry(resolve_buf.c_str()) ) { + if( auto it = FindEntry(resolve_buf) ) { VFSStat::FromSysStat(it->st, _st); return VFSError::Ok; } @@ -722,18 +725,18 @@ const DirEntry *ArchiveHost::FindEntry(std::string_view _path) // TODO: rewrite without using C-style strings // 1st - try to find _path directly (assume it's directory) - char buf[1024]; + char full_path[1024]; char short_name[256]; - memcpy(buf, _path.data(), _path.length()); - buf[_path.length()] = 0; + memcpy(full_path, _path.data(), _path.length()); + full_path[_path.length()] = 0; - char *last_sl = strrchr(buf, '/'); + char *last_sl = strrchr(full_path, '/'); - if( last_sl == buf && strlen(buf) == 1 ) + if( last_sl == full_path && strlen(full_path) == 1 ) return nullptr; // we have no info about root dir - if( last_sl == buf + strlen(buf) - 1 ) { + if( last_sl == full_path + strlen(full_path) - 1 ) { *last_sl = 0; // cut trailing slash - last_sl = strrchr(buf, '/'); + last_sl = strrchr(full_path, '/'); assert(last_sl != nullptr); // sanity check } @@ -744,20 +747,20 @@ const DirEntry *ArchiveHost::FindEntry(std::string_view _path) // short_name - entry name within that directory if( strcmp(short_name, "..") == 0 ) { // special treatment for dot-dot - char tmp[1024]; - if( !GetDirectoryContainingItemFromPath(buf, tmp) ) + char directory[1024]; + if( !GetDirectoryContainingItemFromPath(full_path, directory) ) return nullptr; - return FindEntry(tmp); + return FindEntry(directory); } - const auto i = I->m_PathToDir.find(buf); + const auto i = I->m_PathToDir.find(full_path); if( i == I->m_PathToDir.end() ) return nullptr; // ok, found dir, now let's find item const size_t short_name_len = strlen(short_name); for( const auto &it : i->second.entries ) - if( it.name.length() == short_name_len && it.name.compare(short_name) == 0 ) + if( it.name.length() == short_name_len && it.name == short_name ) return ⁢ return nullptr; @@ -814,7 +817,7 @@ int ArchiveHost::ResolvePath(std::string_view _path, std::pmr::string &_resolved return result_uid; } -int ArchiveHost::StatFS(std::string_view /*_path*/, VFSStatFS &_stat, const VFSCancelChecker &) +int ArchiveHost::StatFS(std::string_view /*_path*/, VFSStatFS &_stat, const VFSCancelChecker & /*_cancel_checker*/) { const std::string_view vol_name = utility::PathManip::Filename(JunctionPath()); if( vol_name.empty() ) @@ -1086,7 +1089,7 @@ const ArchiveHost::Symlink *ArchiveHost::ResolvedSymlink(uint32_t _uid) int ArchiveHost::ReadSymlink(std::string_view _symlink_path, char *_buffer, size_t _buffer_size, - const VFSCancelChecker &) + const VFSCancelChecker & /*_cancel_checker*/) { auto entry = FindEntry(_symlink_path); if( !entry ) diff --git a/Source/VFS/source/ArcLARaw/Host.cpp b/Source/VFS/source/ArcLARaw/Host.cpp index 7aa6001b0..616de03ca 100644 --- a/Source/VFS/source/ArcLARaw/Host.cpp +++ b/Source/VFS/source/ArcLARaw/Host.cpp @@ -60,7 +60,7 @@ static Extracted read_stream(const uint64_t _max_bytes, } st; int rc = 0; - rc = _parent.CreateFile(_path.c_str(), st.source_file, _cancel_checker); + rc = _parent.CreateFile(_path, st.source_file, _cancel_checker); if( rc < 0 ) return rc; rc = st.source_file->Open(VFSFlags::OF_Read); @@ -174,7 +174,7 @@ ArchiveRawHost::ArchiveRawHost(const std::string_view _path, ArchiveRawHost::ArchiveRawHost(const VFSHostPtr &_parent, const VFSConfiguration &_config, VFSCancelChecker _cancel_checker) - : Host(_config.Get().path.c_str(), _parent, UniqueTag), m_Configuration(_config) + : Host(_config.Get().path, _parent, UniqueTag), m_Configuration(_config) { Init(_cancel_checker); } @@ -213,7 +213,7 @@ void ArchiveRawHost::Init(const VFSCancelChecker &_cancel_checker) m_MTime.tv_sec = extracted.mtime; if( m_MTime.tv_sec == 0 ) { VFSStat st; - const auto st_rc = Parent()->Stat(path.c_str(), st, Flags::None, _cancel_checker); + const auto st_rc = Parent()->Stat(path, st, Flags::None, _cancel_checker); if( st_rc != VFSError::Ok ) throw VFSErrorException(st_rc); m_MTime = st.mtime; diff --git a/Source/VFS/source/FileWindow.cpp b/Source/VFS/source/FileWindow.cpp index 4fb0798f7..46c20da7d 100644 --- a/Source/VFS/source/FileWindow.cpp +++ b/Source/VFS/source/FileWindow.cpp @@ -13,7 +13,7 @@ FileWindow::FileWindow(const std::shared_ptr &_file, int _window_size) bool FileWindow::FileOpened() const { - return m_Window.get() != nullptr; + return m_Window != nullptr; } int FileWindow::Attach(const std::shared_ptr &_file, int _window_size) diff --git a/Source/VFS/source/Host.cpp b/Source/VFS/source/Host.cpp index 47ddbea14..11c511c15 100644 --- a/Source/VFS/source/Host.cpp +++ b/Source/VFS/source/Host.cpp @@ -14,7 +14,7 @@ namespace nc::vfs { -HostDirObservationTicket::HostDirObservationTicket() noexcept : m_Ticket(0), m_Host() +HostDirObservationTicket::HostDirObservationTicket() noexcept : m_Ticket(0) { } @@ -93,7 +93,7 @@ FileObservationToken &FileObservationToken::operator=(FileObservationToken &&_rh FileObservationToken::operator bool() const noexcept { - return m_Token != 0 && m_Host.expired() == false; + return m_Token != 0 && !m_Host.expired(); } void FileObservationToken::reset() noexcept @@ -115,7 +115,7 @@ class VFSHostConfiguration [[nodiscard]] static const char *Junction() { return ""; } - bool operator==(const VFSHostConfiguration &) const { return true; } + bool operator==(const VFSHostConfiguration & /*unused*/) const { return true; } }; Host::Host(const std::string_view _junction_path, const std::shared_ptr &_parent, const char *_fs_tag) @@ -474,7 +474,7 @@ int Host::FetchFlexibleListingItems(const std::string &_directory_path, const VFSCancelChecker &_cancel_checker) { VFSListingPtr listing; - const int ret = FetchDirectoryListing(_directory_path.c_str(), listing, _flags, _cancel_checker); + const int ret = FetchDirectoryListing(_directory_path, listing, _flags, _cancel_checker); if( ret != 0 ) return ret; diff --git a/Source/VFS/source/Listing.cpp b/Source/VFS/source/Listing.cpp index 4c013c4be..fc6600f4c 100644 --- a/Source/VFS/source/Listing.cpp +++ b/Source/VFS/source/Listing.cpp @@ -321,7 +321,7 @@ VFSListingPtr Listing::ProduceUpdatedTemporaryPanelListing(const Listing &_origi VFSStat st; auto stat_flags = _original.IsSymlink(i) ? VFSFlags::F_NoFollow : 0; - if( _original.Host(i)->Stat(path.c_str(), st, stat_flags, _cancel_checker) == 0 ) { + if( _original.Host(i)->Stat(path, st, stat_flags, _cancel_checker) == 0 ) { result.filenames.emplace_back(_original.Filename(i)); result.unix_modes.emplace_back(_original.UnixMode(i)); diff --git a/Source/VFS/source/Mem/Host.cpp b/Source/VFS/source/Mem/Host.cpp index c581b3a40..b30fc0420 100644 --- a/Source/VFS/source/Mem/Host.cpp +++ b/Source/VFS/source/Mem/Host.cpp @@ -11,7 +11,7 @@ class VFSMemHostConfiguration [[nodiscard]] static const char *Junction() { return ""; } - bool operator==(const VFSMemHostConfiguration &) const { return true; } + bool operator==(const VFSMemHostConfiguration & /*unused*/) const { return true; } [[nodiscard]] static const char *VerboseJunction() { return "[memfs]:"; } }; diff --git a/Source/VFS/source/Native/File.cpp b/Source/VFS/source/Native/File.cpp index 031f4ee5a..26cbfa54e 100644 --- a/Source/VFS/source/Native/File.cpp +++ b/Source/VFS/source/Native/File.cpp @@ -2,8 +2,10 @@ #include #include #include + #include "File.h" #include "Host.h" +#include namespace nc::vfs::native { @@ -122,8 +124,7 @@ ssize_t File::Write(const void *_buf, size_t _size) const ssize_t ret = write(m_FD, _buf, _size); if( ret >= 0 ) { - if( m_Position + ret > m_Size ) - m_Size = m_Position + ret; + m_Size = std::max(m_Position + ret, m_Size); m_Position += ret; return ret; } diff --git a/Source/VFS/source/Native/Host.mm b/Source/VFS/source/Native/Host.mm index d500e0e5b..e35431670 100644 --- a/Source/VFS/source/Native/Host.mm +++ b/Source/VFS/source/Native/Host.mm @@ -44,7 +44,7 @@ [[nodiscard]] static const char *Junction() { return ""; } - bool operator==(const VFSNativeHostConfiguration &) const { return true; } + bool operator==(const VFSNativeHostConfiguration & /*unused*/) const { return true; } }; VFSMeta NativeHost::Meta() @@ -165,7 +165,7 @@ auto cb_param = [&](const Fetching::CallbackParams &_params) { fill(next_entry_index++, _params); }; if( need_to_add_dot_dot ) { - Fetching::ReadSingleEntryAttributesByPath(io, path.c_str(), cb_param); + Fetching::ReadSingleEntryAttributesByPath(io, path, cb_param); listing_source.filenames[0] = ".."; } diff --git a/Source/VFS/source/NetDropbox/Authenticator.mm b/Source/VFS/source/NetDropbox/Authenticator.mm index 8704ab1cb..4d41e8d3a 100644 --- a/Source/VFS/source/NetDropbox/Authenticator.mm +++ b/Source/VFS/source/NetDropbox/Authenticator.mm @@ -137,7 +137,7 @@ void PerformRequest(const Request &_request, std::string TokenMangler::FromMangledRefreshToken(std::string_view _token) noexcept { - if( IsMangledRefreshToken(_token) == false ) + if( !IsMangledRefreshToken(_token) ) return {}; _token.remove_prefix(std::string_view(refresh_token_tag).length()); return std::string(_token); diff --git a/Source/VFS/source/NetDropbox/Host.mm b/Source/VFS/source/NetDropbox/Host.mm index 3ff6f3991..ca36bca5f 100644 --- a/Source/VFS/source/NetDropbox/Host.mm +++ b/Source/VFS/source/NetDropbox/Host.mm @@ -299,7 +299,7 @@ static VFSNetDropboxHostConfiguration Compose(const std::string &_account, if( path.back() == '/' ) // dropbox doesn't like trailing slashes path.pop_back(); - std::string cursor_token = ""; + std::string cursor_token; do { NSMutableURLRequest *const req = [[NSMutableURLRequest alloc] initWithURL:cursor_token.empty() ? api::ListFolder : api::ListFolderContinue]; @@ -360,7 +360,7 @@ static VFSNetDropboxHostConfiguration Compose(const std::string &_account, if( path.back() == '/' ) // dropbox doesn't like trailing slashes path.pop_back(); - std::string cursor_token = ""; + std::string cursor_token; using nc::base::variable_container; ListingInput listing_source; diff --git a/Source/VFS/source/NetFTP/File.cpp b/Source/VFS/source/NetFTP/File.cpp index e87c6af11..763d76742 100644 --- a/Source/VFS/source/NetFTP/File.cpp +++ b/Source/VFS/source/NetFTP/File.cpp @@ -7,6 +7,8 @@ #include #include +#include + namespace nc::vfs::ftp { File::File(std::string_view _relative_path, std::shared_ptr _host) : VFSFile(_relative_path, _host) @@ -277,7 +279,7 @@ ssize_t File::Write(const void *_buf, size_t _size) } } - if( error == true ) + if( error ) return VFSError::FromErrno(EIO); m_FilePos += m_WriteBuf.Consumed(); @@ -337,8 +339,7 @@ off_t File::Seek(off_t _off, int _basis) if( req_pos < 0 ) return VFSError::InvalidCall; - if( req_pos > static_cast(m_FileSize) ) - req_pos = static_cast(m_FileSize); + req_pos = std::min(req_pos, static_cast(m_FileSize)); m_FilePos = req_pos; diff --git a/Source/VFS/source/NetFTP/Host.cpp b/Source/VFS/source/NetFTP/Host.cpp index 598d444fa..4f067a3b6 100644 --- a/Source/VFS/source/NetFTP/Host.cpp +++ b/Source/VFS/source/NetFTP/Host.cpp @@ -69,7 +69,7 @@ FTPHost::FTPHost(const std::string &_serv_url, const std::string &_start_dir, long _port, bool _active) - : Host(_serv_url.c_str(), nullptr, UniqueTag), m_Cache(std::make_unique()), + : Host(_serv_url, nullptr, UniqueTag), m_Cache(std::make_unique()), m_Configuration(ComposeConfiguration(_serv_url, _user, _passwd, _start_dir, _port, _active)) { const int rc = DoInit(); @@ -78,7 +78,7 @@ FTPHost::FTPHost(const std::string &_serv_url, } FTPHost::FTPHost(const VFSConfiguration &_config) - : Host(_config.Get().server_url.c_str(), nullptr, UniqueTag), + : Host(_config.Get().server_url, nullptr, UniqueTag), m_Cache(std::make_unique()), m_Configuration(_config) { const int rc = DoInit(); @@ -153,7 +153,7 @@ int FTPHost::DownloadAndCacheListing(CURLInstance *_inst, int FTPHost::DownloadListing(CURLInstance *_inst, const char *_path, std::string &_buffer, - const VFSCancelChecker &_cancel_checker) + const VFSCancelChecker &_cancel_checker) const { Log::Trace("FTPHost::DownloadListing({}, {}) called", static_cast(_inst), _path); if( _path == nullptr || _path[0] != '/' ) @@ -163,7 +163,7 @@ int FTPHost::DownloadListing(CURLInstance *_inst, if( path.back() != '/' ) path += '/'; - const std::string request = BuildFullURLString(path.c_str()); + const std::string request = BuildFullURLString(path); Log::Trace("Request: {}", request); std::string response; @@ -381,7 +381,7 @@ int FTPHost::CreateFile(std::string_view _path, int FTPHost::Unlink(std::string_view _path, [[maybe_unused]] const VFSCancelChecker &_cancel_checker) { const std::filesystem::path path = _path; - if( path.is_absolute() == false || path.native().back() == '/' ) + if( !path.is_absolute() || path.native().back() == '/' ) return VFSError::InvalidCall; const std::filesystem::path parent_path = utility::PathManip::EnsureTrailingSlash(path.parent_path()); @@ -424,7 +424,7 @@ int FTPHost::CreateDirectory(std::string_view _path, [[maybe_unused]] const VFSCancelChecker &_cancel_checker) { const std::filesystem::path path = EnsureNoTrailingSlash(std::string(_path)); - if( path.is_absolute() == false || path == "/" ) + if( !path.is_absolute() || path == "/" ) return VFSError::InvalidCall; const std::filesystem::path parent_path = utility::PathManip::EnsureTrailingSlash(path.parent_path()); @@ -465,7 +465,7 @@ int FTPHost::CreateDirectory(std::string_view _path, int FTPHost::RemoveDirectory(std::string_view _path, [[maybe_unused]] const VFSCancelChecker &_cancel_checker) { const std::filesystem::path path = EnsureNoTrailingSlash(std::string(_path)); - if( path.is_absolute() == false ) + if( !path.is_absolute() ) return VFSError::InvalidCall; const std::filesystem::path parent_path = utility::PathManip::EnsureTrailingSlash(path.parent_path()); @@ -507,7 +507,7 @@ int FTPHost::Rename(std::string_view _old_path, { const std::filesystem::path old_path = EnsureNoTrailingSlash(std::string(_old_path)); const std::filesystem::path new_path = EnsureNoTrailingSlash(std::string(_new_path)); - if( old_path.is_absolute() == false || new_path.is_absolute() == false ) + if( !old_path.is_absolute() || !new_path.is_absolute() ) return VFSError::InvalidCall; const std::filesystem::path old_parent_path = utility::PathManip::EnsureTrailingSlash(old_path.parent_path()); @@ -668,7 +668,7 @@ void FTPHost::BasicOptsSetup(CURLInstance *_inst) _inst->EasySetOpt(CURLOPT_PASSWORD, Config().passwd.c_str()); if( Config().port > 0 ) _inst->EasySetOpt(CURLOPT_PORT, Config().port); - if( Config().active == true ) + if( Config().active ) _inst->EasySetOpt(CURLOPT_FTPPORT, "-"); // TODO: SSL support diff --git a/Source/VFS/source/NetFTP/Host.h b/Source/VFS/source/NetFTP/Host.h index 80ab43667..cd858f0fe 100644 --- a/Source/VFS/source/NetFTP/Host.h +++ b/Source/VFS/source/NetFTP/Host.h @@ -97,7 +97,7 @@ class FTPHost final : public Host int DownloadListing(ftp::CURLInstance *_inst, const char *_path, std::string &_buffer, - const VFSCancelChecker &_cancel_checker); + const VFSCancelChecker &_cancel_checker) const; void InformDirectoryChanged(const std::string &_dir_wth_sl); diff --git a/Source/VFS/source/NetFTP/Internals.cpp b/Source/VFS/source/NetFTP/Internals.cpp index 289557a3b..2ab336ce6 100644 --- a/Source/VFS/source/NetFTP/Internals.cpp +++ b/Source/VFS/source/NetFTP/Internals.cpp @@ -216,14 +216,14 @@ CURLInstance::~CURLInstance() curl_multi_cleanup(curlm); } -CURLcode CURLInstance::PerformEasy() +CURLcode CURLInstance::PerformEasy() const { Log::Trace("CURLInstance::PerformEasy() called"); assert(!IsAttached()); return curl_easy_perform(curl); } -CURLcode CURLInstance::PerformMulti() +CURLcode CURLInstance::PerformMulti() const { int still_running = 0; do { diff --git a/Source/VFS/source/NetFTP/Internals.h b/Source/VFS/source/NetFTP/Internals.h index 9ee383bab..73fb2204f 100644 --- a/Source/VFS/source/NetFTP/Internals.h +++ b/Source/VFS/source/NetFTP/Internals.h @@ -34,8 +34,8 @@ struct CURLInstance { bool IsAttached() const { return attached; } CURLMcode Attach(); CURLMcode Detach(); - CURLcode PerformEasy(); - CURLcode PerformMulti(); + CURLcode PerformEasy() const; + CURLcode PerformMulti() const; void EasySetupProgFunc(); // after this call client code can set/change prog_func, that will be // called upon curl work and thus control it's flow diff --git a/Source/VFS/source/NetSFTP/File.cpp b/Source/VFS/source/NetSFTP/File.cpp index c45e4a610..e978ba4d0 100644 --- a/Source/VFS/source/NetSFTP/File.cpp +++ b/Source/VFS/source/NetSFTP/File.cpp @@ -2,7 +2,9 @@ #include "File.h" #include #include + #include "SFTPHost.h" +#include namespace nc::vfs::sftp { @@ -135,8 +137,7 @@ ssize_t File::Write(const void *_buf, size_t _size) const ssize_t rc = libssh2_sftp_write(m_Handle, static_cast(_buf), _size); if( rc >= 0 ) { - if( m_Position + rc > m_Size ) - m_Size = m_Position + rc; + m_Size = std::max(m_Position + rc, m_Size); m_Position += rc; return rc; } diff --git a/Source/VFS/source/NetSFTP/SFTPHost.cpp b/Source/VFS/source/NetSFTP/SFTPHost.cpp index 2d8201915..3c534aa4b 100644 --- a/Source/VFS/source/NetSFTP/SFTPHost.cpp +++ b/Source/VFS/source/NetSFTP/SFTPHost.cpp @@ -60,13 +60,13 @@ bool SFTPHost::Connection::Alive() const struct SFTPHost::AutoConnectionReturn // classic RAII stuff to prevent connections leaking in // operations { - inline AutoConnectionReturn(std::unique_ptr &_conn, SFTPHost *_this) : m_Conn(_conn), m_This(_this) + AutoConnectionReturn(std::unique_ptr &_conn, SFTPHost *_this) : m_Conn(_conn), m_This(_this) { assert(_conn != nullptr); assert(_this != nullptr); } - inline ~AutoConnectionReturn() { m_This->ReturnConnection(std::move(m_Conn)); } + ~AutoConnectionReturn() { m_This->ReturnConnection(std::move(m_Conn)); } std::unique_ptr &m_Conn; SFTPHost *m_This; }; @@ -115,7 +115,7 @@ VFSMeta SFTPHost::Meta() } SFTPHost::SFTPHost(const VFSConfiguration &_config) - : Host(_config.Get().server_url.c_str(), nullptr, UniqueTag), m_Config(_config) + : Host(_config.Get().server_url, nullptr, UniqueTag), m_Config(_config) { const int rc = DoInit(); if( rc < 0 ) @@ -146,7 +146,7 @@ SFTPHost::SFTPHost(const std::string &_serv_url, const std::string &_keypath, long _port, const std::string &_home) - : Host(_serv_url.c_str(), nullptr, UniqueTag), + : Host(_serv_url, nullptr, UniqueTag), m_Config(ComposeConfguration(_serv_url, _user, _passwd, _keypath, _port, _home)) { const int rc = DoInit(); @@ -657,7 +657,7 @@ int SFTPHost::Rename(std::string_view _old_path, std::string_view _new_path, con const auto rename_vfs_rc = VFSErrorForConnection(*conn); if( rename_rc == LIBSSH2_ERROR_SFTP_PROTOCOL && libssh2_sftp_last_error(conn->sftp) == LIBSSH2_FX_FAILURE && - Exists(_new_path, _cancel_checker) == true ) { + Exists(_new_path, _cancel_checker) ) { // it's likely that a SSH server forbids a direct usage of overwriting semantics // lets try to fallback to "rm + mv" scheme const auto unlink_rc = Unlink(_new_path, _cancel_checker); diff --git a/Source/VFS/source/NetWebDAV/CURLConnection.cpp b/Source/VFS/source/NetWebDAV/CURLConnection.cpp index a812baf1d..5d67e92c1 100644 --- a/Source/VFS/source/NetWebDAV/CURLConnection.cpp +++ b/Source/VFS/source/NetWebDAV/CURLConnection.cpp @@ -225,7 +225,7 @@ Connection::BlockRequestResult CURLConnection::PerformBlockingRequest() int CURLConnection::ReadBodyUpToSize(size_t _target) { - if( m_MultiHandle == nullptr || m_MultiHandleAttached == false ) + if( m_MultiHandle == nullptr || !m_MultiHandleAttached ) return VFSError::InvalidCall; const auto multi = m_MultiHandle; @@ -276,7 +276,7 @@ size_t CURLConnection::ReadFromWriteBuffer(void *_ptr, size_t _size, size_t _nme int CURLConnection::WriteBodyUpToSize(size_t _target) { - if( m_MultiHandle == nullptr || m_MultiHandleAttached == false ) + if( m_MultiHandle == nullptr || !m_MultiHandleAttached ) return VFSError::InvalidCall; const auto multi = m_MultiHandle; @@ -285,7 +285,7 @@ int CURLConnection::WriteBodyUpToSize(size_t _target) if( _target == AbortBodyWrite ) SetProgreessCallback([](long, long, long, long) { return false; }); - if( m_Paused == true ) { + if( m_Paused ) { curl_easy_pause(m_EasyHandle, CURLPAUSE_CONT); m_Paused = false; } @@ -314,7 +314,7 @@ int CURLConnection::WriteBodyUpToSize(size_t _target) const size_t target_buffer_size = m_RequestBody.Size() - _target; - if( m_Paused == true ) { + if( m_Paused ) { curl_easy_pause(m_EasyHandle, CURLPAUSE_CONT); m_Paused = false; } diff --git a/Source/VFS/source/NetWebDAV/WebDAVHost.cpp b/Source/VFS/source/NetWebDAV/WebDAVHost.cpp index 8de204bcc..f70e6d1b2 100644 --- a/Source/VFS/source/NetWebDAV/WebDAVHost.cpp +++ b/Source/VFS/source/NetWebDAV/WebDAVHost.cpp @@ -41,14 +41,14 @@ WebDAVHost::WebDAVHost(const std::string &_serv_url, const std::string &_path, bool _https, int _port) - : VFSHost(_serv_url.c_str(), nullptr, UniqueTag), + : VFSHost(_serv_url, nullptr, UniqueTag), m_Configuration(ComposeConfiguration(_serv_url, _user, _passwd, _path, _https, _port)) { Init(); } WebDAVHost::WebDAVHost(const VFSConfiguration &_config) - : VFSHost(_config.Get().server_url.c_str(), nullptr, UniqueTag), m_Configuration(_config) + : VFSHost(_config.Get().server_url, nullptr, UniqueTag), m_Configuration(_config) { Init(); } diff --git a/Source/VFS/source/PS/Host.mm b/Source/VFS/source/PS/Host.mm index 6447b6785..7e4153d41 100644 --- a/Source/VFS/source/PS/Host.mm +++ b/Source/VFS/source/PS/Host.mm @@ -255,7 +255,7 @@ static void print_argv_of_pid(int pid, std::string &_out) [[nodiscard]] static const char *Junction() { return ""; } - bool operator==(const VFSPSHostConfiguration &) const { return true; } + bool operator==(const VFSPSHostConfiguration & /*unused*/) const { return true; } [[nodiscard]] static const char *VerboseJunction() { return "[psfs]:"; } }; @@ -367,7 +367,7 @@ static void print_argv_of_pid(int pid, std::string &_out) void PSHost::EnsureUpdateRunning() { - if( m_UpdateStarted == false ) { + if( !m_UpdateStarted ) { m_UpdateStarted = true; UpdateCycle(); } @@ -489,9 +489,7 @@ static void print_argv_of_pid(int pid, std::string &_out) [[maybe_unused]] unsigned long _flags, [[maybe_unused]] const VFSCancelChecker &_cancel_checker) { - if( _path.empty() || _path != "/" ) - return false; - return true; + return !(_path.empty() || _path != "/"); } int PSHost::CreateFile(std::string_view _path, @@ -576,7 +574,7 @@ static void print_argv_of_pid(int pid, std::string &_out) return true; } -HostDirObservationTicket PSHost::ObserveDirectoryChanges(std::string_view, std::function _handler) +HostDirObservationTicket PSHost::ObserveDirectoryChanges(std::string_view /*_path*/, std::function _handler) { // currently we don't care about _path, since this fs has only one directory - root auto ticket = m_LastTicket++; diff --git a/Source/VFS/source/SearchForFiles.cpp b/Source/VFS/source/SearchForFiles.cpp index 2d79f7bfa..6225fb263 100644 --- a/Source/VFS/source/SearchForFiles.cpp +++ b/Source/VFS/source/SearchForFiles.cpp @@ -127,7 +127,7 @@ void SearchForFiles::AsyncProc(const char *_from_path, VFSHost &_in_host) NotifyLookingIn(path.Path().c_str(), *path.Host()); - path.Host()->IterateDirectoryListing(path.Path().c_str(), [&](const VFSDirEnt &_dirent) { + path.Host()->IterateDirectoryListing(path.Path(), [&](const VFSDirEnt &_dirent) { if( m_Queue.IsStopped() ) return false; @@ -151,20 +151,20 @@ void SearchForFiles::ProcessDirent(const char *_full_path, bool failed_filtering = false; // Filter by being a directory - if( failed_filtering == false && _dirent.type == VFSDirEnt::Dir && (m_SearchOptions & Options::SearchForDirs) == 0 ) + if( !failed_filtering && _dirent.type == VFSDirEnt::Dir && (m_SearchOptions & Options::SearchForDirs) == 0 ) failed_filtering = true; // Filter by being a reg or link - if( failed_filtering == false && (_dirent.type == VFSDirEnt::Reg || _dirent.type == VFSDirEnt::Link) && + if( !failed_filtering && (_dirent.type == VFSDirEnt::Reg || _dirent.type == VFSDirEnt::Link) && (m_SearchOptions & Options::SearchForFiles) == 0 ) failed_filtering = true; // Filter by filename - if( failed_filtering == false && !m_FilterName.IsEmpty() && !FilterByFilename(_dirent.name) ) + if( !failed_filtering && !m_FilterName.IsEmpty() && !FilterByFilename(_dirent.name) ) failed_filtering = true; // Filter by filesize - if( failed_filtering == false && m_FilterSize ) { + if( !failed_filtering && m_FilterSize ) { if( _dirent.type == VFSDirEnt::Reg ) { VFSStat st; if( _in_host.Stat(_full_path, st, 0, nullptr) == 0 ) { @@ -180,12 +180,12 @@ void SearchForFiles::ProcessDirent(const char *_full_path, // Filter by file content CFRange content_pos{-1, 0}; - if( failed_filtering == false && m_FilterContent ) { + if( !failed_filtering && m_FilterContent ) { if( _dirent.type != VFSDirEnt::Reg || !FilterByContent(_full_path, _in_host, content_pos) ) failed_filtering = true; } - if( failed_filtering == false ) + if( !failed_filtering ) ProcessValidEntry(_full_path, _dir_path, _dirent, _in_host, content_pos); if( m_SearchOptions & Options::GoIntoSubDirs ) @@ -238,10 +238,10 @@ bool SearchForFiles::FilterByContent(const char *_full_path, VFSHost &_in_host, const auto result = sif.Search([this] { return m_Queue.IsStopped(); }); if( result.response == SearchInFile::Response::Found ) { _r = CFRangeMake(result.location->offset, result.location->bytes_len); - return m_FilterContent->not_containing == false; + return !m_FilterContent->not_containing; } if( result.response == SearchInFile::Response::NotFound ) { - return m_FilterContent->not_containing == true; + return m_FilterContent->not_containing; } return false; @@ -264,7 +264,7 @@ void SearchForFiles::ProcessValidEntry([[maybe_unused]] const char *_full_path, bool SearchForFiles::IsRunning() const noexcept { - return m_Queue.Empty() == false; + return !m_Queue.Empty(); } } // namespace nc::vfs diff --git a/Source/VFS/source/SearchInFile.cpp b/Source/VFS/source/SearchInFile.cpp index b670a9320..bff62ceb8 100644 --- a/Source/VFS/source/SearchInFile.cpp +++ b/Source/VFS/source/SearchInFile.cpp @@ -31,7 +31,7 @@ SearchInFile::~SearchInFile() void SearchInFile::MoveCurrentPosition(uint64_t _pos) { const auto is_valid = (m_File.FileSize() > 0 && _pos < m_File.FileSize()) || _pos == 0; - if( is_valid == false ) + if( !is_valid ) throw std::out_of_range("SearchInFile::MoveCurrentPosition: invalid index"); ; @@ -184,7 +184,7 @@ void SearchInFile::SetSearchOptions(Options _options) m_SearchOptions = _options; } -SearchInFile::Options SearchInFile::SearchOptions() +SearchInFile::Options SearchInFile::SearchOptions() const { return m_SearchOptions; } diff --git a/Source/VFS/source/VFSConfiguration.cpp b/Source/VFS/source/VFSConfiguration.cpp index 34373cb9e..318311778 100644 --- a/Source/VFS/source/VFSConfiguration.cpp +++ b/Source/VFS/source/VFSConfiguration.cpp @@ -2,9 +2,9 @@ #include "../include/VFS/VFSConfiguration.h" struct VFSConfigurationDummyModel { - [[nodiscard]] static inline const char *Tag() { return ""; } - [[nodiscard]] static inline const char *Junction() { return ""; } - inline bool operator==(const VFSConfigurationDummyModel &) const { return false; } + [[nodiscard]] static const char *Tag() { return ""; } + [[nodiscard]] static const char *Junction() { return ""; } + bool operator==(const VFSConfigurationDummyModel & /*unused*/) const { return false; } }; const char *VFSConfiguration::Tag() const diff --git a/Source/VFS/source/VFSEasyOps.mm b/Source/VFS/source/VFSEasyOps.mm index 7dd9ac7b2..d812c6695 100644 --- a/Source/VFS/source/VFSEasyOps.mm +++ b/Source/VFS/source/VFSEasyOps.mm @@ -403,9 +403,7 @@ int VFSCompareNodes(const std::filesystem::path &_file1_full_path, _file1_host->IterateDirectoryListing(_file1_full_path.c_str(), [&](const VFSDirEnt &_dirent) { const int ret = VFSCompareNodes( _file1_full_path / _dirent.name, _file1_host, _file2_full_path / _dirent.name, _file2_host, _result); - if( ret != 0 ) - return false; - return true; + return ret == 0; }); } return 0; @@ -419,7 +417,7 @@ int VFSCompareNodes(const std::filesystem::path &_file1_full_path, const std::function &_cancel_checker) { VFSFilePtr vfs_file; - if( _host.CreateFile(_vfs_filepath.c_str(), vfs_file, _cancel_checker) < 0 ) + if( _host.CreateFile(_vfs_filepath, vfs_file, _cancel_checker) < 0 ) return std::nullopt; if( vfs_file->Open(VFSFlags::OF_Read, _cancel_checker) < 0 ) @@ -480,7 +478,7 @@ int VFSCompareNodes(const std::filesystem::path &_file1_full_path, auto vfs_dirpath = EnsureNoTrailingSlash(_vfs_dirpath); VFSStat st_src_dir; - const auto src_dir_stat_rc = _host.Stat(vfs_dirpath.c_str(), st_src_dir, VFSFlags::F_NoFollow, _cancel_checker); + const auto src_dir_stat_rc = _host.Stat(vfs_dirpath, st_src_dir, VFSFlags::F_NoFollow, _cancel_checker); if( src_dir_stat_rc != VFSError::Ok ) return {}; @@ -505,7 +503,7 @@ int VFSCompareNodes(const std::filesystem::path &_file1_full_path, auto full_entry_path = current.src_full_path + "/" + _dirent.name; VFSStat st; - const auto stat_rc = _host.Stat(full_entry_path.c_str(), st, VFSFlags::F_NoFollow, _cancel_checker); + const auto stat_rc = _host.Stat(full_entry_path, st, VFSFlags::F_NoFollow, _cancel_checker); if( stat_rc != VFSError::Ok ) return false; @@ -517,7 +515,7 @@ int VFSCompareNodes(const std::filesystem::path &_file1_full_path, return true; }; - const auto rc = _host.IterateDirectoryListing(current.src_full_path.c_str(), block); + const auto rc = _host.IterateDirectoryListing(current.src_full_path, block); if( rc != VFSError::Ok ) return {}; } @@ -538,7 +536,7 @@ static int ExtractRegFile(const std::string &_vfs_path, const std::function &_cancel_checker) { VFSFilePtr vfs_file; - const auto create_file_rc = _host.CreateFile(_vfs_path.c_str(), vfs_file, _cancel_checker); + const auto create_file_rc = _host.CreateFile(_vfs_path, vfs_file, _cancel_checker); if( create_file_rc != VFSError::Ok ) return create_file_rc; @@ -635,7 +633,7 @@ static bool ExtractEntry(const TraversedFSEntry &_entry, const auto &entry = *i; - if( ExtractEntry(entry, _host, base_path, _cancel_checker) != true ) + if( !ExtractEntry(entry, _host, base_path, _cancel_checker) ) return {}; } diff --git a/Source/VFS/source/VFSError.mm b/Source/VFS/source/VFSError.mm index 762316170..b16220d0c 100644 --- a/Source/VFS/source/VFSError.mm +++ b/Source/VFS/source/VFSError.mm @@ -318,7 +318,7 @@ int FromLibarchive(int _errno) int FromCFNetwork(int _errno) { - return int(_errno - 2500000); + return (_errno - 2500000); } int FromNSError(NSError *_err) diff --git a/Source/VFS/source/VFSFile.cpp b/Source/VFS/source/VFSFile.cpp index eaf234b4e..21dfc5565 100644 --- a/Source/VFS/source/VFSFile.cpp +++ b/Source/VFS/source/VFSFile.cpp @@ -60,7 +60,7 @@ bool VFSFile::IsOpened() const return false; } -int VFSFile::Open(unsigned long, const VFSCancelChecker &) +int VFSFile::Open(unsigned long /*unused*/, const VFSCancelChecker & /*unused*/) { return SetLastError(VFSError::NotSupported); } @@ -68,7 +68,7 @@ int VFSFile::Close() { return SetLastError(VFSError::NotSupported); } -off_t VFSFile::Seek(off_t, int) +off_t VFSFile::Seek(off_t /*unused*/, int /*unused*/) { return SetLastError(VFSError::NotSupported); } diff --git a/Source/VFS/source/VFSSeqToRandomWrapper.cpp b/Source/VFS/source/VFSSeqToRandomWrapper.cpp index c10b17bf8..33713f99e 100644 --- a/Source/VFS/source/VFSSeqToRandomWrapper.cpp +++ b/Source/VFS/source/VFSSeqToRandomWrapper.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -248,8 +249,7 @@ off_t VFSSeqToRandomROWrapperFile::Seek(off_t _off, int _basis) if( req_pos < 0 ) return VFSError::InvalidCall; - if( req_pos > m_Backend->m_Size ) - req_pos = m_Backend->m_Size; + req_pos = std::min(req_pos, m_Backend->m_Size); m_Pos = req_pos; return m_Pos; diff --git a/Source/VFS/source/XAttr/xattr.cpp b/Source/VFS/source/XAttr/xattr.cpp index 1510e72dd..8fa43ba50 100644 --- a/Source/VFS/source/XAttr/xattr.cpp +++ b/Source/VFS/source/XAttr/xattr.cpp @@ -8,6 +8,8 @@ #include #include +#include + using namespace std::literals; namespace nc::vfs { @@ -50,10 +52,7 @@ static bool TurnOffBlockingMode(int _fd) noexcept return false; fcntl_ret = fcntl(_fd, F_SETFL, fcntl_ret & ~O_NONBLOCK); - if( fcntl_ret < 0 ) - return false; - - return true; + return fcntl_ret >= 0; } static int EnumerateAttrs(int _fd, std::vector> &_attrs) @@ -427,8 +426,7 @@ off_t XAttrFile::Seek(off_t _off, int _basis) if( req_pos < 0 ) return VFSError::InvalidCall; - if( req_pos > m_Size ) - req_pos = m_Size; + req_pos = std::min(req_pos, m_Size); m_Position = req_pos; return m_Position; diff --git a/Source/VFS/tests/VFSArchive_IT.mm b/Source/VFS/tests/VFSArchive_IT.mm index 1f68864f7..39d0ca41b 100644 --- a/Source/VFS/tests/VFSArchive_IT.mm +++ b/Source/VFS/tests/VFSArchive_IT.mm @@ -52,9 +52,7 @@ static int VFSCompareEntries(const std::filesystem::path &_file1_full_path, _file1_host->IterateDirectoryListing(_file1_full_path.c_str(), [&](const VFSDirEnt &_dirent) { const int ret = VFSCompareEntries( _file1_full_path / _dirent.name, _file1_host, _file2_full_path / _dirent.name, _file2_host, _result); - if( ret != 0 ) - return false; - return true; + return ret == 0; }); } return 0; @@ -123,10 +121,10 @@ static int VFSCompareEntries(const std::filesystem::path &_file1_full_path, const std::string &fn = filenames[std::rand() % filenames.size()]; VFSStat local_st; - REQUIRE(host->Stat(fn.c_str(), local_st, 0, nullptr) == 0); + REQUIRE(host->Stat(fn, local_st, 0, nullptr) == 0); VFSFilePtr file; - REQUIRE(host->CreateFile(fn.c_str(), file, nullptr) == 0); + REQUIRE(host->CreateFile(fn, file, nullptr) == 0); REQUIRE(file->Open(VFSFlags::OF_Read) == 0); std::this_thread::sleep_for(std::chrono::milliseconds(5)); auto d = file->ReadFile(); diff --git a/Source/VFS/tests/VFSFTP_IT.mm b/Source/VFS/tests/VFSFTP_IT.mm index f261e6edc..0acb352da 100644 --- a/Source/VFS/tests/VFSFTP_IT.mm +++ b/Source/VFS/tests/VFSFTP_IT.mm @@ -88,12 +88,12 @@ for( const auto &dir : std::vector{"/" + nc::base::UUID::Generate().ToString(), "/В лесу родилась елочка, В лесу она росла", "/北京市 >≥±§ 😱"} ) { - REQUIRE(host->CreateDirectory(dir.c_str(), 0755) == 0); - REQUIRE(host->IsDirectory(dir.c_str(), 0) == true); // cached - REQUIRE(shadowhost->IsDirectory(dir.c_str(), VFSFlags::F_ForceRefresh) == true); // non-cached - REQUIRE(host->RemoveDirectory(dir.c_str()) == 0); - REQUIRE(host->IsDirectory(dir.c_str(), 0) == false); // cached - REQUIRE(shadowhost->IsDirectory(dir.c_str(), VFSFlags::F_ForceRefresh) == false); // non-cached + REQUIRE(host->CreateDirectory(dir, 0755) == 0); + REQUIRE(host->IsDirectory(dir, 0) == true); // cached + REQUIRE(shadowhost->IsDirectory(dir, VFSFlags::F_ForceRefresh) == true); // non-cached + REQUIRE(host->RemoveDirectory(dir) == 0); + REQUIRE(host->IsDirectory(dir, 0) == false); // cached + REQUIRE(shadowhost->IsDirectory(dir, VFSFlags::F_ForceRefresh) == false); // non-cached } { @@ -137,9 +137,9 @@ for( const auto &dir : std::vector{ "/some / very / bad / filename", "/some/another/invalid/path", "not even an absolute path"} ) { - REQUIRE(host->CreateDirectory(dir.c_str(), 0755) != 0); - REQUIRE(host->IsDirectory(dir.c_str(), 0) == false); - REQUIRE(shadowhost->IsDirectory(dir.c_str(), VFSFlags::F_ForceRefresh) == false); // non-cached + REQUIRE(host->CreateDirectory(dir, 0755) != 0); + REQUIRE(host->IsDirectory(dir, 0) == false); + REQUIRE(shadowhost->IsDirectory(dir, VFSFlags::F_ForceRefresh) == false); // non-cached } } @@ -155,13 +155,13 @@ VFSStat stat; // if there's a trash from previous runs - remove it - if( host->Stat(fn2.c_str(), stat, 0) == 0 ) - REQUIRE(host->Unlink(fn2.c_str()) == 0); + if( host->Stat(fn2, stat, 0) == 0 ) + REQUIRE(host->Unlink(fn2) == 0); REQUIRE(VFSEasyCopyFile(fn1.c_str(), TestEnv().vfs_native, fn2.c_str(), host) == 0); - REQUIRE(host->Rename(fn2.c_str(), fn3.c_str()) == 0); - REQUIRE(host->Stat(fn3.c_str(), stat, 0) == 0); - REQUIRE(host->Unlink(fn3.c_str()) == 0); + REQUIRE(host->Rename(fn2, fn3) == 0); + REQUIRE(host->Stat(fn3, stat, 0) == 0); + REQUIRE(host->Unlink(fn3) == 0); if( host->Stat("/DirectoryName1", stat, 0) == 0 ) REQUIRE(host->RemoveDirectory("/DirectoryName1") == 0); @@ -322,7 +322,7 @@ static void WriteAll(VFSFile &_file, const std::span _bytes) }}; const auto deadline = std::chrono::system_clock::now() + std::chrono::seconds(1); - while( finished == false ) { + while( !finished ) { std::this_thread::sleep_for(std::chrono::milliseconds(10)); REQUIRE((std::chrono::system_clock::now() < deadline)); } diff --git a/Source/VFS/tests/VFSPS_IT.cpp b/Source/VFS/tests/VFSPS_IT.cpp index d39e7b66c..11f03a75e 100644 --- a/Source/VFS/tests/VFSPS_IT.cpp +++ b/Source/VFS/tests/VFSPS_IT.cpp @@ -39,7 +39,7 @@ TEST_CASE(PREFIX "can read info about kernel_task") const auto &kernel_task_listing_item = *it; VFSFilePtr file; - REQUIRE(host->CreateFile(kernel_task_listing_item.Path().c_str(), file, {}) == 0); + REQUIRE(host->CreateFile(kernel_task_listing_item.Path(), file, {}) == 0); REQUIRE(file->Open(Flags::OF_Read) == 0); const auto file_contents = file->ReadFile(); REQUIRE(file_contents != std::nullopt); diff --git a/Source/VFS/tests/VFSSFTP_Tests.mm b/Source/VFS/tests/VFSSFTP_Tests.mm index 04c9d7950..f8aaa6deb 100644 --- a/Source/VFS/tests/VFSSFTP_Tests.mm +++ b/Source/VFS/tests/VFSSFTP_Tests.mm @@ -677,7 +677,7 @@ static void TestUbuntu2004LayoutWithHost(SFTPHost &_host) auto host = hostForUbuntu2004_User2_RSA(); VFSFilePtr seq_file; - REQUIRE(host->CreateFile((host->HomeDir() + "/.ssh/authorized_keys").c_str(), seq_file, nullptr) == VFSError::Ok); + REQUIRE(host->CreateFile(host->HomeDir() + "/.ssh/authorized_keys", seq_file, nullptr) == VFSError::Ok); auto wrapper = std::make_shared(seq_file); REQUIRE(wrapper->Open(VFSFlags::OF_Read | VFSFlags::OF_ShLock, nullptr, nullptr) == VFSError::Ok); diff --git a/Source/VFSIcon/source/IconBuilderImpl.mm b/Source/VFSIcon/source/IconBuilderImpl.mm index 322eeee1e..e5011d6d1 100644 --- a/Source/VFSIcon/source/IconBuilderImpl.mm +++ b/Source/VFSIcon/source/IconBuilderImpl.mm @@ -25,7 +25,7 @@ IconBuilder::LookupResult IconBuilderImpl::LookupExistingIcon(const VFSListingItem &_item, int _icon_px_size) { - if( bool(_item) == false || _icon_px_size <= 0 ) { + if( !_item || _icon_px_size <= 0 ) { Log::Warn("LookupExistingIcon(): invalid lookup request"); return {}; } @@ -83,7 +83,7 @@ IconBuilder::BuildResult IconBuilderImpl::BuildRealIcon(const VFSListingItem &_item, int _icon_px_size, const CancelChecker &_cancel_checker) { - if( bool(_item) == false || _icon_px_size <= 0 ) { + if( !_item || _icon_px_size <= 0 ) { Log::Warn("BuildRealIcon(): invalid lookup request"); return {}; } @@ -129,7 +129,7 @@ return result; } else { - if( _item.Host()->ShouldProduceThumbnails() == false ) + if( !_item.Host()->ShouldProduceThumbnails() ) return {}; // special case for for bundles @@ -161,19 +161,19 @@ bool IconBuilderImpl::ShouldTryProducingQLThumbnailOnNativeFS(const VFSListingItem &_item) const { - return _item.IsDir() == false && _item.Size() > 0 && long(_item.Size()) < m_MaxFilesizeForThumbnailsOnNativeFS && + return !_item.IsDir() && _item.Size() > 0 && long(_item.Size()) < m_MaxFilesizeForThumbnailsOnNativeFS && _item.HasExtension() && m_ExtensionsWhitelist->AllowExtension(_item.Extension()); } bool IconBuilderImpl::ShouldTryProducingQLThumbnailOnVFS(const VFSListingItem &_item) const { - return _item.IsDir() == false && _item.Size() > 0 && long(_item.Size()) < m_MaxFilesizeForThumbnailsOnVFS && + return !_item.IsDir() && _item.Size() > 0 && long(_item.Size()) < m_MaxFilesizeForThumbnailsOnVFS && _item.HasExtension() && m_ExtensionsWhitelist->AllowExtension(_item.Extension()); } static bool MightBeBundle(const VFSListingItem &_item) { - if( _item.HasExtension() == false ) + if( !_item.HasExtension() ) return false; const auto extension = _item.Extension(); diff --git a/Source/VFSIcon/source/IconRepositoryImpl.mm b/Source/VFSIcon/source/IconRepositoryImpl.mm index 5543a640c..36d0b8c64 100644 --- a/Source/VFSIcon/source/IconRepositoryImpl.mm +++ b/Source/VFSIcon/source/IconRepositoryImpl.mm @@ -83,7 +83,7 @@ void IconRepositoryImpl::Unregister(SlotKey _key) { - if( IsValidSlot(_key) == false ) + if( !IsValidSlot(_key) ) return; const auto index = ToIndex(_key); auto &slot = m_Slots[index]; @@ -95,7 +95,7 @@ void IconRepositoryImpl::ScheduleIconProduction(SlotKey _key, const VFSListingItem &_item) { - if( IsValidSlot(_key) == false ) + if( !IsValidSlot(_key) ) return; auto slot_index = ToIndex(_key); @@ -104,7 +104,7 @@ if( slot.production != nullptr ) return; // there is an already ongoing production for this slot - if( slot.state == SlotState::Production && HasFileChanged(slot, _item) == false ) + if( slot.state == SlotState::Production && !HasFileChanged(slot, _item) ) return; // nothing to do if( m_ProductionQueue->QueueLength() >= m_MaxQueueLength ) @@ -120,12 +120,12 @@ slot.state = SlotState::Production; auto work_block = [this, slot_index, context] { - if( context->must_stop == true ) + if( context->must_stop ) return; ProduceRealIcon(*context); - if( context->must_stop == true ) + if( context->must_stop ) return; auto commit_block = [this, slot_index, context] { CommitProductionResult(slot_index, *context); }; @@ -143,7 +143,7 @@ void IconRepositoryImpl::CommitProductionResult(int _slot_index, WorkerContext &_ctx) { - if( _ctx.must_stop == true ) + if( _ctx.must_stop ) return; auto &slot = m_Slots[_slot_index]; @@ -152,7 +152,7 @@ slot.production.reset(); const bool updated = RefreshImages(slot, _ctx); - if( updated == true ) { + if( updated ) { auto callback = m_IconUpdatedCallback; if( callback && *callback ) (*callback)(FromIndex(_slot_index), slot.icon); @@ -178,7 +178,7 @@ int IconRepositoryImpl::AllocateSlot() { - if( m_FreeSlotsIndices.empty() == false ) { + if( !m_FreeSlotsIndices.empty() ) { const auto free_slot_index = m_FreeSlotsIndices.top(); m_FreeSlotsIndices.pop(); return free_slot_index; diff --git a/Source/VFSIcon/source/IconRepositoryImplBase.mm b/Source/VFSIcon/source/IconRepositoryImplBase.mm index 96cdba140..514f9504d 100644 --- a/Source/VFSIcon/source/IconRepositoryImplBase.mm +++ b/Source/VFSIcon/source/IconRepositoryImplBase.mm @@ -65,7 +65,7 @@ auto lock = std::lock_guard{m_AwaitingLock}; - if( m_Awaiting.empty() == false ) { + if( !m_Awaiting.empty() ) { auto new_client_block = std::move(m_Awaiting.front()); m_Awaiting.pop(); DispatchForAsynExecution(std::move(new_client_block)); diff --git a/Source/VFSIcon/source/QLThumbnailsCacheImpl.mm b/Source/VFSIcon/source/QLThumbnailsCacheImpl.mm index 7ab4cd08d..057efdcc4 100644 --- a/Source/VFSIcon/source/QLThumbnailsCacheImpl.mm +++ b/Source/VFSIcon/source/QLThumbnailsCacheImpl.mm @@ -7,7 +7,7 @@ namespace nc::vfsicon { -static inline void hash_combine(size_t &) +static inline void hash_combine(size_t & /*unused*/) { } @@ -59,7 +59,7 @@ static inline void hash_combine(size_t &seed, const T &v, Rest... rest) hash = _key.hash; } -inline QLThumbnailsCacheImpl::Key::Key(std::string_view _path, int _px_size, no_ownership_tag) +inline QLThumbnailsCacheImpl::Key::Key(std::string_view _path, int _px_size, no_ownership_tag /*unused*/) { px_size = _px_size; path = _path; @@ -194,12 +194,12 @@ static inline void hash_combine(size_t &seed, const T &v, Rest... rest) const std::optional &_hint) { Log::Trace("CheckCacheAndUpdateIfNeeded(): called for '{}' ({}px)", _filename, _px_size); - if( _info.is_in_work.test_and_set() == false ) { + if( !_info.is_in_work.test_and_set() ) { auto clear_lock = at_scope_end([&] { _info.is_in_work.clear(); }); // we're first to take control of this item const auto file_state_hint = _hint ? _hint : ReadFileState(_filename); - if( file_state_hint.has_value() == false ) { + if( !file_state_hint.has_value() ) { Log::Warn("CheckCacheAndUpdateIfNeeded(): can't get a file state hint for '{}'", _filename); return; // can't proceed without information about the file. } diff --git a/Source/VFSIcon/source/QLVFSThumbnailsCacheImpl.mm b/Source/VFSIcon/source/QLVFSThumbnailsCacheImpl.mm index 46b032c27..1a9da81ac 100644 --- a/Source/VFSIcon/source/QLVFSThumbnailsCacheImpl.mm +++ b/Source/VFSIcon/source/QLVFSThumbnailsCacheImpl.mm @@ -57,11 +57,11 @@ CGSize _sz) { auto data = ReadEntireFile(_path, _host); - if( data.has_value() == false ) + if( !data.has_value() ) return nil; auto placement_result = m_TempStorage->PlaceWithExtension(data->data(), data->size(), _ext); - if( placement_result.has_value() == false ) + if( !placement_result.has_value() ) return nil; return ProduceThumbnailForTempFile(placement_result->Path(), _sz); @@ -69,7 +69,7 @@ std::string QLVFSThumbnailsCacheImpl::MakeKey(const std::string &_file_path, VFSHost &_host, int _px_size) { - auto key = _host.MakePathVerbose(_file_path.c_str()); + auto key = _host.MakePathVerbose(_file_path); key += "\x01"; key += std::to_string(_px_size); return key; @@ -96,7 +96,7 @@ { VFSFilePtr vfs_file; - if( _host.CreateFile(_path.c_str(), vfs_file, nullptr) < 0 ) + if( _host.CreateFile(_path, vfs_file, nullptr) < 0 ) return std::nullopt; if( vfs_file->Open(VFSFlags::OF_Read) < 0 ) diff --git a/Source/VFSIcon/source/VFSBundleIconsCacheImpl.mm b/Source/VFSIcon/source/VFSBundleIconsCacheImpl.mm index 4d8ee967e..1713b3cf9 100644 --- a/Source/VFSIcon/source/VFSBundleIconsCacheImpl.mm +++ b/Source/VFSIcon/source/VFSBundleIconsCacheImpl.mm @@ -49,14 +49,14 @@ std::string VFSBundleIconsCacheImpl::MakeKey(const std::string &_file_path, VFSHost &_host) { - return _host.MakePathVerbose(_file_path.c_str()); + return _host.MakePathVerbose(_file_path); } static std::optional> ReadEntireFile(const std::string &_path, VFSHost &_host) { VFSFilePtr vfs_file; - if( _host.CreateFile(_path.c_str(), vfs_file, nullptr) < 0 ) + if( _host.CreateFile(_path, vfs_file, nullptr) < 0 ) return std::nullopt; if( vfs_file->Open(VFSFlags::OF_Read) < 0 ) @@ -67,7 +67,7 @@ static NSData *ToTempNSData(const std::optional> &_data) { - if( _data.has_value() == false ) + if( !_data.has_value() ) return nil; return [NSData dataWithBytesNoCopy:const_cast(reinterpret_cast(_data->data())) length:_data->size() @@ -77,7 +77,7 @@ static NSDictionary *ReadDictionary(const std::string &_path, VFSHost &_host) { const auto data = ReadEntireFile(_path, _host); - if( data.has_value() == false ) + if( !data.has_value() ) return nil; const auto objc_data = ToTempNSData(data); @@ -94,7 +94,7 @@ static NSImage *ReadImageFromFile(const std::string &_path, VFSHost &_host) { const auto data = ReadEntireFile(_path, _host); - if( data.has_value() == false ) + if( !data.has_value() ) return nil; const auto objc_data = ToTempNSData(data); diff --git a/Source/VFSIcon/source/WorkspaceIconsCacheImpl.mm b/Source/VFSIcon/source/WorkspaceIconsCacheImpl.mm index 6329483b5..1a2c3db15 100644 --- a/Source/VFSIcon/source/WorkspaceIconsCacheImpl.mm +++ b/Source/VFSIcon/source/WorkspaceIconsCacheImpl.mm @@ -56,12 +56,12 @@ void WorkspaceIconsCacheImpl::UpdateIfNeeded(const std::string &_file_path, Info &_info) { - if( _info.is_in_work.test_and_set() == false ) { + if( !_info.is_in_work.test_and_set() ) { auto clear_lock = at_scope_end([&] { _info.is_in_work.clear(); }); // we're first to take control of this item const auto file_state_hint = m_FileStateReader.ReadState(_file_path); - if( file_state_hint.has_value() == false ) + if( !file_state_hint.has_value() ) return; // can't proceed without recent information about the file. // check if cache is up-to-date @@ -98,7 +98,7 @@ // file must exist and be accessible const auto file_state_hint = m_FileStateReader.ReadState(_file_path); - if( file_state_hint.has_value() == false ) { + if( !file_state_hint.has_value() ) { Log::Warn("failed to get a file state hint for '{}'", _file_path); return; } diff --git a/Source/Viewer/source/HexModeLayout.cpp b/Source/Viewer/source/HexModeLayout.cpp index 3c53323b5..9bf6a38d0 100644 --- a/Source/Viewer/source/HexModeLayout.cpp +++ b/Source/Viewer/source/HexModeLayout.cpp @@ -19,8 +19,8 @@ HexModeLayout::ScrollerPosition HexModeLayout::CalcScrollerPosition() const noex if( m_FileSize > bytes_in_view ) { const auto &working_set = m_Frame->WorkingSet(); ScrollerPosition position; - position.position = double(working_set.GlobalOffset() + - static_cast(m_ScrollOffset.row) * static_cast(m_Frame->BytesPerRow())) / + position.position = double(working_set.GlobalOffset() + (static_cast(m_ScrollOffset.row) * + static_cast(m_Frame->BytesPerRow()))) / double(m_FileSize - bytes_in_view); position.proportion = double(bytes_in_view) / double(m_FileSize); return position; @@ -186,7 +186,7 @@ HexModeLayout::HorizontalOffsets HexModeLayout::CalcHorizontalOffsets() const no const auto symb_width = m_Frame->FontInfo().PreciseMonospaceWidth(); const auto address_width = m_Frame->DigitsInAddress() * symb_width; - const auto column_width = m_Frame->BytesPerColumn() * (symb_width * 3) - symb_width; + const auto column_width = (m_Frame->BytesPerColumn() * (symb_width * 3)) - symb_width; const auto number_of_columns = m_Frame->NumberOfColumns(); double x = offsets.address + address_width + m_Gaps.address_columns_gap; @@ -220,7 +220,7 @@ HexModeLayout::HitPart HexModeLayout::HitTest(double _x) const int HexModeLayout::RowIndexFromYCoordinate(const double _y) const { - const auto scrolled = _y + m_ScrollOffset.row * m_Frame->FontInfo().LineHeight() + m_ScrollOffset.smooth; + const auto scrolled = _y + (m_ScrollOffset.row * m_Frame->FontInfo().LineHeight()) + m_ScrollOffset.smooth; const auto index = static_cast(std::floor(scrolled / m_Frame->FontInfo().LineHeight())); if( index < 0 ) return -1; @@ -247,7 +247,7 @@ int HexModeLayout::ByteOffsetFromColumnHit(CGPoint _position) const const auto symb_width = m_Frame->FontInfo().PreciseMonospaceWidth(); const auto bytes_per_column = m_Frame->BytesPerColumn(); - const auto column_width = m_Frame->BytesPerColumn() * (symb_width * 3) - symb_width; + const auto column_width = (m_Frame->BytesPerColumn() * (symb_width * 3)) - symb_width; for( int i = 0; i < row.ColumnsNumber(); ++i ) { if( i != row.ColumnsNumber() - 1 && x >= x_offsets.columns[i + 1] ) @@ -263,7 +263,7 @@ int HexModeLayout::ByteOffsetFromColumnHit(CGPoint _position) const const auto triplet_fract = local_x / (symb_width * 3); const auto round_up = std::floor(triplet_fract) != std::floor(triplet_fract + 0.33); const auto local_byte = static_cast(std::floor(triplet_fract)) + (round_up ? 1 : 0); - return row.BytesStart() + std::min(bytes_per_column * i + local_byte, row.BytesNum()); + return row.BytesStart() + std::min((bytes_per_column * i) + local_byte, row.BytesNum()); } } return row.BytesEnd(); @@ -297,17 +297,18 @@ std::pair HexModeLayout::CalcColumnSelectionBackground(const CFR const auto &row = m_Frame->RowAtIndex(_row_index); const auto bytes_range = - CFRangeMake(row.BytesStart() + _columm_index * m_Frame->BytesPerColumn(), row.BytesInColum(_columm_index)); + CFRangeMake(row.BytesStart() + (_columm_index * m_Frame->BytesPerColumn()), row.BytesInColum(_columm_index)); const auto sel_range = base::CFRangeIntersect(_bytes_selection, bytes_range); if( sel_range.length <= 0 ) return {0., 0.}; - const auto local_start_byte = int(sel_range.location - row.BytesStart() - - static_cast(_columm_index) * static_cast(m_Frame->BytesPerColumn())); + const auto local_start_byte = + int(sel_range.location - row.BytesStart() - + (static_cast(_columm_index) * static_cast(m_Frame->BytesPerColumn()))); const auto symb_width = m_Frame->FontInfo().PreciseMonospaceWidth(); - auto x1 = _offsets.columns.at(_columm_index) + local_start_byte * symb_width * 3; - auto x2 = x1 + static_cast(sel_range.length) * symb_width * 3 - symb_width; + auto x1 = _offsets.columns.at(_columm_index) + (local_start_byte * symb_width * 3); + auto x2 = x1 + (static_cast(sel_range.length) * symb_width * 3) - symb_width; return {std::floor(x1), std::ceil(x2)}; } @@ -344,7 +345,7 @@ std::pair HexModeLayout::MergeSelection(const CFRange _existing_select const int _first_mouse_hit_index, const int _current_mouse_hit_index) noexcept { - if( _modifiying_existing == false || _existing_selection.location < 0 || _existing_selection.length <= 0 ) { + if( !_modifiying_existing || _existing_selection.location < 0 || _existing_selection.length <= 0 ) { return {std::min(_first_mouse_hit_index, _current_mouse_hit_index), std::max(_first_mouse_hit_index, _current_mouse_hit_index)}; } diff --git a/Source/Viewer/source/HexModeProcessing.cpp b/Source/Viewer/source/HexModeProcessing.cpp index 8554d3382..84ec4acc9 100644 --- a/Source/Viewer/source/HexModeProcessing.cpp +++ b/Source/Viewer/source/HexModeProcessing.cpp @@ -73,7 +73,7 @@ base::CFPtr HexModeSplitter::MakeAddressString(const int _row_bytes "can't be less than 0"); const long unrounded_row_offset = long(_row_bytes_start) + _working_set_global_offset; - const long row_offset = unrounded_row_offset - unrounded_row_offset % _bytes_per_line; + const long row_offset = unrounded_row_offset - (unrounded_row_offset % _bytes_per_line); char16_t buffer[max_hex_length]; @@ -115,14 +115,14 @@ base::CFPtr HexModeSplitter::MakeBytesHexString(const std::byte *co auto buffer = static_cast(alloca(size * chars_per_byte * sizeof(char16_t))); Fill(_first, _last, buffer, _gap_symbol); const auto str = CFStringCreateWithCharacters( - nullptr, reinterpret_cast(buffer), std::max(size * chars_per_byte - 1, 0)); + nullptr, reinterpret_cast(buffer), std::max((size * chars_per_byte) - 1, 0)); return base::CFPtr::adopt(str); } else { std::u16string buffer(size * chars_per_byte, static_cast(0)); Fill(_first, _last, buffer.data(), _gap_symbol); const auto str = CFStringCreateWithCharacters( - nullptr, reinterpret_cast(buffer.data()), std::max(size * chars_per_byte - 1, 0)); + nullptr, reinterpret_cast(buffer.data()), std::max((size * chars_per_byte) - 1, 0)); return base::CFPtr::adopt(str); } } diff --git a/Source/Viewer/source/HexModeView.mm b/Source/Viewer/source/HexModeView.mm index 2ba467189..62276bd74 100644 --- a/Source/Viewer/source/HexModeView.mm +++ b/Source/Viewer/source/HexModeView.mm @@ -205,7 +205,7 @@ - (CGPoint)textOrigin { const auto origin = CGPointMake(m_Layout->GetGaps().left_inset, g_TopInset); const auto offset = m_Layout->GetOffset(); - const auto vertical_shift = offset.row * m_FontInfo.LineHeight() + offset.smooth; + const auto vertical_shift = (offset.row * m_FontInfo.LineHeight()) + offset.smooth; return CGPointMake(origin.x, origin.y - vertical_shift); } @@ -240,7 +240,7 @@ - (void)drawRect:(NSRect)dirtyRect const auto offsets = m_Layout->CalcHorizontalOffsets(); const auto line_height = m_Frame->FontInfo().LineHeight(); - auto line_pos = CGPointMake(origin.x, origin.y + lines_start * m_FontInfo.LineHeight()); + auto line_pos = CGPointMake(origin.x, origin.y + (lines_start * m_FontInfo.LineHeight())); for( int row_index = lines_start; row_index < lines_end; ++row_index, line_pos.y += line_height ) { if( row_index < 0 || row_index >= m_Frame->NumberOfRows() ) continue; @@ -323,7 +323,7 @@ - (bool)scrollToGlobalBytesOffset:(int64_t)_offset else { // nope, we need to perform I/O to move the file window const auto desired_wnd_pos = - std::clamp(_offset - static_cast(m_Backend->RawSize()) / 2, + std::clamp(_offset - (static_cast(m_Backend->RawSize()) / 2), static_cast(0), static_cast(m_Backend->FileSize()) - static_cast(m_Backend->RawSize())); @@ -417,7 +417,7 @@ - (bool)doMoveUpByOneLine old_frame->WorkingSet().GlobalOffset(); const auto desired_window_offset = std::clamp(old_anchor_glob_offset - static_cast(m_Backend->RawSize()) + - static_cast(m_Backend->RawSize()) / 4, + (static_cast(m_Backend->RawSize()) / 4), static_cast(0), static_cast(m_Backend->FileSize() - m_Backend->RawSize())); @@ -459,7 +459,7 @@ - (bool)doMoveDownByOneLine old_frame->WorkingSet().GlobalOffset(); const auto desired_window_offset = std::clamp(old_anchor_glob_offset + static_cast(m_Backend->RawSize()) - - static_cast(m_Backend->RawSize()) / 4, + (static_cast(m_Backend->RawSize()) / 4), static_cast(0), static_cast(m_Backend->FileSize() - m_Backend->RawSize())); @@ -497,7 +497,7 @@ - (void)scrollWheelVertical:(double)_delta_y smooth_offset -= delta_y; while( smooth_offset <= -m_FontInfo.LineHeight() ) { const auto did_move = [self doMoveUpByOneLine]; - if( did_move == false ) + if( !did_move ) break; smooth_offset += m_FontInfo.LineHeight(); } @@ -514,7 +514,7 @@ - (void)scrollWheelVertical:(double)_delta_y smooth_offset -= delta_y; while( smooth_offset >= m_FontInfo.LineHeight() ) { const auto did_move = [self doMoveDownByOneLine]; - if( did_move == false ) + if( !did_move ) break; smooth_offset -= m_FontInfo.LineHeight(); } diff --git a/Source/Viewer/source/Highlighting/Document.cpp b/Source/Viewer/source/Highlighting/Document.cpp index af025da1d..3128d4bab 100644 --- a/Source/Viewer/source/Highlighting/Document.cpp +++ b/Source/Viewer/source/Highlighting/Document.cpp @@ -106,7 +106,7 @@ int Document::CodePage() const noexcept return 65001; // UTF8 } -bool Document::IsDBCSLeadByte(char) const noexcept +bool Document::IsDBCSLeadByte(char /*ch*/) const noexcept { return false; } diff --git a/Source/Viewer/source/TextModeView.mm b/Source/Viewer/source/TextModeView.mm index 69601a007..4d6be0d6e 100644 --- a/Source/Viewer/source/TextModeView.mm +++ b/Source/Viewer/source/TextModeView.mm @@ -230,8 +230,8 @@ - (double)wrappingWidth - (CGPoint)textOrigin { const auto origin = CGPointMake(g_LeftInset, g_TopInset); - const auto vertical_shift = m_VerticalLineOffset * m_FontInfo.LineHeight() + m_PxOffset.y; - const auto horizontal_shift = m_HorizontalCharsOffset * m_FontInfo.PreciseMonospaceWidth() + m_PxOffset.x; + const auto vertical_shift = (m_VerticalLineOffset * m_FontInfo.LineHeight()) + m_PxOffset.y; + const auto horizontal_shift = (m_HorizontalCharsOffset * m_FontInfo.PreciseMonospaceWidth()) + m_PxOffset.x; return CGPointMake(origin.x - horizontal_shift, origin.y - vertical_shift); } @@ -292,7 +292,7 @@ - (void)drawRect:(NSRect)_dirty_rect // +1 to ensure that selection of a following line is also visible const int lines_end = lines_start + lines_per_screen + 1; - auto line_pos = CGPointMake(origin.x, origin.y + lines_start * m_FontInfo.LineHeight()); + auto line_pos = CGPointMake(origin.x, origin.y + (lines_start * m_FontInfo.LineHeight())); const auto selection = [self localSelection]; @@ -363,7 +363,7 @@ - (bool)doMoveUpByOneLine old_frame->WorkingSet().GlobalOffset(); const auto desired_window_offset = std::clamp(old_anchor_glob_offset - static_cast(m_Backend->RawSize()) + - static_cast(m_Backend->RawSize()) / 4, + (static_cast(m_Backend->RawSize()) / 4), static_cast(0), static_cast(m_Backend->FileSize() - m_Backend->RawSize())); @@ -408,7 +408,7 @@ - (bool)doMoveDownByOneLine const auto old_anchor_glob_offset = static_cast(old_frame->Line(old_anchor_line_index).BytesStart()) + old_frame->WorkingSet().GlobalOffset(); const auto desired_window_offset = - std::clamp(old_anchor_glob_offset - static_cast(m_Backend->RawSize()) / 4, + std::clamp(old_anchor_glob_offset - (static_cast(m_Backend->RawSize()) / 4), static_cast(0), static_cast(m_Backend->FileSize() - m_Backend->RawSize())); if( desired_window_offset <= static_cast(m_Backend->FilePos()) ) @@ -528,7 +528,7 @@ - (void)scrollWheelVertical:(double)_delta_y m_PxOffset.y = 0; while( px_offset <= -m_FontInfo.LineHeight() ) { const auto did_move = [self doMoveUpByOneLine]; - if( did_move == false ) + if( !did_move ) break; px_offset += m_FontInfo.LineHeight(); } @@ -546,7 +546,7 @@ - (void)scrollWheelVertical:(double)_delta_y m_PxOffset.y = 0; while( px_offset >= m_FontInfo.LineHeight() ) { const auto did_move = [self doMoveDownByOneLine]; - if( did_move == false ) + if( !did_move ) break; px_offset -= m_FontInfo.LineHeight(); } @@ -682,7 +682,7 @@ - (bool)scrollToGlobalBytesOffset:(int64_t)_offset return false; const auto desired_wnd_pos = - std::clamp(_offset - static_cast(m_Backend->RawSize()) / 2, + std::clamp(_offset - (static_cast(m_Backend->RawSize()) / 2), static_cast(0), static_cast(m_Backend->FileSize()) - static_cast(m_Backend->RawSize())); diff --git a/Source/Viewer/source/TextProcessing.cpp b/Source/Viewer/source/TextProcessing.cpp index 405967570..ee5777dac 100644 --- a/Source/Viewer/source/TextProcessing.cpp +++ b/Source/Viewer/source/TextProcessing.cpp @@ -121,7 +121,7 @@ std::vector> SplitStringIntoLines(const char16_t *_character else { const auto probe_width = CharInfo::WCWidthMin1(c) == 1 ? // TODO: add support for surrogate pairs width + _monospace_width - : width + 2 * _monospace_width; + : width + (2 * _monospace_width); if( probe_width > _wrapping_width + wrapping_epsilon ) { break; diff --git a/Source/Viewer/source/ViewerFooter.mm b/Source/Viewer/source/ViewerFooter.mm index 912947a6a..cf88f8e84 100644 --- a/Source/Viewer/source/ViewerFooter.mm +++ b/Source/Viewer/source/ViewerFooter.mm @@ -239,10 +239,10 @@ - (void)updateControlsVisibility m_LineWrapButton.hidden = !(m_Mode == ViewMode::Text); m_VSep2.hidden = !(m_Mode == ViewMode::Text); m_LanguageButton.hidden = !(m_Mode == ViewMode::Text); - m_VSep3.hidden = !(m_Mode == ViewMode::Text || m_Mode == ViewMode::Hex); - m_EncodingButton.hidden = !(m_Mode == ViewMode::Text || m_Mode == ViewMode::Hex); - m_VSep4.hidden = !(m_Mode == ViewMode::Text || m_Mode == ViewMode::Hex); - m_LinePositionButton.hidden = !(m_Mode == ViewMode::Text || m_Mode == ViewMode::Hex); + m_VSep3.hidden = m_Mode != ViewMode::Text && m_Mode != ViewMode::Hex; + m_EncodingButton.hidden = m_Mode != ViewMode::Text && m_Mode != ViewMode::Hex; + m_VSep4.hidden = m_Mode != ViewMode::Text && m_Mode != ViewMode::Hex; + m_LinePositionButton.hidden = m_Mode != ViewMode::Text && m_Mode != ViewMode::Hex; } - (void)setMode:(ViewMode)_mode diff --git a/Source/Viewer/source/ViewerView.mm b/Source/Viewer/source/ViewerView.mm index f13d9daca..f47fd3bdb 100644 --- a/Source/Viewer/source/ViewerView.mm +++ b/Source/Viewer/source/ViewerView.mm @@ -10,12 +10,14 @@ #include "DataBackend.h" #include #include -#include "Theme.h" -#include "TextModeView.h" + #include "HexModeView.h" #include "PreviewModeView.h" +#include "TextModeView.h" +#include "Theme.h" #include "ViewerFooter.h" #include "ViewerSearchView.h" +#include static const auto g_ConfigDefaultEncoding = "viewer.defaultEncoding"; static const auto g_ConfigAutoDetectEncoding = "viewer.autoDetectEncoding"; @@ -454,10 +456,8 @@ - (void)UpdateSelectionRange uint64_t start = m_SelectionInFile.location; uint64_t end = start + m_SelectionInFile.length; - if( end > window_pos + window_size ) - end = window_pos + window_size; - if( start < window_pos ) - start = window_pos; + end = std::min(end, window_pos + window_size); + start = std::max(start, window_pos); if( start >= end ) { m_SelectionInWindow = CFRangeMake(-1, 0); diff --git a/Source/Viewer/source/ViewerViewController.mm b/Source/Viewer/source/ViewerViewController.mm index d56d08832..9371b6808 100644 --- a/Source/Viewer/source/ViewerViewController.mm +++ b/Source/Viewer/source/ViewerViewController.mm @@ -665,7 +665,7 @@ - (void)observeValueForKeyPath:(NSString *)_key_path { dispatch_assert_background_queue(); assert(_vfs); - if( const int vfs_err = _vfs->CreateFile(_path.c_str(), original_file, nullptr); vfs_err != VFSError::Ok ) + if( const int vfs_err = _vfs->CreateFile(_path, original_file, nullptr); vfs_err != VFSError::Ok ) return vfs_err; if( original_file->GetReadParadigm() < VFSFile::ReadParadigm::Random ) { diff --git a/Source/Viewer/tests/TextMoveView_UT.mm b/Source/Viewer/tests/TextMoveView_UT.mm index 077d69ced..60babdd46 100644 --- a/Source/Viewer/tests/TextMoveView_UT.mm +++ b/Source/Viewer/tests/TextMoveView_UT.mm @@ -34,7 +34,7 @@ [[nodiscard]] NSColor *TextSyntaxStringColor() const override; [[nodiscard]] NSColor *ViewerSelectionColor() const override; [[nodiscard]] NSColor *ViewerBackgroundColor() const override; - void ObserveChanges(std::function) override; + void ObserveChanges(std::function /*_callback*/) override; }; struct Context { @@ -191,7 +191,7 @@ @interface NCViewerTextModeViewMockDelegate : NSObject ) +void DummyTheme::ObserveChanges(std::function /*_callback*/) { } diff --git a/Source/Viewer/tests/hlClient_UT.cpp b/Source/Viewer/tests/hlClient_UT.cpp index 25d8bd194..334415f2c 100644 --- a/Source/Viewer/tests/hlClient_UT.cpp +++ b/Source/Viewer/tests/hlClient_UT.cpp @@ -108,7 +108,7 @@ int hello = 10;)"; TEST_CASE(PREFIX "Reacting to broken JSON") { const std::string settings = "definitely not a JSON"; - const std::string text = ""; + const std::string text; auto hl = Client::Highlight(text, settings); REQUIRE(!hl.has_value()); CHECK(hl.error().contains("Unable to parse the lexing settings")); @@ -119,7 +119,7 @@ TEST_CASE(PREFIX "Reacting to non-existing lexer") const std::string settings = R"({ "lexer": "I don't exist!" })"; - const std::string text = ""; + const std::string text; auto hl = Client::Highlight(text, settings); REQUIRE(!hl.has_value()); CHECK(hl.error().contains("Unable to highlight the document")); @@ -143,7 +143,7 @@ TEST_CASE(PREFIX "Reacting to non-existing option") "SCE_C_COMMENT": "comment" } })"; - const std::string text = ""; + const std::string text; auto hl = Client::Highlight(text, settings); REQUIRE(!hl.has_value()); CHECK(hl.error().contains("Unable to highlight the document")); @@ -157,7 +157,7 @@ TEST_CASE(PREFIX "Reacting to non-existing mapping source") "Hey!": "keyword" } })"; - const std::string text = ""; + const std::string text; auto hl = Client::Highlight(text, settings); REQUIRE(!hl.has_value()); CHECK(hl.error().contains("Unable to parse the lexing settings")); @@ -171,7 +171,7 @@ TEST_CASE(PREFIX "Reacting to non-existing mapping target") "SCE_C_COMMENT": "Hey!" } })"; - const std::string text = ""; + const std::string text; auto hl = Client::Highlight(text, settings); REQUIRE(!hl.has_value()); CHECK(hl.error().contains("Unable to parse the lexing settings"));