/programs/develop/ktcc/trunk/bin/lib/libck.a |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/develop/ktcc/trunk/libc/makefile |
---|
File deleted |
/programs/develop/ktcc/trunk/libc/Makefile |
---|
0,0 → 1,33 |
INCLUDE = include |
LIBSFORBUILD = math |
LIBNAME = libck.a |
CC = ../bin/kos32-tcc |
CFLAGS = -I$(INCLUDE) -m32 -nostdinc -nostdlib -DGNUC |
DIRS := stdio memory kolibrisys string stdlib math dlfcn libgen fs |
############################################################## |
#files := $(foreach dir,$(DIRS),$(dir)/$(wildcard $(dir)/*)) |
asmfiles := $(foreach dir,$(DIRS),$(patsubst %.asm, %.o, $(wildcard $(dir)/*.asm))) |
cfiles := $(foreach dir,$(DIRS),$(patsubst %.c, %.o, $(wildcard $(dir)/*.c))) |
.PHONY: clean all |
ifdef windir |
doClean = del /F /Q $(subst /,\,$(cfiles)) $(subst /,\,$(asmfiles)) |
else |
doClean = rm $(cfiles) $(asmfiles) |
endif |
all: $(cfiles) $(asmfiles) |
ar -ru $(LIBNAME) $^ |
$(cfiles): $(INCLUDE)/*.h |
$(asmfiles): |
fasm $*.asm $*.o |
clean: |
$(doClean) |
install: |
cp $(LIBNAME) ../bin/lib |
/programs/develop/ktcc/trunk/libc/fs/dir.c |
---|
0,0 → 1,64 |
#include <stdlib.h> |
#include <dir.h> |
#include <stdbool.h> |
#pragma pack(push,1) |
typedef struct { |
unsigned p00; |
unsigned long long p04; |
unsigned p12; |
unsigned p16; |
char p20; |
char *p21; |
} kol_struct70; |
#pragma pack(pop) |
int kol_file_70(kol_struct70 *k) |
{ |
asm volatile ("int $0x40"::"a"(70), "b"(k)); |
} |
bool dir_operations(unsigned char fun_num, char *path) |
{ |
kol_struct70 inf; |
inf.p00 = fun_num; |
inf.p04 = 0; |
inf.p12 = 0; |
inf.p16 = 0; |
inf.p20 = 0; |
inf.p21 = path; |
if(!kol_file_70(&inf)){ |
return true; |
} |
else { |
return false; |
} |
} |
char *getcwd(char *buf, unsigned size) |
{ |
if(buf == NULL){ |
buf = malloc(size); |
} |
__asm__ __volatile__( |
"int $0x40" |
::"a"(30),"b"(2),"c"(buf), "d"(size)); |
return(buf); |
} |
void setcwd(const char* cwd) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(30),"b"(1),"c"(cwd)); |
} |
bool rmdir(const char* dir) |
{ |
return dir_operations(8, dir); |
} |
bool mkdir(const char* dir) |
{ |
return dir_operations(9, dir); |
} |
/programs/develop/ktcc/trunk/libc/include/dir.h |
---|
0,0 → 1,20 |
#ifndef _DIR_H |
#define _DIR_H |
#include <stdbool.h> |
#define PATH_MAX 4096 |
// Get the path to the working directory(if buf is NULL, then memory will be allocated automatically) |
char *getcwd(char *buf, unsigned size); |
// Set path to working directory |
void setcwd(const char* cwd); |
// Remove directory (returns "true" if successful) |
bool rmdir(const char* dir); |
// Create directory (returns "true" if successful) |
bool mkdir(const char* dir); |
#endif |
/programs/develop/ktcc/trunk/samples/build_all.sh |
---|
11,4 → 11,5 |
../tcc clayer/boxlib.c -lck -lbox -o /tmp0/1/boxlib_ex |
../tcc clayer/libimg.c -lck -limg -o /tmp0/1/libimg_ex |
../tcc console/console.c -lck -limg -o /tmp0/1/console |
../tcc dir_example.c -lck -o /tmp0/1/dir_example |
exit |
/programs/develop/ktcc/trunk/samples/dir_example.c |
---|
0,0 → 1,21 |
#include <dir.h> |
#include <stdio.h> |
#include <stdbool.h> |
#include <stdlib.h> |
int main() |
{ |
char *path=getcwd(NULL, PATH_MAX); |
printf("Current directory: %s\n", path); |
setcwd("/sys"); //String must be null terminated! |
path=getcwd(NULL, PATH_MAX); |
printf("Move to the directory: %s\n", path); |
free(path); |
if(true==mkdir("TEST1")){ |
puts("Test folder created!"); |
return(0); |
} |
else{ |
puts("Error creating folder!"); |
return(-1); |
} |
} |