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 07:30 AM
$PWD shows absolute path vs path w/symbolic links kornshellmaven Shell Programming and Scripting 3 06-13-2007 01:15 PM
absolute path filedeliver High Level Programming 4 06-05-2007 06:18 PM
vi - replacing a relative path with absolute path in a file Yinzer955i UNIX for Dummies Questions & Answers 2 09-07-2006 12:47 PM
want the current directory without the absolute path olimiles Shell Programming and Scripting 2 09-01-2006 08:07 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-01-2003
youngvet youngvet is offline
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
  #2 (permalink)  
Old 11-01-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,123
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0