2020-11-30 01:05:50 +03:00
|
|
|
#include <dir.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
2020-12-01 19:19:41 +03:00
|
|
|
|
2020-11-30 01:05:50 +03:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
char *path=getcwd(NULL, PATH_MAX);
|
|
|
|
printf("Current directory: %s\n", path);
|
2020-12-01 19:19:41 +03:00
|
|
|
if(true==mkdir("test")){
|
2020-11-30 01:05:50 +03:00
|
|
|
puts("Test folder created!");
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
puts("Error creating folder!");
|
|
|
|
}
|
2020-12-01 19:19:41 +03:00
|
|
|
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);
|
2020-11-30 01:05:50 +03:00
|
|
|
}
|