Glenn Schmottlach
|
Re: Getting file descriptor from a DIR structure
|
Glenn Schmottlach
08/12/2008 8:00 AM
post11670
|
Re: Getting file descriptor from a DIR structure
> What would you do if you had many different filesystems with different
> capabilities? I guess you'd take the lesser of them all?
In the general case, if I go with a hard-coded solution, I'd have to return the minimum path length of all supported
file systems. Obviously this is not an ideal solution. For my specific project, assuming I know the file system that
will be used, this is a feasible, albeit, a non-general solution.
> One thing that
> you could do is to wrap the DIR structure into a custom structure that
> contains a DIR * and stores the original path.
I am constrained by the DBUS API with regards to mucking around with the DIR structure and embedding it inside a wrapper
structure the contains the original path. Plus, I don't want to introduce any more modifications than necessary into
the DBUS source since it will make future updates much more problematic.
The only alternative I could think of is if there was some way to extract the *full* path from the DIR structure. I know
I could use readdir(dirp) to get the dirent structure which contains a directory entry (and the d_name field).
Unfortunately, that does not include the path leading to the directory entry (I guess it assumes you would've used
opendir() to get the dirp in the first place). Is there any way to deduce the full path to the named directory entry
given only the dirp?
|
|
|