Kaynağa Gözat

Fix filesystem docs for v18;

bjorn 3 ay önce
ebeveyn
işleme
d2dee5fd8f

+ 49 - 16
api/init.lua

@@ -9453,9 +9453,14 @@ return {
               },
               returns = {
                 {
-                  name = "bytes",
+                  name = "success",
                   type = "number",
-                  description = "The number of bytes actually appended to the file."
+                  description = "Whether the operation was successful."
+                },
+                {
+                  name = "error",
+                  type = "string",
+                  description = "The error message, if there was an error."
                 }
               }
             },
@@ -9474,9 +9479,14 @@ return {
               },
               returns = {
                 {
-                  name = "bytes",
+                  name = "success",
                   type = "number",
-                  description = "The number of bytes actually appended to the file."
+                  description = "Whether the operation was successful."
+                },
+                {
+                  name = "error",
+                  type = "string",
+                  description = "The error message, if there was an error."
                 }
               }
             }
@@ -9503,6 +9513,11 @@ return {
                   name = "success",
                   type = "boolean",
                   description = "Whether the directory was created."
+                },
+                {
+                  name = "error",
+                  type = "string",
+                  description = "The error message, if there was a failure."
                 }
               }
             }
@@ -9616,7 +9631,12 @@ return {
                 {
                   name = "time",
                   type = "number",
-                  description = "The modification time of the file, in seconds, or `nil` if it's unknown."
+                  description = "The modification time of the file, in seconds, or `nil` if there was an error."
+                },
+                {
+                  name = "error",
+                  type = "string",
+                  description = "The error message, if there was an error."
                 }
               }
             }
@@ -9950,6 +9970,11 @@ return {
                   name = "success",
                   type = "boolean",
                   description = "Whether the archive was successfully mounted."
+                },
+                {
+                  name = "error",
+                  type = "string",
+                  description = "The error message, if the archive failed to mount."
                 }
               }
             }
@@ -10038,7 +10063,6 @@ return {
           description = "Read the contents of a file.",
           key = "lovr.filesystem.read",
           module = "lovr.filesystem",
-          notes = "If the file does not exist or cannot be read, nil is returned.",
           variants = {
             {
               arguments = {
@@ -10046,24 +10070,18 @@ return {
                   name = "filename",
                   type = "string",
                   description = "The name of the file to read."
-                },
-                {
-                  name = "bytes",
-                  type = "number",
-                  description = "The number of bytes to read (if -1, all bytes will be read).",
-                  default = "-1"
                 }
               },
               returns = {
                 {
                   name = "contents",
                   type = "string",
-                  description = "The contents of the file."
+                  description = "The contents of the file, or nil if the file could not be read."
                 },
                 {
-                  name = "bytes",
-                  type = "number",
-                  description = "The number of bytes read from the file."
+                  name = "error",
+                  type = "string",
+                  description = "The error message, if any."
                 }
               }
             }
@@ -10091,6 +10109,11 @@ return {
                   name = "success",
                   type = "boolean",
                   description = "Whether the path was removed."
+                },
+                {
+                  name = "error",
+                  type = "string",
+                  description = "The error message, if any."
                 }
               }
             }
@@ -10240,6 +10263,11 @@ return {
                   name = "success",
                   type = "boolean",
                   description = "Whether the write was successful."
+                },
+                {
+                  name = "error",
+                  type = "string",
+                  description = "The error message, if there was an error."
                 }
               }
             },
@@ -10261,6 +10289,11 @@ return {
                   name = "success",
                   type = "boolean",
                   description = "Whether the write was successful."
+                },
+                {
+                  name = "error",
+                  type = "string",
+                  description = "The error message, if there was an error."
                 }
               }
             }

+ 8 - 4
api/lovr/filesystem/append.lua

