flyshell 1.3.8__tar.gz → 1.3.9__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.
Files changed (59) hide show
  1. {flyshell-1.3.8/src/flyshell.egg-info → flyshell-1.3.9}/PKG-INFO +1 -1
  2. {flyshell-1.3.8 → flyshell-1.3.9}/c_src/diskops/diskops.c +14 -3
  3. flyshell-1.3.9/c_src/diskops/posix/touch.c +35 -0
  4. flyshell-1.3.9/c_src/diskops/win32/touch.c +54 -0
  5. {flyshell-1.3.8 → flyshell-1.3.9}/setup.py +2 -0
  6. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/builtin/diskops.py +0 -42
  7. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/constants.py +3 -2
  8. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/core/directory.py +1 -1
  9. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/native/diskops_handler.py +20 -0
  10. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/native/legacy/diskops.py +18 -0
  11. flyshell-1.3.9/src/flyshell/startup/__init__.py +0 -0
  12. {flyshell-1.3.8 → flyshell-1.3.9/src/flyshell.egg-info}/PKG-INFO +1 -1
  13. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell.egg-info/SOURCES.txt +3 -0
  14. {flyshell-1.3.8 → flyshell-1.3.9}/LICENSE +0 -0
  15. {flyshell-1.3.8 → flyshell-1.3.9}/MANIFEST.in +0 -0
  16. {flyshell-1.3.8 → flyshell-1.3.9}/README.md +0 -0
  17. {flyshell-1.3.8 → flyshell-1.3.9}/c_src/diskops/posix/cat.c +0 -0
  18. {flyshell-1.3.8 → flyshell-1.3.9}/c_src/diskops/shared/native_errors.h +0 -0
  19. {flyshell-1.3.8 → flyshell-1.3.9}/c_src/diskops/win32/cat.c +0 -0
  20. {flyshell-1.3.8 → flyshell-1.3.9}/pyproject.toml +0 -0
  21. {flyshell-1.3.8 → flyshell-1.3.9}/setup.cfg +0 -0
  22. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/__init__.py +0 -0
  23. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/abstract/__init__.py +0 -0
  24. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/abstract/base_cmd.py +0 -0
  25. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/abstract/base_plugin.py +0 -0
  26. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/abstract/parent_cmd.py +0 -0
  27. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/accounts/__init__.py +0 -0
  28. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/accounts/auth.py +0 -0
  29. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/bin/__init__.py +0 -0
  30. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/builtin/__init__.py +0 -0
  31. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/builtin/fs.py +0 -0
  32. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/builtin/pkg.py +0 -0
  33. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/builtin/system.py +0 -0
  34. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/builtin/utils.py +0 -0
  35. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/core/__init__.py +0 -0
  36. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/core/console.py +0 -0
  37. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/core/data.py +0 -0
  38. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/main.py +0 -0
  39. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/native/__init__.py +0 -0
  40. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/native/diskops_bridge.py +0 -0
  41. {flyshell-1.3.8/src/flyshell/startup → flyshell-1.3.9/src/flyshell/native/legacy}/__init__.py +0 -0
  42. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/startup/deps.py +0 -0
  43. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/startup/env.py +0 -0
  44. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell/startup/loader.py +0 -0
  45. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell.egg-info/dependency_links.txt +0 -0
  46. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell.egg-info/entry_points.txt +0 -0
  47. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell.egg-info/requires.txt +0 -0
  48. {flyshell-1.3.8 → flyshell-1.3.9}/src/flyshell.egg-info/top_level.txt +0 -0
  49. {flyshell-1.3.8 → flyshell-1.3.9}/tests/test_auth.py +0 -0
  50. {flyshell-1.3.8 → flyshell-1.3.9}/tests/test_data.py +0 -0
  51. {flyshell-1.3.8 → flyshell-1.3.9}/tests/test_deps.py +0 -0
  52. {flyshell-1.3.8 → flyshell-1.3.9}/tests/test_directory.py +0 -0
  53. {flyshell-1.3.8 → flyshell-1.3.9}/tests/test_diskops.py +0 -0
  54. {flyshell-1.3.8 → flyshell-1.3.9}/tests/test_env.py +0 -0
  55. {flyshell-1.3.8 → flyshell-1.3.9}/tests/test_fs.py +0 -0
  56. {flyshell-1.3.8 → flyshell-1.3.9}/tests/test_loader.py +0 -0
  57. {flyshell-1.3.8 → flyshell-1.3.9}/tests/test_pkg.py +0 -0
  58. {flyshell-1.3.8 → flyshell-1.3.9}/tests/test_security.py +0 -0
  59. {flyshell-1.3.8 → flyshell-1.3.9}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flyshell
