Skip to content

Commit

Permalink
Add support for block files
Browse files Browse the repository at this point in the history
  • Loading branch information
Zedeldi committed Oct 9, 2024
1 parent 52ba33c commit 50ff98b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions igelfs/filesystem.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Python implementation to handle IGEL filesystems."""

import itertools
import os
from functools import cached_property
from pathlib import Path
from typing import Iterator
Expand Down Expand Up @@ -49,6 +50,9 @@ def __iter__(self) -> Iterator[Section]:
@property
def size(self) -> int:
"""Return size of image."""
if self.path.is_block_device():
with open(self.path, "rb") as fd:
return fd.seek(0, os.SEEK_END)
return self.path.stat().st_size

@property
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "igelfs"
description = "Python implementation of the IGEL filesystem."
version = "1.1.0"
version = "1.1.1"
readme = "README.md"
license = {file = "LICENSE"}
authors = [
Expand Down

0 comments on commit 50ff98b

Please sign in to comment.