mirror of
https://github.com/9001/copyparty.git
synced 2026-04-12 23:32:32 -06:00
util: add helper to read .hidden file
This commit is contained in:
parent
ffe6a9aa6f
commit
665a40ed0e
|
|
@ -2381,6 +2381,13 @@ def u8safe(txt: str) -> str:
|
|||
except:
|
||||
return txt.encode("utf-8", "replace").decode("utf-8", "replace")
|
||||
|
||||
def load_dothidden(dpath: str) -> set[str]:
|
||||
try:
|
||||
with open(os.path.join(dpath, ".hidden"), "rb") as f:
|
||||
return {ln.strip() for ln in f.read().decode("utf-8", "replace").splitlines()}
|
||||
except OSError:
|
||||
return {}
|
||||
|
||||
|
||||
def exclude_dotfiles(filepaths: list[str]) -> list[str]:
|
||||
return [x for x in filepaths if not x.split("/")[-1].startswith(".")]
|
||||
|
|
|
|||
Loading…
Reference in a new issue