vvvfs 0.0.1-alpha.2 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,7 +30,7 @@ const VVVFS = require("vvvfs"); // CommonJS
30
30
  3. 初始化
31
31
 
32
32
  ```javascript
33
- const vvvfs = new VVFS("vvvfs"); // 创建一个名为vvvfs的虚拟文件系统
33
+ const vvvfs = new VVVFS("vvvfs"); // 创建一个名为vvvfs的虚拟文件系统
34
34
  ```
35
35
 
36
36
  4. 使用
@@ -39,18 +39,18 @@ const vvvfs = new VVFS("vvvfs"); // 创建一个名为vvvfs的虚拟文件系统
39
39
  // 所有操作都是异步的
40
40
  (async function () {
41
41
  await vvvfs.reset(); // 重置文件系统
42
- await vvvfs.mkdir("/home/user/Desktop"); // 创建目录
43
- await vvvfs.write(
42
+ await vvvfs.createDir("/home/user/Desktop"); // 创建目录,返回true和false
43
+ await vvvfs.writeText(
44
44
  "/home/user/Desktop/test.txt",
45
- new File(["Hello World!"], "test.txt", { type: "text/plain" }),
46
- ); // 写入文件
47
- console.log(await vvvfs.read("/home/user/Desktop/test.txt")); // 读取文件
48
- await vvvfs.delete("/home/user/Desktop/test.txt"); // 删除文件
45
+ "Hello World!"
46
+ ); // 写入文本文件,写入文件还包括write(path: string, content: Blob)和writeJson(path: string, content: Record<string, any>)方法,返回true和false
47
+ console.log(await vvvfs.readText("/home/user/Desktop/test.txt")); // 读取文本文件,读取文件还包括read(path: string): Blob和readJson(path: string): Record<string, any>方法
48
+ await vvvfs.delete("/home/user/Desktop/test.txt"); // 删除文件,返回true和false
49
49
  if (await vvvfs.exists("/home/user/Desktop")) {
50
- // 判断目录是否存在
50
+ // 判断文件或目录是否存在
51
51
  }
52
- console.log(await vvvfs.list("/home/user/Desktop")); // 列出目录下的文件
53
- if (await vvvfs.isDirectory("/home/user/Desktop")) {
52
+ console.log(await vvvfs.list("/home/user/Desktop")); // 列出目录下的文件,返回string[]
53
+ if (await vvvfs.isDir("/home/user/Desktop")) {
54
54
  // 判断是否为目录
55
55
  }
56
56
  if (await vvvfs.isFile("/home/user/Desktop/test.txt")) {
@@ -58,17 +58,16 @@ const vvvfs = new VVFS("vvvfs"); // 创建一个名为vvvfs的虚拟文件系统
58
58
  }
59
59
  await vvvfs.rename(
60
60
  "/home/user/Desktop/test.txt",
61
- "/home/user/Desktop/test2.txt",
62
- ); // 重命名文件
61
+ "test2.txt",
62
+ ); // 重命名文件,返回true和false
63
63
  await vvvfs.move(
64
64
  "/home/user/Desktop/test2.txt",
65
65
  "/home/user/Desktop/test.txt",
66
- ); // 移动文件
66
+ ); // 移动文件,返回true和false
67
67
  await vvvfs.copy(
68
68
  "/home/user/Desktop/test.txt",
69
69
  "/home/user/Desktop/test2.txt",
70
- ); // 复制文件
71
- await vvvfs.chmod("/home/user/Desktop/test.txt", 0o777); // 修改文件权限
72
- await vvvfs.chown("/home/user/Desktop/test.txt", "root", "root"); // 修改文件所有者
70
+ ); // 复制文件,返回true和false
71
+ await vvvfs.search("/home/user/Desktop", "test.txt"); // 搜索文件,返回string[]
73
72
  })();
74
73
  ```