stat()/lstat() problem (?)

bertrand marquis bertrand_marquis@yahoo.fr
Wed Apr 28 09:34:00 GMT 2004


ZXPLESPAC001, Ext a écrit:

>	Hi,
>
>here is my question/problem (see the example program below):
>-----//--------
>#include <stdio.h>
>
>#include <sys/types.h>
>#include <sys/stat.h>
>#include <errno.h>
>
>static int is_dir(char * dr)
>{
>        struct stat st;
>
>        if(stat(dr, &st) == -1)
>        {
>                perror("stat");
>                return -1;
>
>        }
>        if(lstat(dr, &st) == -1)
>        {
>                perror("lstat");
>                return -1;
>
>        }
>}
>int main(int argc,char **argv)
>{
>        int rc;
>
>        rc=is_dir("//bin");
>        rc=is_dir("/bin");
>}
>-----//--------
>
>With my version of cygwin(Windows NT Ver 4.0 Build 1381 Service Pack 6 -
>cygwin 1.5.9-1) 
>the first call to is_dir() produces an error(stat: No such file or
>directory)
>BUT the same code was compiled and run on Linux (RH9) and Sun (Solaris2.8)
>and
>produces no errors !!
>
>The question is:
>- is the behavior on Linux/Solaris normal ? I fact there ain't a '//bin'
>only a '/bin',
>but even all the shells treat them as representing the same path (BTW 'cd
>//bin' on 
>cygwin/bash doesn't work ...)
>
this is a normal error under cygwin, you should look at the FAQ: // 
refers to network places

>- is it an error in cygwin ? Did all pathes (oops is my english very clear
>?) have to
>treat dupplicated '/' as single '/' ? Is the notion of a pathname normalized
>somewhere
>(maybe posix ?) ?
>
you should remove all // under cygwin to avoid those errors
see:
http://cygwin.com/faq/faq_toc.html#TOC34

>
>  
>
>------------------------------------------------------------------------
>
>---------------------------------------------------------
>
>CE COURRIER ELECTRONIQUE EST A USAGE STRICTEMENT INFORMATIF ET NE SAURAIT ENGAGER DE QUELQUE MANIERE QUE CE SOIT EADS ASTRIUM SAS, NI SES FILIALES.
>
>SI UNE ERREUR DE TRANSMISSION OU UNE ADRESSE ERRONEE A MAL DIRIGE CE COURRIER, MERCI D'EN INFORMER L'EXPEDITEUR EN LUI FAISANT UNE REPONSE PAR COURRIER ELECTRONIQUE DES RECEPTION. SI VOUS N'ETES PAS LE DESTINATAIRE DE CE COURRIER, VOUS NE DEVEZ PAS L'UTILISER, LE CONSERVER, EN FAIRE ETAT, LE DISTRIBUER, LE COPIER, L'IMPRIMER OU EN REVELER LE CONTENU A UNE TIERCE PARTIE.
>
>
>
>This email is for information only and will not bind EADS Astrium SAS in any contract or obligation, nor its subsidiaries.
>
>If you have received it in error, please notify the sender by return email. If you are not the addressee of this email, you must not use, keep, disseminate, copy, print or otherwise deal with it.
>
>---------------------------------------------------------
>
>  
>
>------------------------------------------------------------------------
>
>--
>Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>Problem reports:       http://cygwin.com/problems.html
>Documentation:         http://cygwin.com/docs.html
>FAQ:                   http://cygwin.com/faq/
>



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list