Re: Best way to resolve a soft link?
Posted: Tue Jun 03, 2014 6:48 am
Hello everyone.
I have been away so have not been able to get back to this thread for a while.
It seems my question was not understood, or at least I need to explain the idea behind what I want to do and why.
I am writing (actually have written) some backup software which mirrors a partition or directory onto another partition or directory. Currently is just skips any links that it finds but I want it to be able to recreate links on the target backup directory. A good example is the Amiga SDK - it contains about 15 or so softlinks. When I backed my AmigaOne hard drive up onto another hard drive for use on my new AmigaOne, the SDK did not work as the links had not been recreated. So I want to update my backup software to be able to handle these links. For example, in the SDK:gcc/bin directory we have the following files (among others):
$List SDK:gcc/bin/
Directory "SDK:gcc/bin" on Tuesday 03-Jun-14
ppc-amigaos-strip Link ----rwed 03-Nov-13 15:20:45
> DH2:SDK/gcc/bin/strip
ppc-amigaos-strings Link ----rwed 03-Nov-13 15:20:45
> DH2:SDK/gcc/bin/strings
ppc-amigaos-readelf Link ----rwed 03-Nov-13 15:20:45
> DH2:SDK/gcc/bin/readelf
I want these links to be recreated in the target directory. For this I can't just let DOS "take care of things" but must work with the links themselves directly. We have DOS->MakeLink() that can be used to create the link in the target directory, but I need to first find the target of the link in the source directory in order to know how to recreate it on the target.
I already perform an ExamineDir() loop and then check within this loop to see if a file is a link EXD_IS_LINK() and at this point I could get information about the target of the link. Unfortunately this is in a C++ abstraction layer that runs across three platforms (Amiga, Windows, Linux) allowing my code to be "write once, run anywhere" to an extent, so I do not want to modify this to save link information for every file. It would be easier to write a GetLinkInfo() function that works on Amiga, Windows and Linux and returns information about the target of the link. But for this there does not seem to be a way of doing this apart from using this old DOS->ReadSoftLink() function or by rescanning the directory with ExamineDir() which of course is inefficient. On Windows and Linux there are functions for this but not on Amiga that I can find.
So it seems that we have a small API deficiency here. Any other ideas?
I have been away so have not been able to get back to this thread for a while.
It seems my question was not understood, or at least I need to explain the idea behind what I want to do and why.
I am writing (actually have written) some backup software which mirrors a partition or directory onto another partition or directory. Currently is just skips any links that it finds but I want it to be able to recreate links on the target backup directory. A good example is the Amiga SDK - it contains about 15 or so softlinks. When I backed my AmigaOne hard drive up onto another hard drive for use on my new AmigaOne, the SDK did not work as the links had not been recreated. So I want to update my backup software to be able to handle these links. For example, in the SDK:gcc/bin directory we have the following files (among others):
$List SDK:gcc/bin/
Directory "SDK:gcc/bin" on Tuesday 03-Jun-14
ppc-amigaos-strip Link ----rwed 03-Nov-13 15:20:45
> DH2:SDK/gcc/bin/strip
ppc-amigaos-strings Link ----rwed 03-Nov-13 15:20:45
> DH2:SDK/gcc/bin/strings
ppc-amigaos-readelf Link ----rwed 03-Nov-13 15:20:45
> DH2:SDK/gcc/bin/readelf
I want these links to be recreated in the target directory. For this I can't just let DOS "take care of things" but must work with the links themselves directly. We have DOS->MakeLink() that can be used to create the link in the target directory, but I need to first find the target of the link in the source directory in order to know how to recreate it on the target.
I already perform an ExamineDir() loop and then check within this loop to see if a file is a link EXD_IS_LINK() and at this point I could get information about the target of the link. Unfortunately this is in a C++ abstraction layer that runs across three platforms (Amiga, Windows, Linux) allowing my code to be "write once, run anywhere" to an extent, so I do not want to modify this to save link information for every file. It would be easier to write a GetLinkInfo() function that works on Amiga, Windows and Linux and returns information about the target of the link. But for this there does not seem to be a way of doing this apart from using this old DOS->ReadSoftLink() function or by rescanning the directory with ExamineDir() which of course is inefficient. On Windows and Linux there are functions for this but not on Amiga that I can find.
So it seems that we have a small API deficiency here. Any other ideas?