Pixel-Composer/scripts/text_file/text_file.gml

37 lines
644 B
Text
Raw Normal View History

function file_read_all(path) {
2023-12-08 03:50:09 +01:00
INLINE
2023-11-13 07:11:52 +01:00
2023-02-28 09:43:01 +01:00
var f = file_text_open_read(path);
2024-06-03 05:44:08 +02:00
if(!f) return "";
2023-12-08 03:50:09 +01:00
var s = "";
while(!file_text_eof(f))
2023-12-13 11:09:06 +01:00
s += string(file_text_readln(f));
2023-02-28 09:43:01 +01:00
file_text_close(f);
2023-01-01 02:06:02 +01:00
return s;
}
2023-01-01 02:06:02 +01:00
function file_text_read_all_lines(path) {
2023-12-08 03:50:09 +01:00
INLINE
2023-11-13 07:11:52 +01:00
2023-02-28 09:43:01 +01:00
var f = file_text_open_read(path);
2024-06-03 05:44:08 +02:00
if(!f) return "";
2023-01-04 02:30:04 +01:00
var s = [];
2023-03-22 07:07:38 +01:00
while(!file_text_eof(f))
2023-02-28 09:43:01 +01:00
array_push(s, file_text_readln(f));
file_text_close(f);
2023-01-04 02:30:04 +01:00
return s;
}
2023-01-04 02:30:04 +01:00
function file_text_write_all(path, str) {
2023-12-08 03:50:09 +01:00
INLINE
2023-11-13 07:11:52 +01:00
2023-12-08 03:50:09 +01:00
if(file_exists_empty(path)) file_delete(path);
2023-10-18 14:58:55 +02:00
2023-02-28 09:43:01 +01:00
var f = file_text_open_write(path);
2024-06-03 05:44:08 +02:00
if(!f) return "";
2023-01-01 02:06:02 +01:00
file_text_write_string(f, str);
file_text_close(f);
}