3
- Version: 1.3.8
3
+ Version: 1.3.9
4
4
  Summary: A modular, zero-dependency command-line environment in Python.
5
5
  License-Expression: MIT
6
6
  Requires-Python: >=3.10
@@ -4,9 +4,10 @@
4
4
  #include <Python.h>
5
5
  #include "shared/native_errors.h"
6
6
 
7
- /* Prototype declared in both posix/cat.c and win32/cat.c */
8
7
  Result cat(const char* path, char** out_buf, size_t* out_size);
9
8
 
9
+ Result touch(const char* path);
10
+
10
11
  static PyObject* method_ping(PyObject* self, PyObject* args) {
11
12
  return PyLong_FromLong(42);
12
13
  }
@@ -25,7 +26,6 @@ static PyObject* method_cat(PyObject* self, PyObject* args) {
25
26
  return Py_BuildValue("(is)", (int)res, "");
26
27
  }
27
28
 
28
- /* Convert C buffer to Python unicode string */
29
29
  PyObject* content = PyUnicode_FromStringAndSize(buf, size);
30
30
  free(buf);
31
31
 
@@ -38,10 +38,21 @@ static PyObject* method_cat(PyObject* self, PyObject* args) {
38
38
  return ret;
39
39
  }
40
40
 
41
+ static PyObject* method_touch(PyObject* self, PyObject* args) {
42
+ const char* path;
43
+ if (!PyArg_ParseTuple(args, "s", &path)) {
44
+ return NULL;
45
+ }
46
+
47
+ Result res = touch(path);
48
+ return Py_BuildValue("(is)", (int)res, "");
49
+ }
50
+
41
51
  static PyMethodDef DiskopsMethods[] = {
42
52
  {"ping", method_ping, METH_NOARGS, "Health check ping."},
43
53
  {"cat", method_cat, METH_VARARGS, "Read file content natively."},
44
- {NULL, NULL, 0, NULL}
54
+ {"touch", method_touch, METH_VARARGS, "Touch or create file natively."},
55
+ {NULL, NULL, 0, NULL},
45
56
  };
46
57
 
