-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
90 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// 版权 @2023 凹语言 作者。保留所有权利。 | ||
|
||
#wa:build !js | ||
|
||
func ReadFile(name: string) => []byte { | ||
panic("unsupport") | ||
} | ||
|
||
func WriteFile(name: string, data: []byte) { | ||
panic("unsupport") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// 版权 @2023 凹语言 作者。保留所有权利。 | ||
|
||
#wa:linkname $wa.runtime.slice_to_ptr | ||
func slice_to_ptr(t: []byte) => i32 | ||
|
||
#wa:linkname $wa.runtime.string_to_ptr | ||
func string_to_ptr(s: string) => i32 | ||
|
||
#wa:import syscall_js read_file_len | ||
func read_file_len(name_ptr, name_len: i32) => i32 | ||
|
||
#wa:import syscall_js read_file_data | ||
func read_file_data(name_ptr, name_len, data_ptr: i32) | ||
|
||
#wa:import syscall_js write_file | ||
func write_file(name_ptr, name_len, data_ptr, data_len: i32) | ||
|
||
func ReadFile(name: string) => []byte { | ||
size := read_file_len(string_to_ptr(name), len(name)) | ||
data := make([]byte, size) | ||
read_file_data( | ||
string_to_ptr(name), len(name), | ||
slice_to_ptr(data), | ||
) | ||
} | ||
|
||
func WriteFile(name: string, data: []byte) { | ||
write_file( | ||
string_to_ptr(name), len(name), | ||
slice_to_ptr(data), len(data), | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters