Subject: Re: source to handle directory content for manipulate
To: c5666305 <c5666305@comp.polyu.edu.hk>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: current-users
Date: 02/24/1998 07:12:35
> I cannot find any source to handle the content of a directory for
> manipulate.

> 1. Get the content of a particular directoy. It may contains files
>    and directories.

What's wrong with opendir()/readdir()/closedir()?  (See "man 3 opendir";
surely it's not unreasonable for you to do "man -k directory" and look
at the resulting list, which includes the opendir() family of calls.)

If you want a recursive walk, see "man 3 fts", or if you want greater
portability, code your own recursive walk using the opendir() family of
routines, with lstat() and such to identify (sub)directories.

> 2. Some routines to display the content and play around with it like
>    add or delete (not actually add or delete just do it under the
>    program execution).

I'm not sure what you're asking for here.  To add things to a
directory, one calls open() (with O_CREAT), mkdir(), link(), or other
routines that create things in the filesystem.  There is no explicit
"add this entry to this directory" call.  To remove things, one calls
unlink(), rmdir(), or other routines that remove things from the
filesystem.

					der Mouse

			       mouse@rodents.montreal.qc.ca
		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B