fts_children() referenced
このマニュアルページhttp://www.kernel.org/doc/man-pages/online/pages/man3/fts.3.htmlの機能に問題があります。fts_children()
マニュアルページで主張しているように、サブディレクトリ内のすべてのファイルを取得するわけではないようです。たとえばtemp
、フォルダ内v2
に多数のファイルを含むファイルがあります。アルファベット順の最初のファイルを除いて、サブディレクトリ内のすべてのファイルを取得します。これについて私にできることはありますか?私のコードは以下にあり、サブディレクトリ内のファイルには権限があります。コード:
int compare (const FTSENT**, const FTSENT**);
int main(int argc, char* const argv[])
{
FTS* file_system = NULL;
FTSENT* child = NULL;
FTSENT* parent = NULL;
file_system = fts_open(argv + 1,FTS_COMFOLLOW | FTS_NOCHDIR,&compare);
if (NULL != file_system)
{
while( (parent = fts_read(file_system)) != NULL)
{
child = fts_children(file_system,0);
if (errno != 0)
while ((NULL != child) && (NULL != child->fts_link))
{
child = child->fts_link;
printf("%s\n", child->fts_name);
}
}
fts_close(file_system);
}
return 0;
}
int compare(const FTSENT** one, const FTSENT** two)
{
return (strcmp((*one)->fts_name, (*two)->fts_name));
}
一時ファイル(ls -lで出力):
total 8
-rwxrwxrwx 1 tparisi student 14 Sep 27 13:05 a
-rw-r--r--+ 1 tparisi student 25 Sep 26 14:42 f
-rw-r--r--+ 1 tparisi student 13 Sep 27 11:28 file2
-rw-r--r--+ 1 tparisi student 14 Sep 27 11:42 files
drwxr-xr-x+ 2 tparisi student 3 Sep 27 13:33 temp2
-rw-r--r--+ 1 tparisi student 14 Sep 27 13:04 test
-rw-r--r--+ 1 tparisi student 5 Sep 27 13:23 z
a
プログラムを実行すると、ディレクトリ全体が受け入れられるように出力されます。
どんな助けでも素晴らしいでしょう!ありがとう!