Rewrite isWriteModeEnabled() with API

This also introduces a slight behavioral change: Previously, only the
core file with the "raised" io desc was checked, which is RzIO.desc. But
that member is deprecated for good reasons, so now we just check if
there is any core file whose primary fd has write enabled.
This commit is contained in:
Florian Märkl 2022-03-14 10:01:48 +01:00 committed by Anton Kochkov
parent f26f04b5fe
commit 9d2404b486

View File

@ -4042,12 +4042,18 @@ void CutterCore::setWriteMode(bool enabled)
bool CutterCore::isWriteModeEnabled() bool CutterCore::isWriteModeEnabled()
{ {
for (CutterJson v : cmdj("oj")) { CORE_LOCK();
if (v["raised"].toBool()) { RzListIter *it;
return v["writable"].toBool(); RzCoreFile *cf;
CutterRzListForeach (core->files, it, RzCoreFile, cf) {
RzIODesc *desc = rz_io_desc_get(core->io, cf->fd);
if (!desc) {
continue;
}
if (desc->perm & RZ_PERM_W) {
return true;
} }
} }
return false; return false;
} }