示例#1
0
void
single_dirsize_cmd (void)
{
    WPanel *panel = current_panel;
    file_entry_t *entry;

    entry = &(panel->dir.list[panel->selected]);
    if (S_ISDIR (entry->st.st_mode) && !DIR_IS_DOTDOT (entry->fname))
    {
        size_t dir_count = 0;
        size_t count = 0;
        uintmax_t total = 0;
        dirsize_status_msg_t dsm;
        vfs_path_t *p;

        p = vfs_path_from_str (entry->fname);

        memset (&dsm, 0, sizeof (dsm));
        status_msg_init (STATUS_MSG (&dsm), _("Directory scanning"), 1.0, dirsize_status_init_cb,
                         dirsize_status_update_cb, dirsize_status_deinit_cb);

        if (compute_dir_size (p, &dsm, &dir_count, &count, &total, TRUE) == FILE_CONT)
        {
            entry->st.st_size = (off_t) total;
            entry->f.dir_size_computed = 1;
        }

        vfs_path_free (p);

        status_msg_deinit (STATUS_MSG (&dsm));
    }

    if (panels_options.mark_moves_down)
        send_message (panel, NULL, MSG_ACTION, CK_Down, NULL);

    recalculate_panel_summary (panel);

    if (current_panel->sort_field->sort_routine == (GCompareFunc) sort_size)
        panel_re_sort (panel);

    panel->dirty = 1;
}
示例#2
0
void
dirsizes_cmd (void)
{
    WPanel *panel = current_panel;
    int i;
    dirsize_status_msg_t dsm;

    memset (&dsm, 0, sizeof (dsm));
    status_msg_init (STATUS_MSG (&dsm), _("Directory scanning"), 1.0, dirsize_status_init_cb,
                     dirsize_status_update_cb, dirsize_status_deinit_cb);

    for (i = 0; i < panel->dir.len; i++)
        if (S_ISDIR (panel->dir.list[i].st.st_mode)
            && ((panel->dirs_marked && panel->dir.list[i].f.marked)
                || !panel->dirs_marked) && !DIR_IS_DOTDOT (panel->dir.list[i].fname))
        {
            vfs_path_t *p;
            size_t dir_count = 0;
            size_t count = 0;
            uintmax_t total = 0;
            gboolean ok;

            p = vfs_path_from_str (panel->dir.list[i].fname);
            ok = compute_dir_size (p, &dsm, &dir_count, &count, &total, TRUE) != FILE_CONT;
            vfs_path_free (p);
            if (ok)
                break;

            panel->dir.list[i].st.st_size = (off_t) total;
            panel->dir.list[i].f.dir_size_computed = 1;
        }

    status_msg_deinit (STATUS_MSG (&dsm));

    recalculate_panel_summary (panel);

    if (current_panel->sort_field->sort_routine == (GCompareFunc) sort_size)
        panel_re_sort (panel);

    panel->dirty = 1;
}
示例#3
0
mc_search_cbret_t
mcview_search_update_cmd_callback (const void *user_data, gsize char_offset)
{
    status_msg_t *sm = STATUS_MSG (user_data);
    mcview_search_status_msg_t *vsm = (mcview_search_status_msg_t *) user_data;
    mc_search_cbret_t result = MC_SEARCH_CB_OK;

    vsm->offset = (off_t) char_offset;
    if (vsm->offset >= vsm->view->update_activate)
    {
        vsm->view->update_activate += vsm->view->update_steps;

        if (sm->update (sm) == B_CANCEL)
            result = MC_SEARCH_CB_ABORT;
    }

    /* may be in future return from this callback will change current position in searching block. */

    return result;
}
示例#4
0
mc_search_cbret_t
mcview_search_update_cmd_callback (const void *user_data, gsize char_offset)
{
    status_msg_t *sm = STATUS_MSG (user_data);
    mcview_search_status_msg_t *vsm = (mcview_search_status_msg_t *) user_data;
    WView *view = vsm->view;
    gboolean do_update = FALSE;
    mc_search_cbret_t result = MC_SEARCH_CB_OK;

    vsm->offset = (off_t) char_offset;

    if (mcview_search_options.backwards)
    {
        if (vsm->offset <= view->update_activate)
        {
            view->update_activate -= view->update_steps;

            do_update = TRUE;
        }
    }
    else
    {
        if (vsm->offset >= view->update_activate)
        {
            view->update_activate += view->update_steps;

            do_update = TRUE;
        }
    }

    if (do_update && sm->update (sm) == B_CANCEL)
        result = MC_SEARCH_CB_ABORT;

    /* may be in future return from this callback will change current position in searching block. */

    return result;
}
示例#5
0
BOOLEAN SetupResetCurrentInstall(
    _In_ PVOID Arguments
    )
{
    STATUS_MSG(L"Setting up for first time use...");

    ProcessHackerShutdown();

    ULONG err = ERROR_SERVICE_DOES_NOT_EXIST;

    do
    {
        Sleep(1000);

        err = KphUninstall();

    } while (err != ERROR_SERVICE_DOES_NOT_EXIST);

    RemoveAppCompatEntries();

    //PPH_STRING clientPath = GetProcessHackerInstallPath();
    //PPH_STRING startmenu = GetKnownLocation(CSIDL_COMMON_PROGRAMS, TEXT("\\ProcessHacker2"));
    //PPH_STRING desktopShortcutString = GetKnownLocation(CSIDL_DESKTOPDIRECTORY, TEXT("\\Process Hacker 2.lnk"));
    //PPH_STRING startmenuShortcutString = GetKnownLocation(CSIDL_COMMON_PROGRAMS, TEXT("\\Process Hacker 2.lnk"));
    //PPH_STRING startmenuStartupShortcutString = GetKnownLocation(CSIDL_COMMON_PROGRAMS, TEXT("\\Startup\\Process Hacker 2.lnk"));


    STATUS_MSG(L"Cleaning up...\n");
    Sleep(1000);

    //PPH_STRING clientPathString = StringFormat(TEXT("%s\\ProcessHacker.exe"), SetupInstallPath->Buffer);
    //PPH_STRING uninstallPath = StringFormat(TEXT("%s\\ProcessHacker-Setup.exe"), SetupInstallPath->Buffer);
    //PPH_STRING clientPathArgsString = StringFormat(TEXT("\"%s\\ProcessHacker.exe\""), SetupInstallPath->Buffer);
    //PPH_STRING clientPathExeString = StringFormat(TEXT("\"%s\" \"%%1\""), clientPathString->Buffer);

    // Create the Uninstall key...

    //HKEY keyHandle = RegistryCreateKey(
    //    HKEY_LOCAL_MACHINE,
    //    TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ProcessHacker2"),
    //    KEY_ALL_ACCESS | KEY_WOW64_32KEY
    //    );
    //
    //if (keyHandle)
    //{
    //    RegistrySetString(keyHandle, TEXT("DisplayName"), TEXT("Process Hacker"));
    //    RegistrySetString(keyHandle, TEXT("InstallLocation"), SetupInstallPath->Buffer);
    //    RegistrySetString(keyHandle, TEXT("UninstallString"), uninstallPath->Buffer);
    //    RegistrySetString(keyHandle, TEXT("DisplayIcon"), uninstallPath->Buffer);
    //    RegistrySetString(keyHandle, TEXT("Publisher"), TEXT("Electronic Arts, Inc."));
    //    RegistrySetString(keyHandle, TEXT("URLInfoAbout"), TEXT("http://wj32.org/ProcessHacker"));
    //    RegistrySetString(keyHandle, TEXT("HelpLink"), TEXT("http://wj32.org/ProcessHacker"));
    //    RegistrySetDword(keyHandle, TEXT("NoModify"), 1);
    //    RegistrySetDword(keyHandle, TEXT("NoRepair"), 1);
    //    RegCloseKey(keyHandle);
    //}

    //if (IsCreateDesktopSelected)
    //{
    //    PPH_STRING desktopFolderString = GetKnownLocation(
    //        CSIDL_DESKTOPDIRECTORY,
    //        TEXT("\\ProcessHacker.lnk")
    //        );

    //    //if (!CreateLink(
    //    //    desktopFolderString->Buffer, clientPathString->Buffer, SetupInstallPath->Buffer,
    //    //    TEXT("")
    //    //    ))
    //    //{
    //    //    DEBUG_MSG(TEXT("ERROR CreateDesktopLink: %u\n"), GetLastError());
    //    //}

    //    PhFree(desktopFolderString);
    //}

    //if (IsCreateStartSelected)
    //{
    //    PPH_STRING startmenuFolderString = GetKnownLocation(
    //        CSIDL_COMMON_PROGRAMS,
    //        TEXT("\\ProcessHacker.lnk")
    //        );

    //    //if (!CreateLink(
    //    //    startmenuFolderString->Buffer, clientPathString->Buffer, SetupInstallPath->Buffer,
    //    //    TEXT("")
    //    //    ))
    //    //{
    //    //    DEBUG_MSG(TEXT("ERROR CreateStartLink: %u\n"), GetLastError());
    //    //}

    //    PhFree(startmenuFolderString);
    //}

    //if (IsCreateRunStartupSelected)
    //{
    //    PPH_STRING startmenuStartupString = GetKnownLocation(
    //        CSIDL_COMMON_STARTUP,
    //        TEXT("\\ProcessHacker.lnk")
    //        );

    //    //if (!CreateLink(
    //    //    startmenuStartupString->Buffer, clientPathString->Buffer, SetupInstallPath->Buffer,
    //    //    TEXT("")
    //    //    ))
    //    //{
    //    //    DEBUG_MSG(TEXT("ERROR CreateLinkStartup: %u\n"), GetLastError());
    //    //}

    //    PhFree(startmenuStartupString);
    //}

    // GetCachedImageIndex Test
    //{
    //    SHFOLDERCUSTOMSETTINGS fcs = { sizeof(SHFOLDERCUSTOMSETTINGS) };
    //    fcs.dwMask = FCSM_ICONFILE;
    //    fcs.pszIconFile = TEXT("ProcessHacker.exe");
    //    fcs.cchIconFile = _tcslen(TEXT("ProcessHacker.exe")) * sizeof(TCHAR);
    //    fcs.iIconIndex = 0;

    //    if (SUCCEEDED(SHGetSetFolderCustomSettings(&fcs, SetupInstallPath->Buffer, FCS_FORCEWRITE)))
    //    {
    //        SHFILEINFO shellFolderInfo = { 0 };

    //        if (SHGetFileInfo(SetupInstallPath->Buffer, 0, &shellFolderInfo, sizeof(SHFILEINFO), SHGFI_ICONLOCATION))
    //        {
    //            PPH_STRING fileName = FileGetBaseName(shellFolderInfo.szDisplayName);


    //            INT shellIconIndex = Shell_GetCachedImageIndex(
    //                fileName->Buffer,
    //                shellFolderInfo.iIcon,
    //                0
    //                );

    //            SHUpdateImage(
    //                fileName->Buffer,
    //                shellFolderInfo.iIcon,
    //                0,
    //                shellIconIndex
    //                );

    //            SHChangeNotify(SHCNE_UPDATEIMAGE, SHCNF_DWORD, NULL, (PVOID)shellIconIndex);

    //            PhFree(fileName);
    //        }
    //    }
    //}

    //_tspawnl(_P_DETACH, clientPathString->Buffer, clientPathArgsString->Buffer, NULL);

    //if (clientPathExeString)
    //    PhFree(clientPathExeString);

    //if (clientPathArgsString)
    //    PhFree(clientPathArgsString);

    //if (uninstallPath)
    //    PhFree(uninstallPath);

    //if (clientPathString)
    //    PhFree(clientPathString);


    return TRUE;
}
示例#6
0
void
mcview_do_search (WView * view, off_t want_search_start)
{
    mcview_search_status_msg_t vsm;

    off_t search_start = 0;
    off_t orig_search_start = view->search_start;
    gboolean found = FALSE;

    size_t match_len;

    view->search_start = want_search_start;
    /* for avoid infinite search loop we need to increase or decrease start offset of search */

    if (view->search_start != 0)
    {
        if (!view->text_nroff_mode)
            search_start = view->search_start + (mcview_search_options.backwards ? -2 : 0);
        else
        {
            if (mcview_search_options.backwards)
            {
                mcview_nroff_t *nroff;

                nroff = mcview_nroff_seq_new_num (view, view->search_start);
                if (mcview_nroff_seq_prev (nroff) != -1)
                    search_start =
                        -(mcview__get_nroff_real_len (view, nroff->index - 1, 2) +
                          nroff->char_length + 1);
                else
                    search_start = -2;

                mcview_nroff_seq_free (&nroff);
            }
            else
            {
                search_start = mcview__get_nroff_real_len (view, view->search_start + 1, 2);
            }
            search_start += view->search_start;
        }
    }

    if (mcview_search_options.backwards && search_start < 0)
        search_start = 0;

    /* Compute the percent steps */
    mcview_search_update_steps (view);

    view->update_activate = search_start;

    vsm.first = TRUE;
    vsm.view = view;
    vsm.offset = search_start;

    status_msg_init (STATUS_MSG (&vsm), _("Search"), 1.0, simple_status_msg_init_cb,
                     mcview_search_status_update_cb, NULL);

    do
    {
        off_t growbufsize;

        if (view->growbuf_in_use)
            growbufsize = mcview_growbuf_filesize (view);
        else
            growbufsize = view->search->original_len;

        if (mcview_find (&vsm, search_start, mcview_get_filesize (view), &match_len))
        {
            mcview_search_show_result (view, match_len);
            found = TRUE;
            break;
        }

        if (view->search->error == MC_SEARCH_E_ABORT || view->search->error == MC_SEARCH_E_NOTFOUND)
            break;

        search_start = growbufsize - view->search->original_len;
    }
    while (search_start > 0 && mcview_may_still_grow (view));

    status_msg_deinit (STATUS_MSG (&vsm));

    if (orig_search_start != 0 && (!found && view->search->error == MC_SEARCH_E_NOTFOUND)
        && !mcview_search_options.backwards)
    {
        view->search_start = orig_search_start;
        mcview_update (view);

        if (query_dialog
            (_("Search done"), _("Continue from beginning?"), D_NORMAL, 2, _("&Yes"),
             _("&No")) != 0)
            found = TRUE;
        else
        {
            /* continue search from beginning */
            view->update_activate = 0;

            vsm.first = TRUE;
            vsm.view = view;
            vsm.offset = 0;

            status_msg_init (STATUS_MSG (&vsm), _("Search"), 1.0, simple_status_msg_init_cb,
                             mcview_search_status_update_cb, NULL);

            /* search from file begin up to initial search start position */
            if (mcview_find (&vsm, 0, orig_search_start, &match_len))
            {
                mcview_search_show_result (view, match_len);
                found = TRUE;
            }

            status_msg_deinit (STATUS_MSG (&vsm));
        }
    }

    if (!found)
    {
        view->search_start = orig_search_start;
        mcview_update (view);

        if (view->search->error == MC_SEARCH_E_NOTFOUND)
            query_dialog (_("Search"), _(STR_E_NOTFOUND), D_NORMAL, 1, _("&Dismiss"));
        else if (view->search->error_str != NULL)
            query_dialog (_("Search"), view->search->error_str, D_NORMAL, 1, _("&Dismiss"));
    }
    view->dirty++;
}
示例#7
0
void
mcview_do_search (mcview_t * view)
{
    mcview_search_status_msg_t vsm;

    off_t search_start = 0;
    gboolean isFound = FALSE;
    gboolean need_search_again = TRUE;

    size_t match_len;

    /* for avoid infinite search loop we need to increase or decrease start offset of search */

    if (view->search_start != 0)
    {
        if (!view->text_nroff_mode)
            search_start = view->search_start + (mcview_search_options.backwards ? -2 : 0);
        else
        {
            if (mcview_search_options.backwards)
            {
                mcview_nroff_t *nroff;
                nroff = mcview_nroff_seq_new_num (view, view->search_start);
                if (mcview_nroff_seq_prev (nroff) != -1)
                    search_start =
                        -(mcview__get_nroff_real_len (view, nroff->index - 1, 2) +
                          nroff->char_width + 1);
                else
                    search_start = -2;

                mcview_nroff_seq_free (&nroff);
            }
            else
            {
                search_start = mcview__get_nroff_real_len (view, view->search_start + 1, 2);
            }
            search_start += view->search_start;
        }
    }

    if (mcview_search_options.backwards && (int) search_start < 0)
        search_start = 0;

    /* Compute the percent steps */
    mcview_search_update_steps (view);

    view->update_activate = search_start;

    vsm.first = TRUE;
    vsm.view = view;
    vsm.offset = search_start;

    status_msg_init (STATUS_MSG (&vsm), _("Search"), 1.0, simple_status_msg_init_cb,
                     mcview_search_status_update_cb, NULL);

    do
    {
        off_t growbufsize;

        if (view->growbuf_in_use)
            growbufsize = mcview_growbuf_filesize (view);
        else
            growbufsize = view->search->original_len;

        if (mcview_find (&vsm, search_start, mcview_get_filesize (view), &match_len))
        {
            mcview_search_show_result (view, match_len);
            need_search_again = FALSE;
            isFound = TRUE;
            break;
        }

        if (view->search->error_str == NULL)
            break;

        search_start = growbufsize - view->search->original_len;
        if (search_start <= 0)
        {
            search_start = 0;
            break;
        }
    }
    while (mcview_may_still_grow (view));

    status_msg_deinit (STATUS_MSG (&vsm));

    if (view->search_start != 0 && !isFound && need_search_again
        && !mcview_search_options.backwards)
    {
        int result;

        mcview_update (view);

        result =
            query_dialog (_("Search done"), _("Continue from beginning?"), D_NORMAL, 2, _("&Yes"),
                          _("&No"));

        if (result != 0)
            isFound = TRUE;
        else
            search_start = 0;
    }

    if (!isFound && view->search->error_str != NULL)
    {
        /* continue search form beginning */
        off_t search_end;

        search_end = view->search_start;
        /* search_start is 0 here */
        view->update_activate = search_start;

        vsm.first = TRUE;
        vsm.view = view;
        vsm.offset = search_start;

        status_msg_init (STATUS_MSG (&vsm), _("Search"), 1.0, simple_status_msg_init_cb,
                         mcview_search_status_update_cb, NULL);

        if (mcview_find (&vsm, search_start, search_end, &match_len))
        {
            mcview_search_show_result (view, match_len);
            isFound = TRUE;
        }

        status_msg_deinit (STATUS_MSG (&vsm));
    }

    if (!isFound && view->search->error_str != NULL)
        query_dialog (_("Search"), view->search->error_str, D_NORMAL, 1, _("&Dismiss"));

    view->dirty++;
}