aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/world/file.lux
blob: e2f203abe89e458c9ad8ab846e7ac2cff9774958 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
(.using
 [library
  [lux "*"
   ["$" documentation {"+" documentation:}]
   ["@" target]
   [control
    ["<>" parser
     ["<[0]>" code]]]
   [data
    ["[0]" text {"+" \n}
     ["%" format {"+" format}]]]
   [macro
    ["[0]" template]]]]
 [\\library
  ["[0]" /]]
 ["[0]" / "_"
  ["[1][0]" watch]])

(documentation: /.Path
  "A path to a file or a directory in a file-system.")

(documentation: (/.System !)
  "An interface to a file-system.")

(documentation: /.parent
  "If a path represents a nested file/directory, extracts its parent directory."
  [(parent fs path)])

(documentation: /.name
  "The un-nested name of a file/directory."
  [(name fs path)])

(documentation: /.rooted
  "A nested path for a file/directory, given a root/parent path and a file/directory name within it."
  [(rooted fs parent child)])

(documentation: /.exists?
  "Checks if either a file or a directory exists at the given path."
  [(exists? monad fs path)])

(documentation: /.mock
  (format "A purely in-memory simulation of a file-system."
          \n "Useful for testing.")
  [(mock separator)])

(documentation: /.make_directories
  (format "Creates the directory specified by the given path."
          \n "Also, creates every super-directory necessary to make the given path valid.")
  [(make_directories monad fs path)])

(documentation: /.make_file
  "Creates a new file with the given content if-and-only-if the file does not already exist."
  [(make_file monad fs content path)])

(.def: .public documentation
  (.List $.Module)
  (`` (`` ($.module /._
                    ""
                    [..Path
                     ..System
                     ..parent
                     ..name
                     ..rooted
                     ..exists?
                     ..mock
                     ..make_directories
                     ..make_file
                     ($.default /.async)
                     ($.default /.cannot_make_file)
                     ($.default /.cannot_find_file)
                     ($.default /.cannot_delete)
                     ($.default /.cannot_make_directory)
                     ($.default /.cannot_find_directory)
                     ($.default /.cannot_read_all_data)
                     (~~ (for [@.jvm (~~ (as_is ($.default /.cannot_modify_file)
                                                ($.default /.default)))
                               @.js (~~ (as_is ($.default /.default)))
                               @.python (~~ (as_is ($.default /.default)))
                               @.ruby (~~ (as_is ($.default /.default)))]
                              (~~ (as_is))))]
                    [/watch.documentation]))))