The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
absolute path Kirichiko UNIX for Dummies Questions & Answers 2 10-03-2007 03:30 AM
$PWD shows absolute path vs path w/symbolic links kornshellmaven Shell Programming and Scripting 3 06-13-2007 09:15 AM
absolute path filedeliver High Level Programming 4 06-05-2007 02:18 PM
vi - replacing a relative path with absolute path in a file Yinzer955i UNIX for Dummies Questions & Answers 2 09-07-2006 08:47 AM
want the current directory without the absolute path olimiles Shell Programming and Scripting 2 09-01-2006 04:07 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 11-01-2003
Registered User
 

Join Date: Nov 2003
Posts: 1
HOW to make absolute path???? HELP

In the funtion C function link(char *existing, char *new);
existing has to be an absolute path.
But what happens if i want to make a ling to a file in the users home directory (assume file.txt exists)
i cant put in a "~/file.txt" or "./file.txt"

How can i turn the above into the entire path is there a C call to do it
i know the call diname given "~" returns "." which is again what i cant use.

I need some help.
thanks
Reply With Quote
Forum Sponsor
  #2  
Old 11-01-2003
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,616
Please read the rules. There is a link to the rules at the bottom of the page. I deleted the duplicate thread.

link() does not require absolute paths. It will work fine with relative paths. No system call understands the symbol ~ as a directory. That is a shell convention only. You cannot do link("$HOME/filex", "$HOME/bin/filex") either. The symbol ~ is in the boat as $HOME.

I assume that you mean dirname() and not diname(). If so you are misunderstanding how it interprets ~. It thinks that ~ is filename. And it returns . as the parent directory of that file.

If you want to get the user's home directory, you need either the uid or the name of the user. You can use getpwuid() or getpwname() to get the password file entry.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:56 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0