Re: [PATCH] opening files in remote.c should ensure it is opening a file

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Junio C Hamano <gitster@...>
Cc: Morten Welinder <mwelinder@...>, H.Merijn Brand <h.m.brand@...>, <git@...>
Date: Friday, February 8, 2008 - 9:20 pm

Junio C Hamano wrote:

Can we use fileno()? Something like:

FILE *gitfopen(const char *path, const char *mode)
{   
        FILE *fp;
        struct stat st;

        if (strpbrk(mode, "wa"))
                return fopen(path, mode);

        if (!(fp = fopen(path, mode)))
                return NULL;

        if (fstat(fileno(fp), &st)) {
                fclose(fp);
                return NULL;
        }

        if (S_ISDIR(st.st_mode)) {
                fclose(fp);
                errno = EISDIR;
                return NULL;
        }

        return fp;
}   

-brandon

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] opening files in remote.c should ensure it is op..., Brandon Casey, (Fri Feb 8, 9:20 pm)
Re: [PATCH] opening files in remote.c should ensure it is op..., Johannes Schindelin, (Fri Feb 8, 4:40 pm)
Re: [PATCH] opening files in remote.c should ensure it is op..., Johannes Schindelin, (Fri Feb 8, 5:47 pm)
Re: [PATCH] opening files in remote.c should ensure it is op..., Johannes Schindelin, (Fri Feb 8, 4:38 pm)
Re: [PATCH] opening files in remote.c should ensure it is op..., Johannes Schindelin, (Fri Feb 8, 4:44 pm)