linux links

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nassim
    New Member
    • Dec 2007
    • 4

    linux links

    Could someone please point me in the right direction with regards to link 'files'. I would like to be able to use the linux c IO to find/query them, along with other data files. they seem to be evading the file radar: the readdir function (dirent.h) is not picking them.

    email.removed@4 .ur.protection. com

    On a different matter, my thanks to Derrick Coetzee for his sample 'pseudo code' fopen_mkdir. Dodgy as it may be, it was welcome help in my project. Here is my code for it:
    Code:
    #define FULLPERMISSIONS 0x41ff
    
    FILE *fopen_mkdir( char *name, char *mode )
    {
        char *mname = (char*) malloc( sizeof( char ) * MAXPATH );
        DIR *DIRp = 0;
        strcpy( mname, name );
        int len = 0, i;
        while ( mname[ len ] != '\0' ) {
             len++;
        }
        for( i = 0; i < len; i++ ) {
            if (( i > 0 ) && ( mname[ i ] == '/')) {
                mname[ i ] = '\0'; // read path up to a slash
                DIRp = opendir( mname );
                if(( mkdir( mname, FULLPERMISSIONS )) && ( !DIRp )) {
                 // mkdir failed, NOT because dir already exists
                    fprintf( stdout, " \n *** error opening %s *** \n", mname );
                    return NULL;
                }
                if( DIRp ) {
                    closedir( DIRp );
                }
                mname[ i ] = '/'; // put it back
            }
        }
        free( mname );
        return( fopen( name, mode));
    }
    Last edited by numberwhun; Dec 17 '07, 03:09 PM. Reason: add code tags
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    Hi nassim, welcome to The Scripts.
    Could you please better describe what you are trying to do? I am tying to figure out your end goal.

    Comment

    • nassim
      New Member
      • Dec 2007
      • 4

      #3
      Originally posted by Motoma
      Hi nassim, welcome to The Scripts.
      Could you please better describe what you are trying to do? I am tying to figure out your end goal.
      sorry i didn't put that very well

      i was kinda hoping for a reply on that same day.. i'm alright now, well n truly in the right direction, thanks

      Comment

      Working...