File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,8 +12,10 @@ int print(const char *fmt, ...){
1212 va_end (args );
1313 if (n >= sizeof (log_buf )) log_buf [sizeof (log_buf )- 1 ] = '\0' ;
1414 printl (log_buf );
15+ #ifndef CROSS
1516 file fd2 = { .id = 2 };
1617 writef (& fd2 , log_buf , sizeof (log_buf ));
18+ #endif
1719 return 0 ;
1820}
1921
@@ -25,8 +27,10 @@ int printf(const char *fmt, ...){
2527 va_end (args );
2628 if (n >= sizeof (li )) li [sizeof (li )- 1 ] = '\0' ;
2729 printl (li );
30+ #ifndef CROSS
2831 file fd2 = { .id = 2 };
2932 writef (& fd2 , li , sizeof (li ));
33+ #endif
3034 return 0 ;
3135}
3236
@@ -76,7 +80,7 @@ void* zalloc(size_t size){
7680char * read_full_file (const char * path ){
7781
7882 file fd = {};
79- openf (path , & fd );
83+ if ( openf (path , & fd ) != FS_RESULT_SUCCESS ) return false ;
8084 char * fcontent = (char * )malloc (fd .size + 1 );
8185
8286 readf (& fd , fcontent , fd .size );
@@ -86,4 +90,15 @@ char *read_full_file(const char *path){
8690 return fcontent ;
8791}
8892
93+ bool write_full_file (const char * path , void * buf , size_t size ){
94+ file fd = {};
95+ if (openf (path , & fd ) != FS_RESULT_SUCCESS ) return false;
96+
97+ size_t res = writef (& fd , buf , size );
98+
99+ closef (& fd );
100+
101+ return res > 0 ;
102+ }
103+
89104#endif
Original file line number Diff line number Diff line change @@ -67,6 +67,8 @@ sizedptr dir_list(const char *path);
6767int print (const char * fmt , ...);
6868char * read_full_file (const char * path );
6969
70+ bool write_full_file (const char * path , void * buf , size_t size );
71+
7072static inline void yield (){
7173 msleep (0 );
7274}
You can’t perform that action at this time.
0 commit comments