Browse Source

write/append variant;

bjorn 4 years ago
parent
commit
17db5a71c8
3 changed files with 78 additions and 14 deletions
  1. 43 1
      api/init.lua
  2. 18 7
      api/lovr/filesystem/append.lua
  3. 17 6
      api/lovr/filesystem/write.lua

+ 43 - 1
api/init.lua

@@ -3063,7 +3063,28 @@ return {
                 {
                   name = "bytes",
                   type = "number",
-                  description = "The number of bytes actually written to the file."
+                  description = "The number of bytes actually appended to the file."
+                }
+              }
+            },
+            {
+              arguments = {
+                {
+                  name = "filename",
+                  type = "string",
+                  description = "The file to append to."
+                },
+                {
+                  name = "blob",
+                  type = "Blob",
+                  description = "A Blob containing data to append to the file."
+                }
+              },
+              returns = {
+                {
+                  name = "bytes",
+                  type = "number",
+                  description = "The number of bytes actually appended to the file."
                 }
               }
             }
@@ -3734,6 +3755,27 @@ return {
                   description = "The number of bytes written."
                 }
               }
+            },
+            {
+              arguments = {
+                {
+                  name = "filename",
+                  type = "string",
+                  description = "The file to write to."
+                },
+                {
+                  name = "blob",
+                  type = "Blob",
+                  description = "A Blob containing data to write to the file."
+                }
+              },
+              returns = {
+                {
+                  name = "bytes",
+                  type = "number",
+                  description = "The number of bytes written."
+                }
+              }
             }
           },
           related = {

+ 18 - 7
api/lovr/filesystem/append.lua

@@ -2,22 +2,33 @@ return {
   summary = 'Append content to the end of a file.',
   description = 'Appends content to the end of a file.',
   arguments = {
-    {
-      name = 'filename',
+    filename = {
       type = 'string',
       description = 'The file to append to.'
     },
-    {
-      name = 'content',
+    content = {
       type = 'string',
       description = 'A string to write to the end of the file.'
+    },
+    blob = {
+      type = 'Blob',
+      description = 'A Blob containing data to append to the file.'
     }
   },
   returns = {
-    {
-      name = 'bytes',
+    bytes = {
       type = 'number',
-      description = 'The number of bytes actually written to the file.'
+      description = 'The number of bytes actually appended to the file.'
+    }
+  },
+  variants = {
+    {
+      arguments = { 'filename', 'content' },
+      returns = { 'bytes' }
+    },
+    {
+      arguments = { 'filename', 'blob' },
+      returns = { 'bytes' }
     }
   },
   notes = 'If the file does not exist, it is created.'

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

@@ -2,24 +2,35 @@ return {
   summary = 'Write to a file.',
   description = 'Write to a file.',
   arguments = {
-    {
-      name = 'filename',
+    filename = {
       type = 'string',
       description = 'The file to write to.'
     },
-    {
-      name = 'content',
+    content = {
       type = 'string',
       description = 'A string to write to the file.'
+    },
+    blob = {
+      type = 'Blob',
+      description = 'A Blob containing data to write to the file.'
     }
   },
   returns = {
-    {
-      name = 'bytes',
+    bytes = {
       type = 'number',
       description = 'The number of bytes written.'
     }
   },
+  variants = {
+    {
+      arguments = { 'filename', 'content' },
+      returns = { 'bytes' }
+    },
+    {
+      arguments = { 'filename', 'blob' },
+      returns = { 'bytes' }
+    }
+  },
   notes = [[
     If the file does not exist, it is created.