mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 10:56:11 +00:00
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:
parent
9441c3b470
commit
bca7a7a2a6
@ -4042,12 +4042,18 @@ void CutterCore::setWriteMode(bool enabled)
|
||||
|
||||
bool CutterCore::isWriteModeEnabled()
|
||||
{
|
||||
for (CutterJson v : cmdj("oj")) {
|
||||
if (v["raised"].toBool()) {
|
||||
return v["writable"].toBool();
|
||||
CORE_LOCK();
|
||||
RzListIter *it;
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user