GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to get absolute path in GTK- C

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
iswariak
Familiar Face


Joined: 28 Jun 2006
Posts: 8

PostPosted: Mon Jul 03, 2006 5:34 am    Post subject: How to get absolute path in GTK- C Reply with quote

Hi all
How to get an absolute path of an file in GTK.

Thanks in advance.

Iswaria.
Back to top
iswariak
Familiar Face


Joined: 28 Jun 2006
Posts: 8

PostPosted: Mon Jul 03, 2006 8:49 am    Post subject: Code to find the absolute path of the current directory Reply with quote

Hi

Code to find the absolute path of the current directory

--------------------------------------------------------------------
#include <stdio.h>

int main() {
FILE *in;
extern FILE *popen();
char buff[512];

/* popen creates a pipe so we can read the output
of the program we are invoking */
if (!(in = popen("pwd", "r"))) {
exit(1);
}

/* read the output of netstat, one line at a time */
while (fgets(buff, sizeof(buff), in) != NULL ) {
printf("Output: %s", buff);
}

/* close the pipe */
pclose(in);
}

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

Regards
Iswaria.
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 462
Location: Portland, OR USA

PostPosted: Mon Jul 03, 2006 5:42 pm    Post subject: Reply with quote

You can also use standard GNU C functions such as getwd and getcwd as described at http://www.gnu.org/software/libc/manual/html_node/Working-Directory.html
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP