feat: SHIFT-CMD-F zoek functionaliteit toegevoegd
This commit is contained in:
Binary file not shown.
@@ -29,6 +29,29 @@ class FilesystemAdapter:
|
||||
|
||||
return directories, files
|
||||
|
||||
def search_names(self, directory: Path, query: str, limit: int) -> tuple[list[dict], bool]:
|
||||
normalized_query = query.lower()
|
||||
results: list[dict] = []
|
||||
|
||||
for root, dirnames, filenames in __import__("os").walk(directory):
|
||||
dirnames[:] = sorted([name for name in dirnames if not name.startswith(".")], key=str.lower)
|
||||
filenames = sorted([name for name in filenames if not name.startswith(".")], key=str.lower)
|
||||
|
||||
root_path = Path(root)
|
||||
for name in dirnames:
|
||||
if normalized_query in name.lower():
|
||||
results.append({"name": name, "kind": "directory", "absolute": root_path / name})
|
||||
if len(results) >= limit:
|
||||
return results, True
|
||||
|
||||
for name in filenames:
|
||||
if normalized_query in name.lower():
|
||||
results.append({"name": name, "kind": "file", "absolute": root_path / name})
|
||||
if len(results) >= limit:
|
||||
return results, True
|
||||
|
||||
return results, False
|
||||
|
||||
def make_directory(self, path: Path) -> None:
|
||||
path.mkdir(parents=False, exist_ok=False)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user