videoSummary/app/utils/file_utils.py
2025-12-02 18:54:14 +08:00

40 lines
754 B
Python

"""
File utility functions
"""
from pathlib import Path
from typing import Optional
def ensure_directory_exists(directory: Path):
"""
Ensure directory exists, create if not
Args:
directory: Directory path
"""
directory.mkdir(parents=True, exist_ok=True)
def get_file_size(file_path: Path) -> int:
"""
Get file size in bytes
Args:
file_path: File path
Returns:
File size in bytes
"""
return file_path.stat().st_size
def file_exists(file_path: Path) -> bool:
"""
Check if file exists
Args:
file_path: File path
Returns:
True if file exists, False otherwise
"""
return file_path.exists() and file_path.is_file()