How do I query information for a link?
Posted: Mon Aug 01, 2016 6:47 am
Hello.
I have a C++ support class that can be used for querying directory contents on multiple platforms. You call it and it returns a list of objects with information about the files present in the directory. It is cross platform and works on Amiga OS, Linux and Windows. Each entry returned will be in a structure like the following:
struct TEntry
{
char *Name;
char *Link;
bool IsLink;
...
};
If a file is not a link then Name will point to its name, Link will be NULL and IsLink will be false.
If a file *is* a link then Name will point to the name of the source link, Link will point to the name of the file the link points to and IsLink will be true.
On Linux and Windows you can control whether a link is dereferenced or not when you query a file. On Linux, lstat() queries info about the link and stat() resolves the link and queries info about the file the link points to. On Windows you can control this behaviour passing the FILE_FLAG_OPEN_REPARSE_POINT to CreateFile().
On Amiga OS I cannot find any such mechanism. IDOS->ExamineObjectTags() always dereferences the link and does not fill out the Link member of the ExamineData structure. Ok, I could use IDOS->ExamineDir() to iterate through all entries in the directory but this is an ugly workaround and has performance implications.
Any ideas?
I have a C++ support class that can be used for querying directory contents on multiple platforms. You call it and it returns a list of objects with information about the files present in the directory. It is cross platform and works on Amiga OS, Linux and Windows. Each entry returned will be in a structure like the following:
struct TEntry
{
char *Name;
char *Link;
bool IsLink;
...
};
If a file is not a link then Name will point to its name, Link will be NULL and IsLink will be false.
If a file *is* a link then Name will point to the name of the source link, Link will point to the name of the file the link points to and IsLink will be true.
On Linux and Windows you can control whether a link is dereferenced or not when you query a file. On Linux, lstat() queries info about the link and stat() resolves the link and queries info about the file the link points to. On Windows you can control this behaviour passing the FILE_FLAG_OPEN_REPARSE_POINT to CreateFile().
On Amiga OS I cannot find any such mechanism. IDOS->ExamineObjectTags() always dereferences the link and does not fill out the Link member of the ExamineData structure. Ok, I could use IDOS->ExamineDir() to iterate through all entries in the directory but this is an ugly workaround and has performance implications.
Any ideas?