Browse Source

Add notes to lovr.filesystem.write;

bjorn 2 years ago
parent
commit
a84d37557e
2 changed files with 8 additions and 3 deletions
  1. 3 2
      api/init.lua
  2. 5 1
      api/lovr/filesystem/write.lua

+ 3 - 2
api/init.lua

@@ -7817,10 +7817,10 @@ return {
         {
           name = "write",
           summary = "Write to a file.",
-          description = "Write to a file.",
+          description = "Write to a file in the save directory.",
           key = "lovr.filesystem.write",
           module = "lovr.filesystem",
-          notes = "If the file does not exist, it is created.\n\nIf the file already has data in it, it will be replaced with the new content.",
+          notes = "If the file does not exist, it is created.\n\nIf the file already has data in it, it will be replaced with the new content.\n\nIf the path contains subdirectories, all of the parent directories need to exist first or the write will fail.  Use `lovr.filesystem.createDirectory` to make sure they're created first.",
           variants = {
             {
               arguments = {
@@ -7867,6 +7867,7 @@ return {
           },
           related = {
             "lovr.filesystem.append",
+            "lovr.filesystem.getSaveDirectory",
             "lovr.filesystem.read"
           }
         }

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

@@ -1,6 +1,6 @@
 return {
   summary = 'Write to a file.',
-  description = 'Write to a file.',
+  description = 'Write to a file in the save directory.',
   arguments = {
     filename = {
       type = 'string',
@@ -35,9 +35,13 @@ return {
     If the file does not exist, it is created.
 
     If the file already has data in it, it will be replaced with the new content.
+
+    If the path contains subdirectories, all of the parent directories need to exist first or the
+    write will fail.  Use `lovr.filesystem.createDirectory` to make sure they're created first.
   ]],
   related = {
     'lovr.filesystem.append',
+    'lovr.filesystem.getSaveDirectory',
     'lovr.filesystem.read'
   }
 }