path to a file

path to a file

Post by non » Sun, 06 Oct 2002 05:18:14



hi everyone

i have a
gchar *path = /home/tom/somefile.gz;
and i wants to get the path to that file.. (in this example ('/home/tom'
or '/home/tom/')..
is there a function ?
or how can i do that ?

thanks
tom

 
 
 

path to a file

Post by Dragan Cvetkovi » Sun, 06 Oct 2002 05:00:18



> hi everyone

> i have a
> gchar *path = /home/tom/somefile.gz;
> and i wants to get the path to that file.. (in this example ('/home/tom' or
> '/home/tom/')..
> is there a function ?
> or how can i do that ?

man dirname(3).

HTH, Dragan

--
Dragan Cvetkovic,

To be or not to be is true. G. Boole      No it isn't.  L. E. J. Brouwer

 
 
 

path to a file

Post by Eric P. McC » Sun, 06 Oct 2002 09:17:26



> man dirname(3).

dirname() might not be sufficiently portable, in which case you can
always implement it using strrchr(the_path, "/").

--

"Last I checked, it wasn't the power cord for the Clue Generator that
was sticking up your ass." - John Novak, rasfwrj

 
 
 

path to a file

Post by phil-news-nos.. » Sun, 06 Oct 2002 13:02:02



| i have a
| gchar *path = /home/tom/somefile.gz;
| and i wants to get the path to that file.. (in this example ('/home/tom'
| or '/home/tom/')..
| is there a function ?
| or how can i do that ?

I don't know what you are asking.  If you already have the path of the
file as in that first statement, then what are you trying to get?  Are
you trying to just extract the path of the parent directory, such as
with:

    char parent[PATH_MAX];

    strncpy(parent,PATH_MAX-1,path);
    parent[PATH_MAX-1]=0;
    if((p=strrchr(parent,'/')))*p=0;

--
-----------------------------------------------------------------
| Phil Howard - KA9WGN |   Dallas   | http://linuxhomepage.com/ |

-----------------------------------------------------------------

 
 
 

path to a file

Post by Dragan Cvetkovi » Tue, 08 Oct 2002 07:56:41




> > man dirname(3).

> dirname() might not be sufficiently portable, in which case you can
> always implement it using strrchr(the_path, "/").

Agreed. But then, OP has posted in Linux newsgroup only and Linux provides
dirname() and basename(). Otherwise I would alway go for strrchr().

Bye, Dragan

--
Dragan Cvetkovic,

To be or not to be is true. G. Boole      No it isn't.  L. E. J. Brouwer

 
 
 

1. Secure CGI Path Access (translate file path "/" to user homedir)

Hi,

i just configured my webserver (apache) with suexec, so CGI
Scripts are executed with the users uid. Now i do only want
the users CGI Scripts to have access inside their homedir
("/home/www/userdir"). How do i prevent the CGI Scripts from
accessing files like "/etc/httpd/httpd.conf" without changing
all file permissions.

Is there a solution for the setting a virtual User Root Dir
"/" to "/home/www/userdir" ?

PS: Users have no shell Access...

Thanks, Niemo.

2. remote printer problem

3. C: get absolute path to a file from relative path

4. pattern matching question

5. automatically adding paths to $PATH in startup files

6. Freeze on Asus A7V Mobo

7. add in the PATH a path if not present in the PATH

8. How do i get text from a Window to another.

9. ksh: add path to $PATH only when ot yet in $PATH

10. zsh's 'typeset -U path' wipes out path/PATH

11. PATH=$(getconf PATH), but PATH for getconf?

12. set path = "$path" hoses path in tcsh -- why???

13. How to expand paths in $PATH like "~/bin" to full path?