LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Symbolic links (http://www.linuxquestions.org/questions/programming-9/symbolic-links-18017/)

pdstatha 04-08-2002 11:29 AM

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);
}


crabboy 04-08-2002 09:50 PM

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.


All times are GMT -5. The time now is 05:39 AM.