@@ -17,19 +17,23 @@ return {
     }
   },
   returns = {
-    bytes = {
+    success = {
       type = 'number',
-      description = 'The number of bytes actually appended to the file.'
+      description = 'Whether the operation was successful.'
+    },
+    error = {
+      type = 'string',
+      description = 'The error message, if there was an error.'
     }
   },
   variants = {
     {
       arguments = { 'filename', 'content' },
-      returns = { 'bytes' }
+      returns = { 'success', 'error' }
     },
     {
       arguments = { 'filename', 'blob' },
-      returns = { 'bytes' }
+      returns = { 'success', 'error' }
     }
   },
   notes = 'If the file does not exist, it is created.'

+ 5 - 1
api/lovr/filesystem/createDirectory.lua

@@ -15,12 +15,16 @@ return {
     success = {
       type = 'boolean',
       description = 'Whether the directory was created.'
+    },
+    error = {
+      type = 'string',
+      description = 'The error message, if there was a failure.'
     }
   },
   variants = {
     {
       arguments = { 'path' },
-      returns = { 'success' }
+      returns = { 'success', 'error' }
     }
   }
 }

+ 6 - 2
api/lovr/filesystem/getLastModified.lua

@@ -11,13 +11,17 @@ return {
   returns = {
     time = {
       type = 'number',
-      description = 'The modification time of the file, in seconds, or `nil` if it\'s unknown.'
+      description = 'The modification time of the file, in seconds, or `nil` if there was an error.'
+    },
+    error = {
+      type = 'string',
+      description = 'The error message, if there was an error.'
     }
   },
   variants = {
     {
       arguments = { 'path' },
-      returns = { 'time' }
+      returns = { 'time', 'error' }
     }
   }
 }

+ 5 - 1
api/lovr/filesystem/mount.lua

@@ -35,12 +35,16 @@ return {
     success = {
       type = 'boolean',
       description = 'Whether the archive was successfully mounted.'
+    },
+    error = {
+      type = 'string',
+      description = 'The error message, if the archive failed to mount.'
     }
   },
   variants = {
     {
       arguments = { 'path', 'mountpoint', 'append', 'root' },
-      returns = { 'success' }
+      returns = { 'success', 'error' }
     }
   },
   notes = [[

+ 7 - 13
api/lovr/filesystem/read.lua

@@ -6,28 +6,22 @@ return {
     filename = {
       type = 'string',
       description = 'The name of the file to read.'
-    },
-    bytes = {
-      type = 'number',
-      default = '-1',
-      description = 'The number of bytes to read (if -1, all bytes will be read).'
     }
   },
   returns = {
     contents = {
       type = 'string',
-      description = 'The contents of the file.'
+      description = 'The contents of the file, or nil if the file could not be read.'
     },
-    bytes = {
-      type = 'number',
-      description = 'The number of bytes read from the file.'
+    error = {
+      type = 'string',
+      description = 'The error message, if any.'
     }
   },
   variants = {
     {
-      arguments = { 'filename', 'bytes' },
-      returns = { 'contents', 'bytes' }
+      arguments = { 'filename' },
+      returns = { 'contents', 'error' }
     }
-  },
-  notes = 'If the file does not exist or cannot be read, nil is returned.'
+  }
 }

+ 5 - 1
api/lovr/filesystem/remove.lua

@@ -12,12 +12,16 @@ return {
     success = {
       type = 'boolean',
       description = 'Whether the path was removed.'
+    },
+    error = {
+      type = 'string',
+      description = 'The error message, if any.'
     }
   },
   variants = {
     {
       arguments = { 'path' },
-      returns = { 'success' }
+      returns = { 'success', 'error' }
     }
   },
   notes = [[

+ 6 - 2
api/lovr/filesystem/write.lua

@@ -20,16 +20,20 @@ return {
     success = {
       type = 'boolean',
       description = 'Whether the write was successful.'
+    },
+    error = {
+      type = 'string',
+      description = 'The error message, if there was an error.'
     }
   },
   variants = {
     {
       arguments = { 'filename', 'content' },
-      returns = { 'success' }
+      returns = { 'success', 'error' }
     },
     {
       arguments = { 'filename', 'blob' },
-      returns = { 'success' }
+      returns = { 'success', 'error' }
     }
   },
   notes = [[