🦄 refactor(C13, C14, C115): 更新了linux系统开发部分的结构
This commit is contained in:
46
C14-文件系统/glob.c
Normal file
46
C14-文件系统/glob.c
Normal file
@@ -0,0 +1,46 @@
|
||||
#include <glob.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// #define PAT "/etc/a*.conf"
|
||||
#define PAT "/etc/*" // 不包括隐藏文件 .*
|
||||
|
||||
#if 0
|
||||
static int errfunc_(const char *errpath, int eerrno)
|
||||
{
|
||||
puts(errpath);
|
||||
fprintf(stderr, "ERROR MSG: %s\n", strerror(eerrno));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief ls /etc/a*.conf
|
||||
* @details
|
||||
*
|
||||
* @param argc
|
||||
* @param argv
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
glob_t globres;
|
||||
int err;
|
||||
|
||||
err = glob(PAT, 0, NULL, &globres);
|
||||
if (err)
|
||||
{
|
||||
printf("ERROR CODE = %d\n", err);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < globres.gl_pathc; i++)
|
||||
{
|
||||
puts(globres.gl_pathv[i]);
|
||||
}
|
||||
|
||||
// !!!
|
||||
globfree(&globres);
|
||||
exit(0);
|
||||
}
|
||||
Reference in New Issue
Block a user