47
58
  static struct PyModuleDef diskopsmodule = {
@@ -0,0 +1,35 @@
1
+ // c_src/diskops/posix/touch.c
2
+
3
+ #define _POSIX_C_SOURCE 200809L
4
+ #define _GNU_SOURCE
5
+
6
+ #include <fcntl.h>
7
+ #include <sys/stat.h>
8
+ #include <unistd.h>
9
+ #include <errno.h>
10
+ #include "../shared/native_errors.h"
11
+
12
+ Result touch(const char* path) {
13
+ if (!path || path[0] == '\0') {
14
+ return ERR_INVALID_PATH;
15
+ }
16
+
17
+ struct stat st;
18
+ if (stat(path, &st) == 0) {
19
+ if (S_ISDIR(st.st_mode)) {
20
+ return ERR_IS_DIR;
21
+ }
22
+ if (utimensat(AT_FDCWD, path, NULL, 0) != 0) {
23
+ return map_posix_errno(errno);
24
+ }
25
+ return SUCCESS;
26
+ }
27
+
28
+ int fd = open(path, O_WRONLY | O_CREAT | O_NONBLOCK | O_NOCTTY, 0666);
29
+ if (fd < 0) {
30
+ return map_posix_errno(errno);
31
+ }
32
+
33
+ close(fd);
34
+ return SUCCESS;
35
+ }
@@ -0,0 +1,54 @@
1
+ // c_src/diskops/win32/touch.c
2
+
3
+ #include <windows.h>
4
+ #include <stdlib.h>
5
+ #include "../shared/native_errors.h"
6
+
7
+ Result touch(const char* path) {
8
+ if (!path || path[0] == '\0') {
9
+ return ERR_INVALID_PATH;
10
+ }
11
+
12
+ int wlen = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0);
13
+ if (wlen <= 0) {
14
+ return ERR_INVALID_PATH;
15
+ }
16
+
17
+ wchar_t* wpath = (wchar_t*)malloc(wlen * sizeof(wchar_t));
18
+ if (!wpath) {
19
+ return ERR_IO;
20
+ }
21
+ MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, wlen);
22
+
23
+ DWORD attrs = GetFileAttributesW(wpath);
24
+ if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY)) {
25
+ free(wpath);
26
+ return ERR_IS_DIR;
27
+ }
28
+
29
+ HANDLE hFile = CreateFileW(
30
+ wpath,
31
+ FILE_WRITE_ATTRIBUTES,
32
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
33
+ NULL,
34
+ OPEN_ALWAYS,
35
+ FILE_ATTRIBUTE_NORMAL,
36
+ NULL
37
+ );
38
+
39
+ if (hFile == INVALID_HANDLE_VALUE) {
40
+ DWORD err = GetLastError();
41
+ free(wpath);
42
+ return map_win32_error(err);
43
+ }
44
+ free(wpath);
45
+
46
+ FILETIME ft;
47
+ SYSTEMTIME st;
48
+ GetSystemTime(&st);
49
+ SystemTimeToFileTime(&st, &ft);
50
+ SetFileTime(hFile, NULL, &ft, &ft);
51
+
52
+ CloseHandle(hFile);
53
+ return SUCCESS;
54
+ }
@@ -9,8 +9,10 @@ sources = [
9
9
 
10
10
  if sys.platform == "win32":
11
11
  sources.append("c_src/diskops/win32/cat.c")
12
+ sources.append("c_src/diskops/win32/touch.c")
12
13
  else:
13
14
  sources.append("c_src/diskops/posix/cat.c")
15
+ sources.append("c_src/diskops/posix/touch.c")
14
16
 
15
17
  native_diskops = Extension(
16
18
  name="flyshell.bin._native_diskops",
@@ -446,45 +446,3 @@ class RmDir(BaseCmd):
446
446
  1,
447
447
  f"\nSystem Error: Unexpected error removing '{raw_target}' ({e})\n",
448
448
  )
449
-
450
-
451
- class Touch(BaseCmd):
452
- name = "touch"
453
- description = "Create a new empty file or update timestamps of an existing file"
454
- min_args = 1
455
- options = "Target file"
456
- aliases = []
457
-
458
- def execute(self, args):
459
- raw_target = " ".join(args).strip("\"'")
460
- target_path = Path(raw_target).expanduser().resolve()
461
- if target_path.is_dir():
462
- return (
463
- 1,
464
- f"\nCommand Error: '{raw_target}' is a directory, not a file.\n",
465
- )
466
- if not target_path.parent.exists():
467
- return (
468
- 1,
469
- f"\nSystem Error: Cannot create file '{raw_target}'. Parent directory does not exist.\n",
470
- )
471
- try:
472
- if target_path.exists():
473
- target_path.touch()
474
- return (
475
- 0,
476
- f"\nSUCCESS! Updated timestamp for existing file '{raw_target}'\n",
477
- )
478
- else:
479
- target_path.touch(exist_ok=False)
480
- return (0, f"\nSUCCESS! Created file '{raw_target}'\n")
481
- except PermissionError:
482
- return (
483
- 1,
484
- f"\nSystem Error: Permission denied. Cannot access '{raw_target}'.\n",
485
- )
486
- except Exception as e:
487
- return (
488
- 1,
489
- f"\nSystem Error: Failed to touch file '{raw_target}' ({e})\n",
490
- )
@@ -5,8 +5,8 @@ import os
5
5
  import platform
6
6
  import time
7
7
 
8
- BUILD = 148
9
- VERSION = "1.3.8"
8
+ BUILD = 149
9
+ VERSION = "1.3.9"
10
10
 
11
11
 
12
12
  def _resolve_app_dir() -> Path:
@@ -73,6 +73,7 @@ REQUIRED_COMPONENTS = [
73
73
  "main.py",
74
74
  "native",
75
75
  "native/__init__.py",
76
+ "native/legacy/__init__.py",
76
77
  "native/legacy/diskops.py",
77
78
  "native/diskops_bridge.py",
78
79
  "native/diskops_handler.py",
@@ -75,7 +75,7 @@ INSTALLED_COMMANDS: list[BaseCmd] = [
75
75
  diskops_legacy.RmDir(),
76
76
  utils.Sleep(),
77
77
  system.SysExe(),
78
- diskops_legacy.Touch(),
78
+ diskops.Touch(),
79
79
  ]
80
80
 
81
81
  COMMAND_REGISTRY: dict[str, BaseCmd] = {}
@@ -60,3 +60,23 @@ class Cat(BaseCmd):
60
60
  output_lines.append(clean_line)
61
61
  output_lines.append(f"\nEnd of '{target_path.name}'\n")
62
62
  return (0, "\n".join(output_lines))
63
+
64
+
65
+ class Touch(BaseCmd):
66
+ name = "touch"
67
+ description = "Create an empty file or update existing file timestamps"
68
+ min_args = 1
69
+ options = "Target file"
70
+
71
+ def execute(self, args):
72
+ if not args:
73
+ return (1, "\nCommand Error: Target file not specified.\n")
74
+ raw_target = " ".join(args).strip("\"'")
75
+ target_path = Path(raw_target).expanduser().resolve()
76
+ if bridge.has_native_support() and hasattr(bridge._native, "touch"):
77
+ code, _ = bridge._native.touch(str(target_path))
78
+ else:
79
+ code, _ = legacy.lgc_touch(target_path)
80
+ if code != 0:
81
+ return bridge.translate_error(code, raw_target)
82
+ return (0, f"\nSUCCESS! File '{raw_target}' touched successfully.\n")
@@ -20,3 +20,21 @@ def lgc_cat(target_path: Path) -> tuple[int, str]:
20
20
  return (-14, "") # ERR_DECODE
21
21
  except Exception:
22
22
  return (-13, "") # ERR_IO
23
+
24
+
25
+ def lgc_touch(target_path: Path) -> tuple[int, str]:
26
+ if target_path.is_dir():
27
+ return (-3, "") # ERR_IS_DIR
28
+ try:
29
+ target_path.touch(exist_ok=True)
30
+ return (0, "") # SUCCESS
31
+ except PermissionError:
32
+ return (-2, "") # ERR_PERMISSION
33
+ except FileNotFoundError:
34
+ return (-1, "") # ERR_NOT_FOUND
35
+ except OSError as e:
36
+ if getattr(e, "errno", None) == 28: # ENOSPC
37
+ return (-12, "")
38
+ return (-13, "") # ERR_IO
39
+ except Exception:
40
+ return (-99, "") # ERR_UNKNOWN
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flyshell
3
- Version: 1.3.8
3
+ Version: 1.3.9
4
4
  Summary: A modular, zero-dependency command-line environment in Python.
5
5
  License-Expression: MIT
6
6
  Requires-Python: >=3.10
@@ -5,8 +5,10 @@ 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/touch.c
8
9
  c_src/diskops/shared/native_errors.h
9
10
  c_src/diskops/win32/cat.c
11
+ c_src/diskops/win32/touch.c
10
12
  src/flyshell/__init__.py
11
13
  src/flyshell/constants.py
12
14
  src/flyshell/main.py
@@ -36,6 +38,7 @@ src/flyshell/core/directory.py
36
38
  src/flyshell/native/__init__.py
37
39
  src/flyshell/native/diskops_bridge.py
38
40
  src/flyshell/native/diskops_handler.py
41
+ src/flyshell/native/legacy/__init__.py
39
42
  src/flyshell/native/legacy/diskops.py
40
43
  src/flyshell/startup/__init__.py
41
44
  src/flyshell/startup/deps.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