mirror of
https://hacklab.nilfm.cc/kuro
synced 2024-10-22 07:11:47 +00:00
35 lines
601 B
C
35 lines
601 B
C
|
#include "dat.h"
|
||
|
#include "fns.h"
|
||
|
|
||
|
static char mtpt[256] = {0};
|
||
|
|
||
|
void kuro9p_set_mtpt(char* path) {
|
||
|
strcpy(mtpt, path);
|
||
|
}
|
||
|
|
||
|
void kuro9p_write(char* path, char* data, int len) {
|
||
|
int fd;
|
||
|
char fullpath[256];
|
||
|
strcpy(fullpath, mtpt);
|
||
|
strcat(fullpath, path);
|
||
|
|
||
|
fd = open(fullpath, OWRITE);
|
||
|
if (fd >= 0) {
|
||
|
write(fd, data, len);
|
||
|
close(fd);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
char* kuro9p_read(char* path, char* buf, int len) {
|
||
|
int fd;
|
||
|
char fullpath[256];
|
||
|
strcpy(fullpath, mtpt);
|
||
|
strcat(fullpath, path);
|
||
|
|
||
|
fd = open(fullpath, OREAD);
|
||
|
if (fd >= 0) {
|
||
|
read(fd, buf, len);
|
||
|
close(fd);
|
||
|
}
|
||
|
return buf;
|
||
|
}
|