dotgnu-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[DotGNU]dir.c


From: Charles Shuller
Subject: [DotGNU]dir.c
Date: Thu, 24 Oct 2002 11:50:58 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020923

Gopal --

I'm attaching an excerpt from lib_dir.c I've asked a few questions about the differences in coding styles, that are best asked in the code where you can see whats going on more easily. I've prefixed comments with our IRC handles so people on the list, as well as ourselves, can more easily identify who said what :)

--
Charles Shuller
Jabber ID: address@hidden
/*
 * public static Errno GetFilesInDirectory(String path, out 
 *                                                                              
        Platform.FileInfo[] files);
 */
/*  What is with the funky break?  */
extern ILInt32 _IL_DirMethods_GetFilesInDirectory(ILExecThread * _thread, 
ILString * path, System_Array * * files)
{
        ILDir *dirStream; /* follow a single std of naming */
        ILDirEnt *dirEntry;
        ILInt32 arraySize = 0;
        Platform_FileInfo *buffer=NULL; /*coz _ptr is for fools who forget :-) 
*/
                                        /*  Oh, Shush, it is also helpfull for 
people starting in the middle
                                            or for those who are new to C, but 
I have no prob leaving it out 
                                            for stylistic reasons :) */
        ILInt32 i;  /*  How surprising, an index var named 'i' */
        /*  I thought this was generaly accepted practice, should it be 
changed???  */

#ifdef HAVE_DIRENT_H /* the dirent-> is included only if HAVE_DIRENT_H */
                     /*  Sortof, Win32 has a different method of this type
                         of operation, so when ported it will also be typedefed
                         to ILDir.  I'll leave the ifdef in for you to decide.  
*/

        dirStream = ILOpenDir(ILStringToAnsi(_thread, path));
        if(!dirStream)
        {
                goto cleanup;
        }
        while(ILReadDir(dirStream))arraySize++;
        if(!ILCloseDir(dirStream))
        {
                goto cleanup;
        }
        *files = (System_Array*) ILExecThreadNew(_thread,
                                                
"[vPlatform.FileInfo;","(Ti)V",(ILVaInt)(arraySize));
        /* I'm confused as to why the linebreak here and with this much 
tabbing.  Is there
           a specific colum we don't want to pass?  */

        /*  Also, am I not allowed to double space between signifigant blocks 
of code?  */
        if(!(*files))
        {
                ILExecThreadThrowOutOfMemory(_thread);
                return IL_ERRNO_EPERM;
        }
        buffer = (Platform_FileInfo *)(ArrayToBuffer(*files));
        dirStream = ILOpenDir(ILStringToAnsi(_thread, path));
        if(!dirStream)
        {
                goto cleanup;
        }
        for(i=0;i<arraySize;i++)
        {
                dirEntry= ILReadDir(dirStream);
                /*  Is it stylistically wrong to space before break, and even
                    put it in '{' '}' ???  */
                if(!dirEntry)break;
                buffer->fileName = ILStringCreate(_thread, dirEntry->d_name);
                buffer->fileType = dirEntry -> d_type;
                ++buffer;
        }
        ILCloseDir(dirStream);
        return ILSysIOConvertErrno(errno);
cleanup:
        *files = (System_Array*) ILExecThreadNew(_thread,
                                "[vPlatform.FileInfo;","(Ti)V",(ILVaInt)(0));
        return IL_ERRNO_EPERM;
#else
        return IL_ERRNO_EPERM;
#endif
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]