LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-08-2002, 11:29 AM   #1
pdstatha
LQ Newbie
 
Registered: Apr 2002
Location: UK - Swansea
Posts: 3

Rep: Reputation: 0
Symbolic links


Why won't this code work????

Code:
if(S_ISLNK(sbuf.st_mode)){
        if(readlink(curdir,buf,(size_t)FILENAME_MAX) != -1){
          if(lstat(buf,&sbuf) == -1){
            fprintf(stderr,"Can't stat %s\n",filename);
            return;
          }
        }else
          fprintf(stderr,"Can't readlink %s\n",filename);
      }
}

mode = sbuf.st_mode;
if( S_ISLNK( mode ) ){ type = 'l'; /*symlink: This doesn't work*/
  printf("%c\n",type);
}
 
Old 04-08-2002, 09:50 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Sorry to say this but it worked for me.

Code:
int mode;

if ( S_ISLNK( stFileInfo.st_mode ))
   printf("is link\n");
mode = stFileInfo.st_mode;
if ( S_ISLNK( mode ))
   printf("is link Test2\n");
All I can suggest is running it through gdb. See if the value of sbuf.st_mode is the same as mode after the assignment.
Let me know if you need help with gdb.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
symbolic links durden2.0 Linux - Newbie 6 11-12-2008 03:06 AM
Symbolic Links petercool Linux - General 2 08-20-2003 11:15 AM
Symbolic links bkmesenbrink Linux - Newbie 2 11-13-2002 11:54 AM
symbolic links winger Linux - General 5 04-06-2002 05:16 PM
Symbolic links Valerie Linux - Newbie 12 03-31-2002 01:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration