nativefs

版本 v1.0.1·更新於 2024-04-17

nativefs replicates a subset of the love.filesystem API, but without LÖVE's path restrictions.

模組介紹 作者原文

This is a package mirror of EngineerSmith's nativefs repository with an added lovely patch....

This is a re-host as previously it was taken down by the original developer. Pull requests for fixes are welcome!

Native filesystem for LÖVE

nativefs replicates a subset of the love.filesystem API, but without LÖVE's path restrictions.

Available functions

nativefs

Links in this list point to their love.filesystem counterparts. All functions are designed to behave the same way as love.filesystem, but without the path restrictions that LÖVE imposes; i.e., they allow full access to the filesystem.

  • nativefs.newFile
  • nativefs.newFileData
  • nativefs.mount
  • nativefs.unmount
  • nativefs.read
  • nativefs.write
  • nativefs.append
  • nativefs.lines
  • nativefs.load
  • nativefs.getWorkingDirectory
  • nativefs.getDirectoryItems
  • nativefs.getInfo
  • nativefs.createDirectory
  • nativefs.remove
  • nativefs.getDirectoryItemsInfo
  • nativefs.getDriveList
  • nativefs.setWorkingDirectory

Additional nativefs functions

Functions that are not available in love.filesystem:

  • nativefs.getDirectoryItemsInfo(path)

Returns a list of items in a directory that contains not only the names, but also the information returned by getInfo for each item. The return value is a list of files and directories, in which each entry is a table as returned by getInfo, with an additional name field for each entry. Using this function is faster than calling getInfo separately for each item.

  • nativefs.getDriveList()

Returns a table with all populated drive letters on Windows ({ 'C:/', 'D:/',...}). On systems that don't use drive letters, a table with the single entry / is returned.

  • nativefs.setWorkingDirectory(directory)

Changes the working directory.

File

nativefs.newFile returns a File object that provides these functions:

  • File:open:open)
  • File:close:close)
  • File:read:read)
  • File:write:write)
  • File:lines:lines)
  • File:isOpen:isOpen)
  • File:isEOF:isEOF)
  • File:getFilename:getFilename)
  • File:getMode:getMode)
  • File:getBuffer:getBuffer)
  • File:setBuffer:setBuffer)
  • File:getSize:getSize)
  • File:seek:seek)
  • File:tell:tell)
  • File:flush:flush)
  • File:type
  • File:typeOf
  • File:release

Function names in this list are links to their LÖVE File counterparts. File is designed to work the same way as LÖVE's File objects.

Example

local nativefs = require("nativefs")

-- Prints all information on files in C:\Windows

local files = nativefs.getDirectoryItemsInfo("C:/Windows")

for i = 1, #files do

if files[i].type == "file" then

local info = nativefs.getInfo("C:/Windows/".. files[i].name)

print(i.. ": ".. files[i].. ": Type:".. info.type.. ", Size:".. tostring(info.size).. ", last modified:".. tostring(info.modtime))

end

end

License

Copyright 2020 megagrump@pm.me

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

安裝與使用 安裝:按包內說明操作

  1. 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
  2. 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
  3. 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
  4. 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。

不同模組的安裝位置差異較大,包內說明是最可靠的依據。 這類模組需要先安裝社群載入器(包內 readme 通常會提供下載入口)。

前置依賴

下面這些內容需要先安裝,否則該模組不會生效:

lovely

檔案與校驗

檔案名稱
nativefs-1.0.1.zip
檔案大小
146.3 KiB