forked from zeng-github01/OC-Doc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilesystem.lua
More file actions
143 lines (117 loc) · 4.65 KB
/
filesystem.lua
File metadata and controls
143 lines (117 loc) · 4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
---@meta
--- OpenComputers Filesystem API
---
--- Provides utilities for interacting with file system components and the global directory tree.
---@class FilesystemLib
local filesystem = {}
--- Returns whether autorun is enabled for new filesystems.
---@return boolean True if autorun is enabled
function filesystem.isAutorunEnabled() end
--- Sets whether autorun files should be run on startup.
---@param value boolean Enable or disable autorun
function filesystem.setAutorunEnabled(value) end
--- Returns the canonical form of a path (no . or .. segments).
---@param path string Path to canonicalize
---@return string Canonical path
function filesystem.canonical(path) end
--- Returns a table of canonical path segments.
---@param path string Path to split
---@return table Segments
function filesystem.segments(path) end
--- Concatenates two or more paths, returns canonical result.
---@param pathA string First path
---@param ... string Additional paths
---@return string Concatenated path
function filesystem.concat(pathA, ...) end
--- Returns the directory part of a path.
---@param path string Path
---@return string Directory path
function filesystem.path(path) end
--- Returns the file name part of a path.
---@param path string Path
---@return string File name
function filesystem.name(path) end
--- Gets the proxy for a filesystem by address or label.
---@param filter string Address or label
---@return table|nil Proxy or nil
---@return string? Error message
function filesystem.proxy(filter) end
--- Mounts a filesystem at the specified path.
---@param fs table|string Proxy, address, or label
---@param path string Mount path
---@return boolean|nil True if mounted, nil on error
---@return string? Error message
function filesystem.mount(fs, path) end
--- Returns an iterator over all mounted filesystems and their paths.
---@return function Iterator function
function filesystem.mounts() end
--- Unmounts a filesystem by proxy, address, or path.
---@param fsOrPath table|string Proxy, address, or path
---@return boolean True if unmounted
function filesystem.umount(fsOrPath) end
--- Checks if a path is a symlink. Returns link target if so.
---@param path string Path
---@return boolean True if symlink
---@return string? Link target
function filesystem.isLink(path) end
--- Creates a symbolic link at linkpath to target.
---@param target string Target path
---@param linkpath string Link path
---@return boolean|nil True if link created, nil on error
---@return string? Error message
function filesystem.link(target, linkpath) end
--- Gets the proxy for the filesystem containing the path.
---@param path string Path
---@return table|nil Proxy or nil
---@return string? Mount path or error
function filesystem.get(path) end
--- Checks if a file or folder exists at the path.
---@param path string Path
---@return boolean True if exists
function filesystem.exists(path) end
--- Gets the file size at the path (0 if not a file).
---@param path string Path
---@return number File size
function filesystem.size(path) end
--- Checks if the path is a directory.
---@param path string Path
---@return boolean True if directory
function filesystem.isDirectory(path) end
--- Gets the last modified unix timestamp of the file or directory.
---@param path string Path
---@return number Unix timestamp
function filesystem.lastModified(path) end
--- Returns an iterator over directory contents.
---@param path string Directory path
---@return function Iterator function
---@return string? Error message
function filesystem.list(path) end
--- Creates a new directory (and parents if needed).
---@param path string Directory path
---@return boolean|nil True if created, nil on error
---@return string? Error message
function filesystem.makeDirectory(path) end
--- Removes a file or directory (recursively for directories).
---@param path string Path
---@return boolean|nil True if removed, nil on error
---@return string? Error message
function filesystem.remove(path) end
--- Renames a file or directory.
---@param oldPath string Old path
---@param newPath string New path
---@return boolean|nil True if renamed, nil on error
---@return string? Error message
function filesystem.rename(oldPath, newPath) end
--- Copies a file to a new location.
---@param fromPath string Source file
---@param toPath string Destination file
---@return boolean|nil True if copied, nil on error
---@return string? Error message
function filesystem.copy(fromPath, toPath) end
--- Opens a file for reading or writing. Returns a file stream.
---@param path string File path
---@param mode string? Open mode ("r", "w", etc.)
---@return table|nil File stream or nil
---@return string? Error message
function filesystem.open(path, mode) end
return filesystem