Zesstra | 19d657d | 2017-01-29 21:40:38 +0100 | [diff] [blame^] | 1 | #include "/sys/files.h" |
| 2 | |
| 3 | public varargs string read_data(string file, int start, anzahl) |
| 4 | { |
| 5 | if (!stringp(file)) |
| 6 | raise_error("Bad arg 1 to read_data(): expected 'string'.\n"); |
| 7 | |
| 8 | // Wenn Pfad nicht absolut, ist das nen Fehler, daher wird das nicht |
| 9 | // korrigiert. |
| 10 | |
| 11 | // wenn kein /data/ vorn steht, wird es vorangestellt. |
| 12 | if (strstr(file,"/"LIBDATADIR"/") != 0) |
| 13 | { |
| 14 | file = "/"LIBDATADIR + file; |
| 15 | } |
| 16 | // read_file() nicht direkt rufen, sondern vorher als closure ans |
| 17 | // aufrufende Objekt binden. Sonst laeuft die Rechtepruefung in |
| 18 | // valid_write() im Master unter der Annahme, dass die simul_efun.c mit |
| 19 | // ihrer root id was will. |
| 20 | return funcall(bind_lambda(#'efun::read_file, previous_object()), |
| 21 | file, start, anzahl); |
| 22 | } |
| 23 | |
| 24 | public varargs int write_data(string file, string str, int flags) |
| 25 | { |
| 26 | if (!stringp(file)) |
| 27 | raise_error("Bad arg 1 to write_data(): expected 'string'.\n"); |
| 28 | if (!stringp(str)) |
| 29 | raise_error("Bad arg 2 to write_data(): expected 'string'.\n"); |
| 30 | |
| 31 | // Wenn Pfad nicht absolut, ist das nen Fehler, daher wird das nicht |
| 32 | // korrigiert. |
| 33 | |
| 34 | // wenn kein /data/ vorn steht, wird es vorangestellt. |
| 35 | if (strstr(file,"/"LIBDATADIR"/") != 0) |
| 36 | { |
| 37 | file = "/"LIBDATADIR + file; |
| 38 | } |
| 39 | // write_file() nicht direkt rufen, sondern vorher als closure ans |
| 40 | // aufrufende Objekt binden. Sonst laeuft die Rechtepruefung in |
| 41 | // valid_write() im Master unter der Annahme, dass die simul_efun.c mit |
| 42 | // ihrer root id was will. |
| 43 | return funcall(bind_lambda(#'efun::write_file, previous_object()), |
| 44 | file, str, flags); |
| 45 | } |