love.filesystem

来源:互联网 发布:最大公约数 方法 知乎 编辑:程序博客网 时间:2024/06/05 16:24
2017年4月1日23:21:20更新

love.filesystem

提供用户文件系统的接口。

此模块提供访问特定位置的文件,如:

  •  .love archive的根目录 (或源文件目录)
  • 游戏存档保存的目录
  • The folder containing the game's .love archive (或源文件目录), but only if specific conditions are met.

通过love.filesystem 可以在系统中获取一个文件夹用来保存数据.  这些目录通常是已下:

  • Windows XP: C:\Documents and Settings\user\Application Data\LOVE\ or %appdata%\LOVE\
  • Windows Vista and 7: C:\Users\user\AppData\Roaming\LOVE or %appdata%\LOVE\
  • Linux: $XDG_DATA_HOME/love/ or ~/.local/share/love/
  • Mac: /Users/user/Library/Application Support/LOVE/
  • Android: /data/user/0/org.love2d.android/files/save/ or /data/data/org.love2d.android/files/save/ (在Android上有各种保存位置. 如果使用默认目录请在 love.filesystem.getSaveDirectory() 查看.)

Files that are opened for write or append will always be created in the save directory. The same goes for other operations that involve writing to the filesystem, like mkdir.

Files that are opened for read will be looked for in the save directory, and then in the .love archive (in that order). So if a file with a certain filename (and path) exist in both the .love archive and the save folder, the one in the save directory takes precedence.

提示: All paths are relative to the .love archive and save directory. (except for the get*Directory() calls)

可以在你的 conf.lua 中设置. 你也可以在love.filesystem.setIdentity 设置.

类型

File表示文件系统上的文件。  FileDataData 表示文件的内容  

函数

love.filesystem.append将数据附加到现有文件。Added since 0.9.0 love.filesystem.areSymlinksEnabledGets whether love.filesystem follows symbolic links.Added since 0.9.2 love.filesystem.createDirectory创建目录。Added since 0.9.0 love.filesystem.enumerate返回所有文件和子目录Added since 0.3.0Removed in0.9.0love.filesystem.exists检查文件或目录是否存在。  love.filesystem.getAppdataDirectory返回应用程序数据目录 (可能和 getUserDirectory相同)  love.filesystem.getDirectoryItems返回所有文件和子目录的文件。Added since 0.9.0 love.filesystem.getIdentityGets the write directory name for your game.Added since 0.9.0 love.filesystem.getLastModified获取文件的最后修改时间。Added since 0.7.1 love.filesystem.getRealDirectory获取包含文件的绝对路径。Added since 0.9.2 love.filesystem.getRequirePathGets the filesystem paths that will be searched when require is called.Added since0.10.0 love.filesystem.getSaveDirectory获取指定保存目录的完整路径。  love.filesystem.getSize获取文件的字节大小.Added since 0.9.0 love.filesystem.getSourceReturns the full path to the directory containing the .love file or directory.Added since 0.9.0 love.filesystem.getSourceBaseDirectoryReturns the full path to the directory containing the .love file.Added since 0.9.0 love.filesystem.getUserDirectory返回用户目录的路径  love.filesystem.getWorkingDirectory获取当前工作目录。  love.filesystem.initInitializes love.filesystem, will be called internally, so should not be used explictly.  love.filesystem.isDirectory检查是否是个目录  love.filesystem.isFile检查是否是个文件  love.filesystem.isFusedGets whether the game is in fused mode or not.Added since 0.9.0 love.filesystem.isSymlinkGets whether a filepath is actually a symbolic link.Added since 0.9.2 love.filesystem.lines遍历文件中的行。  love.filesystem.load加载Lua文件 (不运行).  love.filesystem.mkdir创建目录 Removed in0.9.0love.filesystem.mountMounts a zip file or folder in the game's save directory for reading.Added since 0.9.0 love.filesystem.newFile创建一个新的文件对象  love.filesystem.newFileData创建一个新的文件数据 对象Added since 0.7.0 love.filesystem.read读取文件的内容  love.filesystem.remove删除文件或目录  love.filesystem.setIdentitySets the write directory for your game.  love.filesystem.setRequirePathSets the filesystem paths that will be searched when require is called.Added since0.10.0 love.filesystem.setSourceSets the source of the game, where the code is present. Used internally.  love.filesystem.setSymlinksEnabledSets whether love.filesystem follows symbolic links.Added since 0.9.2 love.filesystem.unmountUnmounts a zip file or folder previously mounted with love.filesystem.mount.Added since 0.9.0 love.filesystem.write将数据写入文件。  

枚举类型

FileDecoder如何解码一个给定的FileDataAdded since 0.7.0 FileModeThe different modes you can open a File in.  
0 0
原创粉丝点击