Changeset 01e9991 in mainline for uspace/app/nav/panel.c


Ignore:
Timestamp:
2021-10-25T00:32:45Z (3 years ago)
Author:
jxsvoboda <5887334+jxsvoboda@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
97c3c59
Parents:
7aeb52cb
git-author:
Jiri Svoboda <jiri@…> (2021-10-16 23:08:02)
git-committer:
jxsvoboda <5887334+jxsvoboda@…> (2021-10-25 00:32:45)
Message:

Executing binaries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/nav/panel.c

    r7aeb52cb r01e9991  
    4141#include <stdlib.h>
    4242#include <str.h>
     43#include <task.h>
    4344#include <ui/control.h>
    4445#include <ui/paint.h>
     
    953954errno_t panel_open(panel_t *panel, panel_entry_t *entry)
    954955{
     956        if (entry->isdir)
     957                return panel_open_dir(panel, entry);
     958        else if (entry->svc == 0)
     959                return panel_open_file(panel, entry);
     960        else
     961                return EOK;
     962}
     963
     964/** Open panel directory entry.
     965 *
     966 * Perform Open action on a directory entry (i.e. switch to the directory).
     967 *
     968 * @param panel Panel
     969 * @param entry Panel entry (which is a directory)
     970 *
     971 * @return EOK on success or an error code
     972 */
     973errno_t panel_open_dir(panel_t *panel, panel_entry_t *entry)
     974{
    955975        gfx_context_t *gc = ui_window_get_gc(panel->window);
    956         char *dirname;
    957976        errno_t rc;
    958977
    959         if (!entry->isdir)
    960                 return EOK;
    961 
    962         dirname = str_dup(entry->name);
     978        assert(entry->isdir);
     979
    963980        panel_clear_entries(panel);
    964981
    965         rc = panel_read_dir(panel, dirname);
    966         if (rc != EOK) {
    967                 free(dirname);
    968                 return rc;
    969         }
     982        rc = panel_read_dir(panel, entry->name);
     983        if (rc != EOK)
     984                return rc;
    970985
    971986        rc = panel_paint(panel);
    972         if (rc != EOK) {
    973                 free(dirname);
    974                 return rc;
    975         }
    976 
    977         free(dirname);
     987        if (rc != EOK)
     988                return rc;
     989
    978990        return gfx_update(gc);
    979991}
    980992
     993/** Open panel file entry.
     994 *
     995 * Perform Open action on a file entry (i.e. try running it).
     996 *
     997 * @param panel Panel
     998 * @param entry Panel entry (which is a file)
     999 *
     1000 * @return EOK on success or an error code
     1001 */
     1002errno_t panel_open_file(panel_t *panel, panel_entry_t *entry)
     1003{
     1004        task_id_t id;
     1005        task_wait_t wait;
     1006        task_exit_t texit;
     1007        int retval;
     1008        errno_t rc;
     1009
     1010        /* It's not a directory */
     1011        assert(!entry->isdir);
     1012        /* It's not a service-special file */
     1013        assert(entry->svc == 0);
     1014
     1015        rc = task_spawnl(&id, &wait, entry->name, entry->name, NULL);
     1016        if (rc != EOK)
     1017                return rc;
     1018
     1019        rc = task_wait(&wait, &texit, &retval);
     1020        if ((rc != EOK) || (texit != TASK_EXIT_NORMAL))
     1021                return rc;
     1022
     1023        (void) ui_paint(ui_window_get_ui(panel->window));
     1024        return EOK;
     1025}
     1026
    9811027/** @}
    9821028 */
Note: See TracChangeset for help on using the changeset viewer.