File

package
v0.0.0-...-3e87f45 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2022 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

* @Author: NyanCatda * @Date: 2022-03-22 21:59:31 * @LastEditTime: 2022-03-23 21:43:03 * @LastEditors: NyanCatda * @Description: 目录操作 * @FilePath: \Momizi\Internal\Plugin\JavaScript\Tools\File\Dir.go

* @Author: NyanCatda * @Date: 2022-03-22 21:57:52 * @LastEditTime: 2022-03-23 21:43:24 * @LastEditors: NyanCatda * @Description: 文件操作函数注册 * @FilePath: \Momizi\Internal\Plugin\JavaScript\Tools\File\File.go

* @Author: NyanCatda * @Date: 2022-03-23 13:57:19 * @LastEditTime: 2022-03-27 21:22:48 * @LastEditors: NyanCatda * @Description:文件读写操作 * @FilePath: \Momizi\Internal\Plugin\JavaScript\Tools\File\ReadWrite.go

Index

Constants

This section is empty.

Variables

View Source
var DataPath = Controller.DataPath + "/"

Functions

func RegistrationFunction

func RegistrationFunction(VM *goja.Runtime) error

*

  • @description: 注册文件操作函数
  • @param {*goja.Runtime} VM
  • @return {*}

Types

type File

type File struct {
	VM *goja.Runtime
}

func (File) Copy

func (File File) Copy(Path string, NewPath string) (int64, bool)

*

  • @description: 复制文件
  • @param {string} Path 路径
  • @param {string} NewPath 新路径
  • @return {int64} 文件大小(Byte)
  • @return {bool} 是否成功

func (File) Delete

func (File File) Delete(Path string) bool

*

  • @description: 删除文件/文件夹
  • @param {string} Path 路径
  • @return {bool} 是否成功

func (File) Exists

func (File File) Exists(Path string) bool

*

  • @description: 判断文件/文件夹是否存在
  • @param {string} Path 路径
  • @return {*}

func (File) GetFileSize

func (File File) GetFileSize(FilePath string) int64

*

  • @description: 获取文件大小
  • @param {string} FilePath 文件路径
  • @return {int64} 文件大小(Byte)

func (File) GetFilesList

func (File File) GetFilesList(Path string) []string

列出文件夹下的全部文件(包含子目录)

func (File) IsDir

func (File File) IsDir(Path string) bool

*

  • @description: 判断是否是文件夹
  • @param {string} Path 路径
  • @return {bool} 是否是文件夹

func (File) MKDir

func (File File) MKDir(Path string) bool

*

  • @description: 创建文件夹
  • @param {string} Path
  • @return {*}

func (File) Move

func (File File) Move(Path string, NewPath string) bool

*

  • @description: 移动文件
  • @param {string} Path 路径
  • @param {string} NewPath 新路径
  • @return {bool} 是否成功

func (File) Read

func (File File) Read(Path string) any

*

  • @description: 读取文件
  • @param {string} Path 文件路径
  • @return {string} 文件内容(读取失败返回nil)

func (File) ReadAsync

func (File File) ReadAsync(Path string, Callback goja.Callable)

*

  • @description: 异步读取文件
  • @param {string} Path 文件路径
  • @param {goja.Callable} Callback 回调函数
  • @return {string} 文件内容(读取失败返回nil)

func (File) WriteAppend

func (File File) WriteAppend(Path string, Content string) bool

*

  • @description: 追加写入文件
  • @param {string} Path 文件路径
  • @param {string} Content 文件内容
  • @return {bool} 是否成功

func (File) WriteAppendAsync

func (File File) WriteAppendAsync(Path string, Content string, Callback goja.Callable)

*

  • @description: 异步追加写入文件
  • @param {string} Path 文件路径
  • @param {string} Content 文件内容
  • @param {goja.Callable} Callback 回调函数
  • @return {bool} 是否成功

func (File) WriteTo

func (File File) WriteTo(Path string, Content string) bool

*

  • @description: 覆盖写入文件
  • @param {string} Path 文件路径
  • @param {string} Content 文件内容
  • @return {bool} 是否成功

func (File) WriteToAsync

func (File File) WriteToAsync(Path string, Content string, Callback goja.Callable)

*

  • @description: 异步覆盖写入文件
  • @param {string} Path 文件路径
  • @param {string} Content 文件内容
  • @param {goja.Callable} Callback 回调函数
  • @return {bool} 是否成功

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL