- Added "lsdir" function to libck ktcc.

- Added "fs" folder to build.bat in libck for tcc.
- Updated libck and dir_example

git-svn-id: svn://kolibrios.org@8289 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
superturbocat2001
2020-12-01 16:19:41 +00:00
parent e34d1445df
commit 5451715e39
5 changed files with 90 additions and 12 deletions

View File

@@ -2,20 +2,40 @@
#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")){
if(true==mkdir("test")){
puts("Test folder created!");
return(0);
}
else{
puts("Error creating folder!");
return(-1);
}
short_file_info *info;
int num = lsdir(path, &info);
if(num==FS_ERROR)
{
puts("File system error.");
return -1;
}
printf("Objects in the folder: %d\n", num);
for(int j=0; j<num; j++)
{
printf("%s ", info[j].name);
if(info[j].type==T_FOLDER)
{
printf("(Folder)\n");
}
else
{
printf("(File)\n");
}
}
free(info);
setcwd("/sys");
path=getcwd(NULL, PATH_MAX);
printf("Move to the directory: %s\n", path);
free(path);
}