Rev 8793 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
9766 | turbocat | 1 | #include |
8744 | turbocat | 2 | #include |
3 | #include |
||
9766 | turbocat | 4 | #include |
5 | #include |
||
8744 | turbocat | 6 | |
9766 | turbocat | 7 | const char* folder_type = "Folder"; |
8 | const char* file_type = "File"; |
||
8744 | turbocat | 9 | |
10 | int main() |
||
11 | { |
||
9766 | turbocat | 12 | char* path = getcwd(NULL, PATH_MAX); |
13 | printf("Current directory: %s\n", path); |
||
14 | if (mkdir("test")) { |
||
15 | puts("Test folder created!"); |
||
16 | } else { |
||
8744 | turbocat | 17 | puts("Error creating folder!"); |
18 | } |
||
9766 | turbocat | 19 | |
20 | DIR* mydir = opendir(path); |
||
21 | if (!mydir) { |
||
8744 | turbocat | 22 | puts("File system error."); |
23 | return -1; |
||
24 | } |
||
25 | |||
9766 | turbocat | 26 | struct dirent* file_info; |
27 | char* str_type = NULL; |
||
8744 | turbocat | 28 | putc(' '); |
9766 | turbocat | 29 | while ((file_info = readdir(mydir)) != NULL) { |
30 | if (file_info->d_type == IS_FOLDER) { |
||
8744 | turbocat | 31 | (*con_set_flags)(CON_COLOR_GREEN); |
32 | str_type = (char*)folder_type; |
||
9766 | turbocat | 33 | } else { |
8744 | turbocat | 34 | (*con_set_flags)(7); |
35 | str_type = (char*)file_type; |
||
36 | } |
||
9766 | turbocat | 37 | printf("%3d %20s %s\n ", file_info->d_ino, file_info->d_name, str_type); |
8744 | turbocat | 38 | }; |
39 | |||
40 | setcwd("/sys/develop"); |
||
9766 | turbocat | 41 | path = getcwd(NULL, PATH_MAX); |
8744 | turbocat | 42 | printf("Move to the directory: %s\n", path); |
43 | free(path); |
||
44 | } |