Thanks.
/root
--
Learn more or lose your rights!
http://www.guncontrolkills.com/
http://www.gunbanobama.com/
Learn more or lose your rights!
Don't use fopen - use readlink(2) instead.
If the file you give readlink isn't a symbolic link, it will return -1
and set errno to EINVAL, so that lets you tell whether or not a file is
a symlink.
The C language has nothing to say about this; C is implemented on
plenty of systems that don't have symbolic links. I'm sure the nice
folks in comp.unix.programmer will be happy to answer your question.
<OT>Hint: readlink</OT>
--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
> root <ro...@localhost.localdomain> writes:
>> Hi when I use fopen on a sym bolic link, it will follow the link and open
>> thae target file. Most times this is what I want, but my question is: how
>> to get fopen to open the link itself (= file containing path to be
>> followed), what is the option I need.
>
> The C language has nothing to say about this; C is implemented on
> plenty of systems that don't have symbolic links. I'm sure the nice
> folks in comp.unix.programmer will be happy to answer your question.
>
> <OT>Hint: readlink</OT>
readlink is a C function. What do you mean it has nothing to do with
C? How ludicrous.
,----
| #include <unistd.h>
|
| ssize_t readlink(const char *path, char *buf, size_t
| bufsiz);
`----
Yup. Looks like C to me.
--
"Avoid hyperbole at all costs, its the most destructive argument on
the planet" - Mark McIntyre in comp.lang.c
You don't. If you asked in a Unix programming group, you might even get
an answer as to the question you should have asked. :)
-s
--
Copyright 2009, all wrongs reversed. Peter Seebach / usenet...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
> On 2009-12-16, root <ro...@localhost.localdomain> wrote:
>> Hi when I use fopen on a sym bolic link, it will follow the link and open
>> thae target file. Most times this is what I want, but my question is: how
>> to get fopen to open the link itself (= file containing path to be
>> followed), what is the option I need.
>
> You don't. If you asked in a Unix programming group, you might even get
> an answer as to the question you should have asked. :)
>
> -s
Had you not been such a killfile happy know all, you would have seen
that the OP already got a perfectly good reply. The question also raises
its head : how did you not see Keith's reply which said the same as you
(surprise) AND included the correct function reference. and don't come
the old "usenet delay" bullshit - it's not 1986 .... You just wanted to
see your name in lights net nannying once more.
> > On 2009-12-16, root <ro...@localhost.localdomain> wrote:
> >> Hi when I use fopen on a sym bolic link, it will follow the link and open
> >> thae target file. Most times this is what I want, but my question is: how
> >> to get fopen to open the link itself (= file containing path to be
> >> followed), what is the option I need.
> >
> > You don't. If you asked in a Unix programming group, you might even get
> > an answer as to the question you should have asked. :)
> >
> > -s
> Had you not been such a killfile happy know all, you would have seen
> that the OP already got a perfectly good reply.
Why do you assume that readlink is the better answer over the CopyFileEx,
CreateFile, FindFirstFile family of functions? Unix isn't the only platform
that has symbolic links.
Since I'm the person who gave the readlink hint, yes, I did assume
that the OP was using a Unix-like platform. I assumed (incorrectly,
apparently) that only Unix-like systems have symbolic links.
To the OP: If you're not using a Unix-like system (such as Linux),
ask in a newsgroup that deals with your OS. If it's MS Windows,
try comp.os.ms-windows.programmer.win32.
It gets complicated. :)
There is a great deal of magic to deal with in trying to deal with links,
and if the OP wanted to, say, open the file so as to write to it, then
readlink isn't very helpful.
It is, it turns out, complicated.
Right, since when do Windows users commonly post under the name
ro...@localhost.localdomain
?
Whether or not you can use readlink on Windows depends on which SDK you
install. Windows doesn't come with a toolchain, so you get to teach
Windows what symlink API it should speak. If you install Cygwin, you can
use readlink.
What's so odd about that? I use both Windows and Linux myself.