Ticket #1687: hotloading.patch

File hotloading.patch, 1.5 KB (added by leper, 11 years ago)

Rough prototype

  • source/ps/Filesystem.cpp

     
    7373
    7474    std::vector<DirWatchNotification> notifications;
    7575    RETURN_STATUS_IF_ERR(dir_watch_Poll(notifications));
     76    Status status = INFO::OK;
    7677    for(size_t i = 0; i < notifications.size(); i++)
    7778    {
    7879        if(!CanIgnore(notifications[i]))
    7980        {
     81            // TODO: logging?
     82            #define CONTINUE_IF_ERR(expression)\
     83                status = (expression);\
     84                if (status < 0)\
     85                    continue
     86
    8087            VfsPath pathname;
    81             RETURN_STATUS_IF_ERR(g_VFS->GetVirtualPath(notifications[i].Pathname(), pathname));
    82             RETURN_STATUS_IF_ERR(g_VFS->RemoveFile(pathname));
    83             RETURN_STATUS_IF_ERR(g_VFS->RepopulateDirectory(pathname.Parent()/""));
     88            CONTINUE_IF_ERR(g_VFS->GetVirtualPath(notifications[i].Pathname(), pathname));
     89            // Handle additions of new files too
     90            status = g_VFS->RemoveFile(pathname);
     91            if (status < 0 && status != ERR::VFS_FILE_NOT_FOUND)
     92                continue;
     93
     94            CONTINUE_IF_ERR(g_VFS->RepopulateDirectory(pathname.Parent()/""));
    8495
    8596            // Tell each hotloadable system about this file change:
    8697
    87             RETURN_STATUS_IF_ERR(g_GUI->ReloadChangedFiles(pathname));
     98            g_GUI->ReloadChangedFiles(pathname);
    8899
    89100            for (size_t j = 0; j < g_ReloadFuncs.size(); ++j)
    90101                g_ReloadFuncs[j].first(g_ReloadFuncs[j].second, pathname);
    91102
    92             RETURN_STATUS_IF_ERR(h_reload(g_VFS, pathname));
     103            h_reload(g_VFS, pathname);
     104
     105            #undef CONTINUE_IF_ERR
    93106        }
    94107    }
    95108    return INFO::OK;