File tree Expand file tree Collapse file tree 6 files changed +168
-0
lines changed
Expand file tree Collapse file tree 6 files changed +168
-0
lines changed Original file line number Diff line number Diff line change 1+ <!--
2+ category: reference
3+ -->
4+
5+ Blob
6+ ===
7+
8+ A Blob is an object that represents the contents of a file. It can be passed to most functions that
9+ create objects from file data, such as ` lovr.graphics.newModel ` and ` lovr.audio.newSource ` . Loading
10+ many objects in this way is often faster because the file data only needs to be read once and can be
11+ reused. It can also be useful if file data is retrieved from some non-filesystem source, such as a
12+ network request.
13+
14+ Functions
15+ ---
16+
17+ <table >
18+ <tr >
19+ <td class =" pre " >lovr.filesystem.newBlob</td >
20+ <td >Create a Blob from a file or raw data.</td >
21+ </tr >
22+
23+ <tr >
24+ <td class =" pre " >Blob:getFilename</td >
25+ <td >Return the name of the file used to load the Blob (or the user-defined name).</td >
26+ </tr >
27+
28+ <tr >
29+ <td class =" pre " >Blob:getPointer</td >
30+ <td >Return a raw pointer to the Blob's data.</td >
31+ </tr >
32+
33+ <tr >
34+ <td class =" pre " >Blob:getSize</td >
35+ <td >Return the size of the Blob's data, in bytes.</td >
36+ </tr >
37+
38+ <tr >
39+ <td class =" pre " >Blob:getString</td >
40+ <td >Return a string containing the binary blob data.</td >
41+ </tr >
42+ </table >
Original file line number Diff line number Diff line change 1+ <!--
2+ category: reference
3+ -->
4+
5+ Blob: getFilename
6+ ===
7+
8+ Returns the name of the file used to load the Blob, or the custom name given to it when it was
9+ created.
10+
11+ filename = blob:getFilename()
12+
13+ ### Arguments
14+
15+ None
16+
17+ ### Returns
18+
19+ - ` string filename ` The name of the Blob.
Original file line number Diff line number Diff line change 1+ <!--
2+ category: reference
3+ -->
4+
5+ Blob: getPointer
6+ ===
7+
8+ Returns a raw pointer to the Blob's data. This can be used to interface with other C libraries
9+ using the LuaJIT FFI. Use this only if you know what you're doing!
10+
11+ pointer = blob:getPointer()
12+
13+ ### Arguments
14+
15+ None
16+
17+ ### Returns
18+
19+ - ` userdata pointer ` A pointer to the data.
Original file line number Diff line number Diff line change 1+ <!--
2+ category: reference
3+ -->
4+
5+ Blob: getSize
6+ ===
7+
8+ Get the size of a Blob's data in bytes.
9+
10+ bytes = blob:getSize()
11+
12+ ### Arguments
13+
14+ None
15+
16+ ### Returns
17+
18+ - ` number bytes ` The size of the data.
Original file line number Diff line number Diff line change 1+ <!--
2+ category: reference
3+ -->
4+
5+ Blob: getString
6+ ===
7+
8+ Get the binary data of the Blob.
9+
10+ data = blob:getString()
11+
12+ ### Arguments
13+
14+ None
15+
16+ ### Returns
17+
18+ - ` string data ` The Blob data.
19+
20+ Example
21+ ---
22+
23+ Manually copy a file using Blobs:
24+
25+ ```
26+ blob = lovr.filesystem.newBlob('image.png')
27+ lovr.filesystem.write('copy.png', blob:getString())
28+ ```
Original file line number Diff line number Diff line change 1+ <!--
2+ category: reference
3+ -->
4+
5+ lovr.filesystem.newBlob
6+ ===
7+
8+ Creates a new Blob. A Blob is an object that represents the contents of a file. It can be passed
9+ to most functions that create objects from file data, such as ` lovr.graphics.newModel ` and
10+ ` lovr.audio.newSource ` . Loading many objects in this way is often faster because the file data
11+ only needs to be read once and can be reused. It can also be useful if file data is retrieved from
12+ some non-filesystem source, such as a network request.
13+
14+ ---
15+
16+ blob = lovr.filesystem.newBlob(filename)
17+
18+ ### Arguments
19+
20+ - ` string filename ` The file to load.
21+
22+ ### Returns
23+
24+ - ` Blob blob ` The new Blob.
25+
26+ ---
27+
28+ blob = lovr.filesystem.newBlob(str, name)
29+
30+ ### Arguments
31+
32+ - ` string str ` The contents of the Blob.
33+ - ` string name ` A name for the Blob (used for error messages).
34+
35+ ### Returns
36+
37+ - ` Blob blob ` A new Blob.
38+
39+ See also
40+ ---
41+
42+ - ` Blob `
You can’t perform that action at this time.
0 commit comments