D
David Mathog
There have been a series of questions about directory operations, all of
which have been answered with "there is no portable way to do this".
This raises the perfectly reasonable question, why, in this day and age,
does the C standard have no abstract and portable method for
dealing with directories? It doesn't seem like a particularly
difficult problem. For instance, this
int show_current_directory(struct DIRSTRUCT *current_directory);
could return status values like these:
VALID_DIRECTORY
success, and the structure is filled in
PLATFORM_HAS_NO_DIRECTORIES
self evident, what you'd see on an embedded controller, for
instance.
CURRENT_DIRECTORY_DOES_NOT_EXIST
like after "cd /newdirectory", when
the directory has not been created yet. Structure
is filled in. Some bit in that structure indicates
that the directory doesn't actually exist.
ERROR
self evident
The organization of DIRSTRUCT could be platform dependent, so
long as key operations (navigation, create directory, delete
directory, compare directory structures [am I in this directory?]) are
fully supported by functions operating on this type.
So, what's the real scoop. Why doesn't the standard support
portable directory operations????
Thanks,
David Mathog
which have been answered with "there is no portable way to do this".
This raises the perfectly reasonable question, why, in this day and age,
does the C standard have no abstract and portable method for
dealing with directories? It doesn't seem like a particularly
difficult problem. For instance, this
int show_current_directory(struct DIRSTRUCT *current_directory);
could return status values like these:
VALID_DIRECTORY
success, and the structure is filled in
PLATFORM_HAS_NO_DIRECTORIES
self evident, what you'd see on an embedded controller, for
instance.
CURRENT_DIRECTORY_DOES_NOT_EXIST
like after "cd /newdirectory", when
the directory has not been created yet. Structure
is filled in. Some bit in that structure indicates
that the directory doesn't actually exist.
ERROR
self evident
The organization of DIRSTRUCT could be platform dependent, so
long as key operations (navigation, create directory, delete
directory, compare directory structures [am I in this directory?]) are
fully supported by functions operating on this type.
So, what's the real scoop. Why doesn't the standard support
portable directory operations????
Thanks,
David Mathog