-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bae7d35
commit 4c92d83
Showing
2 changed files
with
36 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,30 @@ | ||
from struct import Struct | ||
from typing import List | ||
|
||
from pyzshell.fs import Fs | ||
|
||
from pyzshell.exceptions import ZShellError | ||
from pyzshell.structs.linux import dirent | ||
|
||
|
||
class LinuxFs(Fs): | ||
CHUNK_SIZE = 1024 | ||
|
||
def listdir(self, dirname: str) -> list: | ||
""" get directory listing for a given dirname """ | ||
raise NotImplementedError() | ||
def listdir(self, dirname='.') -> List[Struct]: | ||
""" list directory contents(at remote). | ||
calls readdir in a loop """ | ||
errno = self._client.symbols.errno | ||
errno[0] = 0 | ||
dir_list = [] | ||
folder = self._client.symbols.opendir(dirname) | ||
if folder == 0: | ||
raise ZShellError('cannot open folder to listdir') | ||
diren = self._client.symbols.readdir(folder) | ||
while diren != 0: | ||
entry = dirent.parse_stream(diren) | ||
dir_list.append(entry) | ||
diren = self._client.symbols.readdir(folder) | ||
if errno[0] != 0: | ||
raise ZShellError(f'readdir for listdir failed. ({self._client.errno})') | ||
self._client.symbols.closedir(folder) | ||
return dir_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters