flyshell 1.3.9__tar.gz → 1.3.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flyshell-1.3.9/src/flyshell.egg-info → flyshell-1.3.10}/PKG-INFO +1 -1
- {flyshell-1.3.9 → flyshell-1.3.10}/c_src/diskops/diskops.c +32 -0
- flyshell-1.3.10/c_src/diskops/posix/dir.c +71 -0
- flyshell-1.3.10/c_src/diskops/shared/dir_types.c +16 -0
- flyshell-1.3.10/c_src/diskops/shared/dir_types.h +21 -0
- flyshell-1.3.10/c_src/diskops/win32/dir.c +65 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/setup.py +3 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/builtin/diskops.py +0 -23
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/constants.py +2 -2
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/core/directory.py +1 -1
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/native/diskops_handler.py +29 -1
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/native/legacy/diskops.py +27 -2
- {flyshell-1.3.9 → flyshell-1.3.10/src/flyshell.egg-info}/PKG-INFO +1 -1
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell.egg-info/SOURCES.txt +4 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/LICENSE +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/MANIFEST.in +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/README.md +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/c_src/diskops/posix/cat.c +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/c_src/diskops/posix/touch.c +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/c_src/diskops/shared/native_errors.h +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/c_src/diskops/win32/cat.c +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/c_src/diskops/win32/touch.c +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/pyproject.toml +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/setup.cfg +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/__init__.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/abstract/__init__.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/abstract/base_cmd.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/abstract/base_plugin.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/abstract/parent_cmd.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/accounts/__init__.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/accounts/auth.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/bin/__init__.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/builtin/__init__.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/builtin/fs.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/builtin/pkg.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/builtin/system.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/builtin/utils.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/core/__init__.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/core/console.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/core/data.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/main.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/native/__init__.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/native/diskops_bridge.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/native/legacy/__init__.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/startup/__init__.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/startup/deps.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/startup/env.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell/startup/loader.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell.egg-info/dependency_links.txt +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell.egg-info/entry_points.txt +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell.egg-info/requires.txt +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/src/flyshell.egg-info/top_level.txt +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/tests/test_auth.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/tests/test_data.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/tests/test_deps.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/tests/test_directory.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/tests/test_diskops.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/tests/test_env.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/tests/test_fs.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/tests/test_loader.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/tests/test_pkg.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/tests/test_security.py +0 -0
- {flyshell-1.3.9 → flyshell-1.3.10}/tests/test_utils.py +0 -0
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
#define PY_SSIZE_T_CLEAN
|
|
4
4
|
#include <Python.h>
|
|
5
5
|
#include "shared/native_errors.h"
|
|
6
|
+
#include "shared/dir_types.h"
|
|
6
7
|
|
|
7
8
|
Result cat(const char* path, char** out_buf, size_t* out_size);
|
|
8
9
|
|
|
9
10
|
Result touch(const char* path);
|
|
10
11
|
|
|
12
|
+
Result list_dir(const char* path, DirList* out_list);
|
|
13
|
+
|
|
11
14
|
static PyObject* method_ping(PyObject* self, PyObject* args) {
|
|
12
15
|
return PyLong_FromLong(42);
|
|
13
16
|
}
|
|
@@ -48,10 +51,39 @@ static PyObject* method_touch(PyObject* self, PyObject* args) {
|
|
|
48
51
|
return Py_BuildValue("(is)", (int)res, "");
|
|
49
52
|
}
|
|
50
53
|
|
|
54
|
+
static PyObject* method_dir(PyObject* self, PyObject* args) {
|
|
55
|
+
const char* path;
|
|
56
|
+
if (!PyArg_ParseTuple(args, "s", &path)) {
|
|
57
|
+
return NULL;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
DirList dir_list;
|
|
61
|
+
Result res = list_dir(path, &dir_list);
|
|
62
|
+
if (res != SUCCESS) {
|
|
63
|
+
return Py_BuildValue("(i[])", (int)res);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
PyObject* py_list = PyList_New(dir_list.count);
|
|
67
|
+
if (!py_list) {
|
|
68
|
+
free_dir_list(&dir_list);
|
|
69
|
+
return Py_BuildValue("(i[])", (int)ERR_IO);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
for (size_t i = 0; i < dir_list.count; ++i) {
|
|
73
|
+
PyObject* item = Py_BuildValue("(sO)", dir_list.entries[i].name,
|
|
74
|
+
dir_list.entries[i].is_dir ? Py_True : Py_False);
|
|
75
|
+
PyList_SET_ITEM(py_list, i, item);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
free_dir_list(&dir_list);
|
|
79
|
+
return Py_BuildValue("(iN)", (int)SUCCESS, py_list);
|
|
80
|
+
}
|
|
81
|
+
|
|
51
82
|
static PyMethodDef DiskopsMethods[] = {
|
|
52
83
|
{"ping", method_ping, METH_NOARGS, "Health check ping."},
|
|
53
84
|
{"cat", method_cat, METH_VARARGS, "Read file content natively."},
|
|
54
85
|
{"touch", method_touch, METH_VARARGS, "Touch or create file natively."},
|
|
86
|
+
{"dir", method_dir, METH_VARARGS, "List directory contents natively."},
|
|
55
87
|
{NULL, NULL, 0, NULL},
|
|
56
88
|
};
|
|
57
89
|
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// c_src/diskops/posix/dir.c
|
|
2
|
+
|
|
3
|
+
#define _POSIX_C_SOURCE 200809L
|
|
4
|
+
#define _GNU_SOURCE
|
|
5
|
+
|
|
6
|
+
#include <dirent.h>
|
|
7
|
+
#include <sys/stat.h>
|
|
8
|
+
#include <stdlib.h>
|
|
9
|
+
#include <string.h>
|
|
10
|
+
#include <errno.h>
|
|
11
|
+
#include "../shared/native_errors.h"
|
|
12
|
+
#include "../shared/dir_types.h"
|
|
13
|
+
|
|
14
|
+
Result list_dir(const char* path, DirList* out_list) {
|
|
15
|
+
if (!path || path[0] == '\0' || !out_list) {
|
|
16
|
+
return ERR_INVALID_PATH;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
out_list->entries = NULL;
|
|
20
|
+
out_list->count = 0;
|
|
21
|
+
|
|
22
|
+
DIR* dir = opendir(path);
|
|
23
|
+
if (!dir) {
|
|
24
|
+
return map_posix_errno(errno);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
size_t capacity = 16;
|
|
28
|
+
out_list->entries = (DirEntry*)malloc(capacity * sizeof(DirEntry));
|
|
29
|
+
if (!out_list->entries) {
|
|
30
|
+
closedir(dir);
|
|
31
|
+
return ERR_IO;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
struct dirent* entry;
|
|
35
|
+
while ((entry = readdir(dir)) != NULL) {
|
|
36
|
+
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (out_list->count >= capacity) {
|
|
41
|
+
capacity *= 2;
|
|
42
|
+
DirEntry* resized = (DirEntry*)realloc(out_list->entries, capacity * sizeof(DirEntry));
|
|
43
|
+
if (!resized) {
|
|
44
|
+
closedir(dir);
|
|
45
|
+
free_dir_list(out_list);
|
|
46
|
+
return ERR_IO;
|
|
47
|
+
}
|
|
48
|
+
out_list->entries = resized;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
bool is_dir = false;
|
|
52
|
+
#ifdef _DIRENT_HAVE_D_TYPE
|
|
53
|
+
if (entry->d_type != DT_UNKNOWN) {
|
|
54
|
+
is_dir = (entry->d_type == DT_DIR);
|
|
55
|
+
} else
|
|
56
|
+
#endif
|
|
57
|
+
{
|
|
58
|
+
struct stat st;
|
|
59
|
+
if (fstatat(dirfd(dir), entry->d_name, &st, 0) == 0) {
|
|
60
|
+
is_dir = S_ISDIR(st.st_mode);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
out_list->entries[out_list->count].name = strdup(entry->d_name);
|
|
65
|
+
out_list->entries[out_list->count].is_dir = is_dir;
|
|
66
|
+
out_list->count++;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
closedir(dir);
|
|
70
|
+
return SUCCESS;
|
|
71
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// c_src/diskops/shared/dir_types.c
|
|
2
|
+
|
|
3
|
+
#include <stdlib.h>
|
|
4
|
+
#include "dir_types.h"
|
|
5
|
+
|
|
6
|
+
void free_dir_list(DirList* list) {
|
|
7
|
+
if (!list) return;
|
|
8
|
+
if (list->entries) {
|
|
9
|
+
for (size_t i = 0; i < list ->count; ++i) {
|
|
10
|
+
free(list->entries[i].name);
|
|
11
|
+
}
|
|
12
|
+
free(list->entries);
|
|
13
|
+
list->entries = NULL;
|
|
14
|
+
}
|
|
15
|
+
list->count = 0;
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// c_src/diskops/shared/dir_types.h
|
|
2
|
+
|
|
3
|
+
#ifndef DIR_TYPES_H
|
|
4
|
+
#define DIR_TYPES_H
|
|
5
|
+
|
|
6
|
+
#include <stdbool.h>
|
|
7
|
+
#include <stddef.h>
|
|
8
|
+
|
|
9
|
+
typedef struct {
|
|
10
|
+
char* name;
|
|
11
|
+
bool is_dir;
|
|
12
|
+
} DirEntry;
|
|
13
|
+
|
|
14
|
+
typedef struct {
|
|
15
|
+
DirEntry* entries;
|
|
16
|
+
size_t count;
|
|
17
|
+
} DirList;
|
|
18
|
+
|
|
19
|
+
void free_dir_list(DirList* list);
|
|
20
|
+
|
|
21
|
+
#endif /* DIR_TYPES_H */
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// c_src/diskops/win32/dir.c
|
|
2
|
+
|
|
3
|
+
#include <windows.h>
|
|
4
|
+
#include <stdio.h>
|
|
5
|
+
#include <stdlib.h>
|
|
6
|
+
#include <string.h>
|
|
7
|
+
#include "../shared/native_errors.h"
|
|
8
|
+
#include "../shared/dir_types.h"
|
|
9
|
+
|
|
10
|
+
Result list_dir(const char* path, DirList* out_list) {
|
|
11
|
+
if (!path || path[0] == '\0' || !out_list) {
|
|
12
|
+
return ERR_INVALID_PATH;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
out_list->entries = NULL;
|
|
16
|
+
out_list->count = 0;
|
|
17
|
+
|
|
18
|
+
char search_pattern[MAX_PATH];
|
|
19
|
+
snprintf(search_pattern, sizeof(search_pattern), "%s\\*", path);
|
|
20
|
+
|
|
21
|
+
WIN32_FIND_DATAA find_data;
|
|
22
|
+
HANDLE h_find = FindFirstFileA(search_pattern, &find_data);
|
|
23
|
+
if (h_find == INVALID_HANDLE_VALUE) {
|
|
24
|
+
return map_win32_error(GetLastError());
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
size_t capacity = 16;
|
|
28
|
+
out_list->entries = (DirEntry*)malloc(capacity * sizeof(DirEntry));
|
|
29
|
+
if (!out_list->entries) {
|
|
30
|
+
FindClose(h_find);
|
|
31
|
+
return ERR_IO;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
do {
|
|
35
|
+
if (strcmp(find_data.cFileName, ".") == 0 || strcmp(find_data.cFileName, "..") == 0) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (out_list->count >= capacity) {
|
|
40
|
+
capacity *= 2;
|
|
41
|
+
DirEntry* resized = (DirEntry*)realloc(out_list->entries, capacity * sizeof(DirEntry));
|
|
42
|
+
if (!resized) {
|
|
43
|
+
FindClose(h_find);
|
|
44
|
+
free_dir_list(out_list);
|
|
45
|
+
return ERR_IO;
|
|
46
|
+
}
|
|
47
|
+
out_list->entries = resized;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
bool is_dir = (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
|
51
|
+
out_list->entries[out_list->count].name = _strdup(find_data.cFileName);
|
|
52
|
+
out_list->entries[out_list->count].is_dir = is_dir;
|
|
53
|
+
out_list->count++;
|
|
54
|
+
} while (FindNextFileA(h_find, &find_data) != 0);
|
|
55
|
+
|
|
56
|
+
DWORD err = GetLastError();
|
|
57
|
+
FindClose(h_find);
|
|
58
|
+
|
|
59
|
+
if (err != ERROR_NO_MORE_FILES && err != ERROR_SUCCESS) {
|
|
60
|
+
free_dir_list(out_list);
|
|
61
|
+
return map_win32_error(err);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return SUCCESS;
|
|
65
|
+
}
|
|
@@ -5,13 +5,16 @@ import sys
|
|
|
5
5
|
|
|
6
6
|
sources = [
|
|
7
7
|
"c_src/diskops/diskops.c",
|
|
8
|
+
"c_src/diskops/shared/dir_types.c",
|
|
8
9
|
]
|
|
9
10
|
|
|
10
11
|
if sys.platform == "win32":
|
|
11
12
|
sources.append("c_src/diskops/win32/cat.c")
|
|
13
|
+
sources.append("c_src/diskops/win32/dir.c")
|
|
12
14
|
sources.append("c_src/diskops/win32/touch.c")
|
|
13
15
|
else:
|
|
14
16
|
sources.append("c_src/diskops/posix/cat.c")
|
|
17
|
+
sources.append("c_src/diskops/posix/dir.c")
|
|
15
18
|
sources.append("c_src/diskops/posix/touch.c")
|
|
16
19
|
|
|
17
20
|
native_diskops = Extension(
|
|
@@ -71,29 +71,6 @@ class Copy(BaseCmd):
|
|
|
71
71
|
return (1, f"\nSystem Error: Failed to copy '{raw_src}' ({e})\n")
|
|
72
72
|
|
|
73
73
|
|
|
74
|
-
class Dir(BaseCmd):
|
|
75
|
-
name = "dir"
|
|
76
|
-
description = "List all files in the current working directory"
|
|
77
|
-
min_args = 0
|
|
78
|
-
options = None
|
|
79
|
-
aliases = ["ls"]
|
|
80
|
-
|
|
81
|
-
def execute(self, args):
|
|
82
|
-
try:
|
|
83
|
-
current_path = os.getcwd()
|
|
84
|
-
items = os.listdir(current_path)
|
|
85
|
-
lines = [f"\nDirectory: '{current_path}'"]
|
|
86
|
-
for item in items:
|
|
87
|
-
if os.path.isdir(os.path.join(current_path, item)):
|
|
88
|
-
lines.append(f"[DIR] {item}/")
|
|
89
|
-
else:
|
|
90
|
-
lines.append(f"[FILE] {item}")
|
|
91
|
-
lines.append(f"\nTotal items in directory: {len(items)}\n")
|
|
92
|
-
return (0, "\n".join(lines))
|
|
93
|
-
except Exception as e:
|
|
94
|
-
return (1, f"\nSystem Error: Unable to list directory ({e})\n")
|
|
95
|
-
|
|
96
|
-
|
|
97
74
|
class MkDir(BaseCmd):
|
|
98
75
|
name = "mkdir"
|
|
99
76
|
description = "Create a new directory from the current working directory"
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# src/flyshell/native/diskops_handler.py
|
|
2
2
|
|
|
3
|
-
from pathlib import Path
|
|
4
3
|
from flyshell.abstract.base_cmd import BaseCmd
|
|
5
4
|
from flyshell.native import diskops_bridge as bridge
|
|
6
5
|
from flyshell.native.legacy import diskops as legacy
|
|
7
6
|
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import os
|
|
9
|
+
|
|
8
10
|
|
|
9
11
|
class Cat(BaseCmd):
|
|
10
12
|
name = "cat"
|
|
@@ -62,6 +64,32 @@ class Cat(BaseCmd):
|
|
|
62
64
|
return (0, "\n".join(output_lines))
|
|
63
65
|
|
|
64
66
|
|
|
67
|
+
class Dir(BaseCmd):
|
|
68
|
+
name = "dir"
|
|
69
|
+
description = "List all files in the current working directory"
|
|
70
|
+
min_args = 0
|
|
71
|
+
options = None
|
|
72
|
+
aliases = ["ls"]
|
|
73
|
+
|
|
74
|
+
def execute(self, args):
|
|
75
|
+
target_str = args[0].strip("\"'") if args else os.getcwd()
|
|
76
|
+
target_path = Path(target_str).expanduser().resolve()
|
|
77
|
+
if bridge.has_native_support() and hasattr(bridge._native, "dir"):
|
|
78
|
+
code, items = bridge._native.dir(str(target_path))
|
|
79
|
+
else:
|
|
80
|
+
code, items = legacy.lgc_dir(target_path)
|
|
81
|
+
if code != 0:
|
|
82
|
+
return bridge.translate_error(code, str(target_path))
|
|
83
|
+
lines = [f"\nDirectory: '{target_path}'"]
|
|
84
|
+
for name, is_dir in items:
|
|
85
|
+
if is_dir:
|
|
86
|
+
lines.append(f"[DIR] {name}/")
|
|
87
|
+
else:
|
|
88
|
+
lines.append(f"[FILE] {name}")
|
|
89
|
+
lines.append(f"\nTotal items in directory: {len(items)}\n")
|
|
90
|
+
return (0, "\n".join(lines))
|
|
91
|
+
|
|
92
|
+
|
|
65
93
|
class Touch(BaseCmd):
|
|
66
94
|
name = "touch"
|
|
67
95
|
description = "Create an empty file or update existing file timestamps"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# src/flyshell/native/legacy/diskops.py
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
|
+
import os
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
def lgc_cat(target_path: Path) -> tuple[int, str]:
|
|
@@ -22,6 +23,30 @@ def lgc_cat(target_path: Path) -> tuple[int, str]:
|
|
|
22
23
|
return (-13, "") # ERR_IO
|
|
23
24
|
|
|
24
25
|
|
|
26
|
+
def lgc_dir(target_path: Path) -> tuple[int, list[tuple[str, bool]]]:
|
|
27
|
+
if not target_path.exists():
|
|
28
|
+
return (-1, []) # ERR_NOT_FOUND
|
|
29
|
+
if not target_path.is_dir():
|
|
30
|
+
return (-4, []) # ERR_NOT_DIR
|
|
31
|
+
try:
|
|
32
|
+
entries: list[tuple[str, bool]] = []
|
|
33
|
+
with os.scandir(target_path) as it:
|
|
34
|
+
for entry in it:
|
|
35
|
+
try:
|
|
36
|
+
entries.append((entry.name, entry.is_dir()))
|
|
37
|
+
except OSError:
|
|
38
|
+
entries.append((entry.name, False))
|
|
39
|
+
return (0, entries) # SUCCESS
|
|
40
|
+
except PermissionError:
|
|
41
|
+
return (-2, []) # ERR_PERMISSION
|
|
42
|
+
except OSError as e:
|
|
43
|
+
if getattr(e, "errno", None) == 20:
|
|
44
|
+
return (-4, []) # ERR_NOT_DIR
|
|
45
|
+
return (-13, []) # ERR_IO
|
|
46
|
+
except Exception:
|
|
47
|
+
return (-99, []) # ERR_UNKNOWN
|
|
48
|
+
|
|
49
|
+
|
|
25
50
|
def lgc_touch(target_path: Path) -> tuple[int, str]:
|
|
26
51
|
if target_path.is_dir():
|
|
27
52
|
return (-3, "") # ERR_IS_DIR
|
|
@@ -33,8 +58,8 @@ def lgc_touch(target_path: Path) -> tuple[int, str]:
|
|
|
33
58
|
except FileNotFoundError:
|
|
34
59
|
return (-1, "") # ERR_NOT_FOUND
|
|
35
60
|
except OSError as e:
|
|
36
|
-
if getattr(e, "errno", None) == 28:
|
|
37
|
-
return (-12, "")
|
|
61
|
+
if getattr(e, "errno", None) == 28:
|
|
62
|
+
return (-12, "") # ERR_NO_SPACE
|
|
38
63
|
return (-13, "") # ERR_IO
|
|
39
64
|
except Exception:
|
|
40
65
|
return (-99, "") # ERR_UNKNOWN
|
|
@@ -5,9 +5,13 @@ pyproject.toml
|
|
|
5
5
|
setup.py
|
|
6
6
|
c_src/diskops/diskops.c
|
|
7
7
|
c_src/diskops/posix/cat.c
|
|
8
|
+
c_src/diskops/posix/dir.c
|
|
8
9
|
c_src/diskops/posix/touch.c
|
|
10
|
+
c_src/diskops/shared/dir_types.c
|
|
11
|
+
c_src/diskops/shared/dir_types.h
|
|
9
12
|
c_src/diskops/shared/native_errors.h
|
|
10
13
|
c_src/diskops/win32/cat.c
|
|
14
|
+
c_src/diskops/win32/dir.c
|
|
11
15
|
c_src/diskops/win32/touch.c
|
|
12
16
|
src/flyshell/__init__.py
|
|
13
17
|
src/flyshell/constants.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|