ALLFILES.C
资源名称:C.rar [点击查看]
上传用户:qq5388545
上传日期:2022-07-04
资源大小:29849k
文件大小:1k
源码类别:
界面编程
开发平台:
C/C++
- #include <stdio.h>
- #include <dirent.h>
- #include <dos.h>
- #include <io.h>
- #include <direct.h>
- #include <string.h>
- void show_directory(char *directory_name)
- {
- DIR *directory_pointer;
- struct dirent *entry;
- unsigned attributes;
- if ((directory_pointer = opendir(directory_name)) == NULL)
- printf("Error opening %sn", directory_name);
- else
- {
- chdir(directory_name);
- while (entry = readdir(directory_pointer))
- {
- attributes = _chmod(entry, 0);
- // Check if entry is for a subdirectory
- // and is not . or ..
- if ((attributes & FA_DIREC) &&
- (strncmp(entry, ".", 1) != 0))
- {
- printf("nn----%s----n", entry);
- show_directory(entry);
- }
- else
- printf("%sn", entry);
- }
- closedir(directory_pointer);
- chdir("..");
- }
- }
- void main(void)
- {
- char buffer[MAXPATH];
- // Save current directory so we can restore it later
- getcwd(buffer, sizeof(buffer));
- show_directory("\");
- chdir(buffer);
- }