你指的 copendir 实际上应该是 opendir(POSIX 标准目录遍历函数)。
在 Ubuntu 里,opendir 不是需要单独安装的软件,而是 C 语言标准库(glibc)的一部分,只要你安装了 gcc / build-essential 就可以直接使用。
sudo apt update
sudo apt install build-essential
安装完成后,系统中就已经包含:
opendirreaddirclosedir它们定义在:
#include <dirent.h>
listdir.c#include <stdio.h>
#include <dirent.h>
int main() {
DIR *dir = opendir(".");
struct dirent *entry;
if (dir == NULL) {
perror("opendir");
return 1;
}
while ((entry = readdir(dir)) != NULL) {
printf("%s\n", entry->d_name);
}
closedir(dir);
return 0;
}
gcc listdir.c -o listdir
./listdir
目前 Ubuntu 官方仓库中没有叫 copendir 的软件包。
可能的情况:
opendir / find / fd)你可以试试:
apt search copendir
如果没有结果,可以告诉我:
我可以帮你精确定位 ✅