Files
pancake 2c19d6c9dc Ported the remaining classes to use the command builder and _exec:
- Search: string/wide/case-insensitive/Rabin-Karp/JSON searches now use _cmd_arg so patterns with spaces/special chars are safe.
- Flags: removed leftover manual _tmp_off = "" cleanups (now automatic).
- Debugger: added _tmp_addr() helper, removed manual _tmp_off cleanup.
- Esil: ESIL expressions use _cmd_arg; EsilCPU.registers() returns {} on failure; emulateInstr resolves symbol names to numeric
addresses because aesp doesn't accept symbols.
- Config: cleaned up old-style super() and % formatting; config set now uses key=value.
- File: minor __getattr__ cleanup.
- IOMap: setName uses _cmd_arg for arbitrary map names.
- R2Api / Function: af, afn, afn., p8, aoj, axtj now rely on automatic _tmp_off handling; removed duplicated open/files definitions.
2026-08-28 17:05:58 +02:00

32 lines
872 B
Python

from r2papi.base import R2Base, ResultArray
class Flags(R2Base):
def __init__(self, r2):
super().__init__(r2)
def all(self):
return ResultArray(self._exec("fj", json=True))
def exists(self, name):
flags = self._exec("fj", json=True) or []
return any(f.get("name") == name for f in flags)
def new(self, name, offset=None):
if offset is None:
offset = self.curr_seek_addr()
else:
self._tmp_off = ""
self._exec(f"f {name} @ {offset}")
def delete(self, name="", offset=None):
if offset is not None:
self._exec(f"f-{name}@{offset}")
elif name:
self._exec(f"f-{name}")
elif self._tmp_off:
self._exec(f"f-{self._tmp_off}")
def rename(self, old, new=""):
self._exec(f"fr {old} {new} {self._tmp_off}")