Howdy all!
In C, if I can fopen a file by name and relative path, is there anything I
can do to obtain the absolute path for that file?
Any help would be much appreciated!
Rob
:)
:-}
;->
In C, if I can fopen a file by name and relative path, is there anything I
can do to obtain the absolute path for that file?
Any help would be much appreciated!
Rob
:)
:-}
;->
--
Fletcher Glenn
to reply remove NOSPAM from my reply address
Quote:> Howdy all!
> In C, if I can fopen a file by name and relative path, is there anything I
> can do to obtain the absolute path for that file?
> Any help would be much appreciated!
> Rob
> :)
> :-}
> ;->
I had not thought of this. The program will use the shell's workingQuote:> You can chdir() to the relative directory, then getcwd(). There's
> no guarantee that this is the only path to the file.
mm..
Rob
:)
:-}
;->
> --
> Fletcher Glenn
> to reply remove NOSPAM from my reply address
> > Howdy all!
> > In C, if I can fopen a file by name and relative path, is there anything
I
> > can do to obtain the absolute path for that file?
> > Any help would be much appreciated!
> > Rob
> > :)
> > :-}
> > ;->
not in ansi/iso c, but your unspecified system might have realpath().Quote:>In C, if I can fopen a file by name and relative path, is there anything I
>can do to obtain the absolute path for that file?
--
bringing you boring signatures for 17 years
...which is a X/Open System Interfaces Extension (XSI).Quote:> in comp.unix.programmer i read:
>>In C, if I can fopen a file by name and relative path, is there anything I
>>can do to obtain the absolute path for that file?
> not in ansi/iso c, but your unspecified system might have realpath().
The getcwd function might be of use if you don't have
realpath, it's in POSIX Base.
--
Andreas K?h?ri
--------------------------------------------------------------
Feed your daemons. www.netbsd.org
This is comp.unix.programmer and realpath is part of SUS. Unfortuntely,Quote:> in comp.unix.programmer i read:
> >In C, if I can fopen a file by name and relative path, is there anything I
> >can do to obtain the absolute path for that file?
> not in ansi/iso c, but your unspecified system might have realpath().
DS
And, judging by IEEE Std 1003.1-2001, your system probably does so if itQuote:>in comp.unix.programmer i read:
>>In C, if I can fopen a file by name and relative path, is there anything I
>>can do to obtain the absolute path for that file?
>not in ansi/iso c, but your unspecified system might have realpath().
Gee, sounds like you you read before you post. The thread "Full path name" hasQuote:> Howdy all!
> In C, if I can fopen a file by name and relative path, is there anything I
> can do to obtain the absolute path for that file?
> Any help would be much appreciated!
> Rob
--
Communications Research Centre / RNS Tel (613) 998-2845
3701 Carling Ave., Fax (613) 998-9648
Ottawa, Ontario
K2H 8S2
Canada
>> not in ansi/iso c, but your unspecified system might have realpath().
> This is comp.unix.programmer and realpath is part of SUS.
i didn't say it was. on a system with /proc/self/fd one might just openQuote:>Unfortuntely, it's not quite 100% reliable on many implementations. For
>one thing, a file may not have a single absolute path.
--
bringing you boring signatures for 17 years
CHANGE HISTORYQuote:>Submitted by "those who know me have no need of my name" to
>comp.unix.programmer:
>> your unspecified system might have realpath().
>...which is a X/Open System Interfaces Extension (XSI).
First released in Issue 4, Version 2.
Issue 5
Moved from X/OPEN UNIX extension to BASE.
--
bringing you boring signatures for 17 years
I have to admit that I didn't read that far...Quote:> in comp.unix.programmer i read:
>>Submitted by "those who know me have no need of my name" to
>>comp.unix.programmer:
>>> your unspecified system might have realpath().
>>...which is a X/Open System Interfaces Extension (XSI).
> CHANGE HISTORY
> First released in Issue 4, Version 2.
> Issue 5
> Moved from X/OPEN UNIX extension to BASE.
--
Andreas K?h?ri
Bioinformatics and Unix System Support, Dunedin, New Zealand
--------------------------------------------------------------
Feed your daemons. www.netbsd.org
1. Relative path to Absolute path
I'm looking for a C algorithm to convert relative paths to an absolute
path.
For instance, I want to resolve "/usr/bin/X11/../ls" into "/usr/bin/ls."
But I would also like to generally clean up a path as well; eg.
"/usr/bin//ls" to "/usr/bin/ls," and so on.
Years ago I saw an algorithm to do this, posted here, but I have since
lost the darn thing.
Thanks for any ideas,
RH
2. Diamond Stealth 64 DRAM - Final Word!!
3. Relative path to Absolute Path
4. Which Databases are available for Linux
5. Symbolic Links - Absolute Paths to Relative Paths
7. Add an absolute path prefix only to relative paths
8. How to set up Redhat linux without a CD-ROM
9. How to convert a relative path into an absolute one?
10. tarring absolute paths for relative untar
11. Make relative tar path absolute at extraction
12. finding absolute or relative path?
13. Relative / absolute paths and symlinks