Pixel-Composer/scripts/text_file/text_file.gml

31 lines
638 B
Plaintext
Raw Normal View History

2023-12-15 12:56:36 +01:00
function file_read_all(path) { #region
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);
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-12-15 12:56:36 +01:00
} #endregion
2023-01-01 02:06:02 +01:00
2023-12-15 12:56:36 +01:00
function file_text_read_all_lines(path) { #region
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);
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-12-15 12:56:36 +01:00
} #endregion
2023-01-04 02:30:04 +01:00
2023-12-15 12:56:36 +01:00
function file_text_write_all(path, str) { #region
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);
2023-01-01 02:06:02 +01:00
file_text_write_string(f, str);
file_text_close(f);
2023-12-15 12:56:36 +01:00
} #endregion