Changeset 328 for trunk/dll/walkem.c


Ignore:
Timestamp:
Jul 25, 2006, 8:37:24 PM (19 years ago)
Author:
root
Message:

Use Runtime_Error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/walkem.c

    r259 r328  
    55
    66  Copyright (c) 1993-98 M. Kimes
    7   Copyright (c) 2005, 2004, 2005 Steven H. Levine
     7  Copyright (c) 2005, 2006 Steven H. Levine
    88
    99  01 Aug 04 SHL Rework lstrip/rstrip usage
     
    1111  13 Aug 05 SHL Run through indent
    1212  13 Aug 05 SHL remove_udir - avoid corrupting last dirs list
     13  17 Jul 06 SHL Use Runtime_Error
    1314
    1415***********************************************************************/
     
    3132
    3233#pragma data_seg(DATA1)
     34
     35static PSZ pszSrcFile = __FILE__;
     36
    3337#pragma alloc_text(WALKER,FillPathListBox,WalkDlgProc,TextSubProc)
    3438#pragma alloc_text(WALKER,WalkAllDlgProc,WalkCopyDlgProc)
     
    157161            if (*s && *s != ';')
    158162            {
    159                 info = malloc(sizeof(LINKDIRS));
    160                 if (info)
    161                 {
    162                     info -> path = strdup(s);
    163                     if (info -> path)
     163                info = xmalloc(sizeof(LINKDIRS),pszSrcFile,__LINE__);
     164                if (info) {
     165                    info -> path = xstrdup(s,pszSrcFile,__LINE__);
     166                    if (!info -> path)
     167                        free(info);
     168                    else
    164169                    {
    165170                        info -> next = NULL;
     
    170175                        last = info;
    171176                    }
    172                     else
    173                         free(info);
    174177                }
    175178            }
     
    194197                strcat(s, "\\");
    195198            strcat(s, "USERDIRS.DAT");
    196             fp = fopen(s, "w");
     199            fp = xfopen(s, "w",pszSrcFile,__LINE__);
    197200            if (fp)
    198201            {
     
    279282            }
    280283            // Append entry to end of user dirs list
    281             info = malloc(sizeof(LINKDIRS));
     284            info = xmalloc(sizeof(LINKDIRS),pszSrcFile,__LINE__);
    282285            if (info)
    283286            {
    284                 info -> path = strdup(path);
    285                 if (info -> path)
     287                info -> path = xstrdup(path,pszSrcFile,__LINE__);
     288                if (!info -> path)
     289                    free(info);
     290                else
    286291                {
    287292                    info -> next = NULL;
     
    303308                    return TRUE;
    304309                }
    305                 else
    306                     free(info);
    307310            }
    308311        }
     
    511514        if (!mp2)
    512515        {
     516            Runtime_Error(pszSrcFile, __LINE__, "no data");
    513517            WinDismissDlg(hwnd, 0);
    514518            break;
    515519        }
    516         wa = malloc(sizeof(WALKER));
     520        wa = xmallocz(sizeof(WALKER),pszSrcFile,__LINE__);
    517521        if (!wa)
    518522        {
    519             DosBeep(50, 100);
    520523            WinDismissDlg(hwnd, 0);
    521524            break;
    522525        }
    523         memset(wa, 0, sizeof(WALKER));
    524526        wa -> size = (USHORT) sizeof(WALKER);
    525527        WinSetWindowPtr(hwnd, 0, (PVOID) wa);
     
    819821                APIRET rc;
    820822
    821 //            *szBuffer = 0;
    822                 //            WinQueryDlgItemText(hwnd,WALK_RECENT,CCHMAXPATH,szBuffer);
     823                // *szBuffer = 0;
     824                // WinQueryDlgItemText(hwnd,WALK_RECENT,CCHMAXPATH,szBuffer);
    823825                if (!*szBuffer)
    824826                    break;
     
    841843                    rc = 0;
    842844                }
    843                 if (!rc && (findbuf.attrFile & FILE_DIRECTORY))
     845                if (rc)
     846                    Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,"DosFindFirst");
     847                else if (~findbuf.attrFile & FILE_DIRECTORY)
     848                    Runtime_Error(pszSrcFile, __LINE__, "not a directory");
     849                else
    844850                {
    845851                    strcpy(wa -> szCurrentPath, szBuffer);
     
    851857                                    wa -> szCurrentPath, FALSE);
    852858                }
    853                 else
    854                     DosBeep(50, 100);
    855859            }
    856860            else if (SHORT2FROMMP(mp1) == CBN_ENTER)
     
    892896                    rc = 0;
    893897                }
    894                 if (!rc && (findbuf.attrFile & FILE_DIRECTORY))
     898                if (rc)
     899                    Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,"DosFindFirst");
     900                else if (~findbuf.attrFile & FILE_DIRECTORY)
     901                    Runtime_Error(pszSrcFile, __LINE__, "not a directory");
     902                else
    895903                {
    896904                    strcpy(wa -> szCurrentPath, szBuffer);
     
    901909                                    wa -> szCurrentPath, FALSE);
    902910                }
    903                 else
    904                     DosBeep(50, 100);
    905911            }
    906912            else if (SHORT2FROMMP(mp1) == LN_ENTER)
     
    10571063            {
    10581064                MakeFullName(szBuff);
    1059                 if (add_udir(TRUE,
    1060                              szBuff))
    1061                 {
     1065                if (!add_udir(TRUE, szBuff))
     1066                    Runtime_Error(pszSrcFile, __LINE__, "add_udir");
     1067                else {
    10621068                    WinSendDlgItemMsg(hwnd,
    10631069                                      WALK_USERLIST,
     
    10671073                    wa -> changed = 1;
    10681074                }
    1069                 else
    1070                     DosBeep(50, 100);
    10711075            }
    10721076            break;
Note: See TracChangeset for help on using the changeset viewer.