Added Required logic if not found, and added better update logic
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
---@meta LfsTypes
|
||||
|
||||
---@alias lfs.AttributeName
|
||||
---|'dev' -- on Unix systems, this represents the device that the inode resides on. On Windows systems, represents the drive number of the disk containing the file
|
||||
---|'ino' -- on Unix systems, this represents the inode number. On Windows systems this has no meaning
|
||||
---|'mode' -- string representing the associated protection mode (the values could be file, directory, link, socket, named pipe, char device, block device or other)
|
||||
---|'nlink' -- number of hard links to the file
|
||||
---|'uid' -- user-id of owner (Unix only, always 0 on Windows)
|
||||
---|'gid' -- group-id of owner (Unix only, always 0 on Windows)
|
||||
---|'rdev' -- on Unix systems, represents the device type, for special file inodes. On Windows systems represents the same as dev
|
||||
---|'access' -- time of last access
|
||||
---|'modification' -- time of last data modification
|
||||
---|'change' -- time of last file status change
|
||||
---|'size' -- file size, in bytes
|
||||
---|'permissions' -- file permissions string
|
||||
---|'blocks' -- block allocated for file; (Unix only)
|
||||
---|'blksize' -- optimal file system I/O blocksize; (Unix only)
|
||||
|
||||
---@alias lfs.AttributeMode
|
||||
---|'file'
|
||||
---|'directory'
|
||||
---|'link'
|
||||
---|'socket'
|
||||
---|'char device'
|
||||
---|"block device"
|
||||
---|"named pipe"
|
||||
|
||||
---@class lfs.Attributes
|
||||
---@field [lfs.AttributeName] any
|
||||
---@field ['mode'] lfs.AttributeMode
|
||||
|
||||
---@alias lfs.FileMode
|
||||
---| "binary"
|
||||
---| "text"
|
||||
|
||||
---@class lfs.Lock
|
||||
---@field free fun() Releases the lock on the file/directory.
|
||||
|
||||
---@class lfs.DirObject
|
||||
---@field next fun(self: lfs.DirObject): string? Returns a directory entry's name as a string, or `nil` if there are no more entries.
|
||||
---@field close fun(self: lfs.DirObject) Explicitly closes the directory before iteration finishes.
|
||||
|
||||
---@class lfs
|
||||
---@field attributes fun(path:string, result_param: lfs.AttributeName | lfs.Attributes | table): lfs.Attributes? Returns a table with the file attributes corresponding to filepath (or `nil` followed by an error message and a system-dependent error code in case of error). If the second optional argument is given and is a string, then only the value of the named attribute is returned (this use is equivalent to lfs.attributes(filepath)[request_name], but the table is not created and only one attribute is retrieved from the O.S.). if a table is passed as the second argument, it (result_table) is filled with attributes and returned instead of a new table
|
||||
---@field chdir fun(path:string) : boolean?, string? Changes the current working directory to the given path. <br> Returns true in case of success or `nil` plus an error string.
|
||||
---@field lock_dir fun(path:string, seconds_stale: number?) : lfs.Lock?, string? Creates a lockfile (called lockfile.lfs) in path if it does not exist and returns the lock. If the lock already exists checks if it's stale, using the second parameter (default for the second parameter is `INT_MAX`, which in practice means the lock will never be stale. To free the the lock call `lock:free()`. <br>In case of any errors it returns `nil` and the error message. In particular, if the lock exists and is not stale it returns the "File exists" message.
|
||||
---@field currentdir fun(): string?, string? Returns a string with the current working directory or `nil` plus an error string.
|
||||
---@field dir fun(path: string): fun(): string?, lfs.DirObject Lua iterator over the entries of a given directory. Each time the iterator is called with `dir_obj` it returns a directory entry's name as a string, or `nil` if there are no more entries. You can also iterate by calling `dir_obj:next()`, and explicitly close the directory before the iteration finished with `dir_obj:close()`. Raises an error if `path` is not a directory.
|
||||
---@field lock fun(filehandle, mode: string, start?: number, length?: number): boolean?, string? Locks a file or a part of it. The mode can be `'r'` (read/shared lock) or `'w'` (write/exclusive lock). Returns `true` if successful, or `nil` plus an error string in case of error.
|
||||
---@field link fun(old: string, new: string, symlink?: boolean): boolean?, string?, number? Creates a link. If the optional third argument is true, creates a symbolic link; otherwise creates a hard link.
|
||||
---@field mkdir fun(dirname: string): boolean?, string?, number? Creates a new directory. Returns `true` in case of success or `nil`, an error message and a system-dependent error code in case of error.
|
||||
---@field rmdir fun(dirname: string): boolean?, string?, number? Removes an existing directory. Returns `true` in case of success or `nil`, an error message and a system-dependent error code in case of error.
|
||||
---@field setmode fun(file, mode: lfs.FileMode): boolean?, string? Sets the writing mode for a file. The mode can be `'binary'` or `'text'`. Returns `true` followed by the previous mode string, or `nil` followed by an error string in case of error. On non-Windows platforms, setting the mode has no effect and is always returned as `'binary'`.
|
||||
---@field symlinkattributes fun(filepath: string, request_name?: lfs.AttributeName | string): lfs.Attributes? | any Gets information about a symlink itself (not the file it refers to). Identical to `lfs.attributes` but also adds a `target` field containing the filename the symlink points to. On Windows, this is identical to `lfs.attributes`.
|
||||
---@field touch fun(filepath: string, atime?: number, mtime?: number): boolean?, string?, number? Sets access and modification times of a file. Times are in seconds (from `os.time()`). If `mtime` is omitted, `atime` is used; if both are omitted, the current time is used. Returns `true` in case of success or `nil`, an error message and a system-dependent error code in case of error.
|
||||
---@field unlock fun(filehandle, start?: number, length?: number): boolean?, string? Unlocks a file or a part of it. Returns `true` if successful, or `nil` plus an error string in case of error.
|
||||
|
||||
---@class DcsLfs : lfs
|
||||
---@field tempdir fun(): string Returns the DCS temporary directory.
|
||||
---@field writedir fun(): string Returns the Saved Games directory.
|
||||
---@field realpath fun(path: string): string Returns the absolute path of a file.
|
||||
---@field normpath fun(path: string): string Returns the normalized path.
|
||||
---@field md5sum fun(path: string): string Returns the MD5 checksum of the file at the given path.
|
||||
---@field locations fun(): table Returns available drives.
|
||||
|
||||
-- In DCS lfs can be removed, hence the option of it being `nil`.
|
||||
---@type DcsLfs|nil
|
||||
lfs = lfs or nil
|
||||
Reference in New Issue
Block a user