Added fwrite
This commit is contained in:
parent
680defd654
commit
f4b82ec850
17
kernel/vfs.c
17
kernel/vfs.c
@ -219,6 +219,23 @@ int puts(const char* s) {
|
||||
return fputs(s,stdout);
|
||||
}
|
||||
|
||||
size_t fwrite(void* buffer_ptr,size_t size,size_t count,FILE* stream) {
|
||||
if (!stream->wr) {
|
||||
errno=EBADF;
|
||||
stream->error=1;
|
||||
return 0;
|
||||
}
|
||||
char* buffer=(char*)buffer_ptr;
|
||||
size_t bytes=size*count;
|
||||
for (size_t i=0;i<bytes;i++) {
|
||||
int c=fputs(stream,buffer[i]);
|
||||
if (c==EOF) {
|
||||
return (size_t)(i/size);
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int vfprintf(FILE* stream,const char* format,va_list arg) {
|
||||
int c;
|
||||
for(;*format!='\0';format++) {
|
||||
|
@ -34,6 +34,7 @@ size_t fread(void* buffer,size_t size,size_t count,FILE* stream);
|
||||
int fputc(int c,FILE* stream);
|
||||
int putc(int c);
|
||||
int fputs(const char* s,FILE* stream);
|
||||
size_t fwrite(void* buffer_ptr,size_t size,size_t count,FILE* stream);
|
||||
int puts(const char* s);
|
||||
int fprintf(FILE* stream,const char* format,...);
|
||||
int vfprintf(FILE* stream,const char* format,va_list arg);
|
||||
|
Loading…
x
Reference in New Issue
Block a user