feat: file edit added
This commit is contained in:
Binary file not shown.
@@ -65,11 +65,25 @@ class FilesystemAdapter:
|
||||
limit = max_bytes + 1
|
||||
with path.open("rb") as in_f:
|
||||
raw = in_f.read(limit)
|
||||
modified = self.modified_iso(path)
|
||||
truncated = size > max_bytes or len(raw) > max_bytes
|
||||
if truncated:
|
||||
raw = raw[:max_bytes]
|
||||
return {
|
||||
"size": size,
|
||||
"modified": modified,
|
||||
"truncated": truncated,
|
||||
"content": raw.decode(encoding, errors="replace"),
|
||||
}
|
||||
|
||||
def write_text_file(self, path: Path, content: str, encoding: str = "utf-8") -> dict:
|
||||
path.write_text(content, encoding=encoding)
|
||||
return {
|
||||
"size": int(path.stat().st_size),
|
||||
"modified": self.modified_iso(path),
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def modified_iso(path: Path) -> str:
|
||||
stat = path.stat()
|
||||
return datetime.fromtimestamp(stat.st_mtime, tz=timezone.utc).isoformat().replace("+00:00", "Z")
|
||||
|
||||
Reference in New Issue
Block a user