コード例 #1
0
ファイル: right_click_menu.c プロジェクト: 2742195759/egui
si_t shortcut_delete(struct shortcut* sh_ptr){
	int number = vector_find(&sh_desktop_vector, sh_ptr, link_file_cmp);
	if(number>=0){
		object_remove(OBJECT_POINTER(sh_ptr));
		//object_delete(OBJECT_POINTER(sh_ptr),_widget_destructor);
		//vector_erase(&sh_desktop_vector,number);
		//位置清除
		flag_pptr[sh_ptr->position_x][sh_ptr->position_y]=0;
		app_number--;
		
		pid_t pid;
		if((pid = fork()) == 0)
    	{
    		if(strcmp(sh_ptr->app_name,"file_browser")==0 && sh_ptr->is_real==1){
        		//execl("/bin/rm", "rm",sh_ptr->link_file_path, NULL);
				//exit(0);
				//delete_file(sh_ptr->link_file_path);
				//rmdir(sh_ptr->link_file_path);
				//exit(0);
			}
        	else if(sh_ptr->is_real==1)
           	 	execl("/bin/rm", "rm", sh_ptr->link_file_path, NULL);
        }
		
	}
	return 0;
}
コード例 #2
0
ファイル: main.c プロジェクト: atrinik/atrinik
/**
 * All this really is is a glorified object_removeject that also updates the
 * counts on the map if needed and sets map timeout if needed.
 * @param op
 * The object leaving the map.
 */
void leave_map(object *op)
{
    object_remove(op, 0);

    if (!op->map->player_first) {
        set_map_timeout(op->map);
    }

    op->map = NULL;
    CONTR(op)->last_update = NULL;
}
コード例 #3
0
ファイル: item.c プロジェクト: atrinik/atrinik
/**
 * Remove all items in object's inventory.
 * @param op
 * The object to remove inventory of.
 */
void object_remove_inventory(object *op)
{
    if (!op) {
        return;
    }

    if (op == cpl.sack) {
        cpl.sack = NULL;
    }

    object_redraw(op);

    for (object *tmp = op->inv, *next; tmp != NULL; tmp = next) {
        next = tmp->next;

        if (tmp == cpl.sack) {
            continue;
        }

        object_remove(tmp);
    }
}
コード例 #4
0
ファイル: main.c プロジェクト: atrinik/atrinik
/**
 * Swap one apartment (unique) map for another.
 * @param mapold
 * Old map path.
 * @param mapnew
 * Map to switch for.
 * @param x
 * X position where player's items from old map will go to.
 * @param y
 * Y position where player's items from old map will go to.
 * @param op
 * Player we're doing the switching for.
 * @return
 * 1 on success, 0 on failure.
 */
int swap_apartments(const char *mapold, const char *mapnew, int x, int y, object *op)
{
    char *cleanpath, *path;
    int i, j;
    object *ob, *tmp, *tmp2;
    mapstruct *oldmap, *newmap;

    /* So we can transfer our items from the old apartment. */
    cleanpath = estrdup(mapold);
    string_replace_char(cleanpath, "/", '$');
    path = player_make_path(op->name, cleanpath);
    oldmap = ready_map_name(path, NULL, MAP_PLAYER_UNIQUE);
    efree(path);
    efree(cleanpath);

    if (!oldmap) {
        LOG(BUG, "Could not get oldmap using ready_map_name().");
        return 0;
    }

    /* Our new map. */
    cleanpath = estrdup(mapnew);
    string_replace_char(cleanpath, "/", '$');
    path = player_make_path(op->name, cleanpath);
    newmap = ready_map_name(path, NULL, MAP_PLAYER_UNIQUE);
    efree(path);
    efree(cleanpath);

    if (!newmap) {
        LOG(BUG, "Could not get newmap using ready_map_name().");
        return 0;
    }

    /* Go through every square on old apartment map, looking for things
     * to transfer. */
    for (i = 0; i < MAP_WIDTH(oldmap); i++) {
        for (j = 0; j < MAP_HEIGHT(oldmap); j++) {
            for (ob = GET_MAP_OB(oldmap, i, j); ob; ob = tmp2) {
                tmp2 = ob->above;

                /* We teleport any possible players here to emergency map. */
                if (ob->type == PLAYER) {
                    object_enter_map(ob, NULL, NULL, 0, 0, false);
                    continue;
                }

                /* If it's sys_object 1, there's no need to transfer it. */
                if (QUERY_FLAG(ob, FLAG_SYS_OBJECT)) {
                    continue;
                }

                /* A pickable item... Tranfer it */
                if (!QUERY_FLAG(ob, FLAG_NO_PICK)) {
                    object_remove(ob, 0);
                    ob->x = x;
                    ob->y = y;
                    object_insert_map(ob, newmap, NULL, INS_NO_MERGE | INS_NO_WALK_ON);
                } else {
                    /* Fixed part of map */

                    /* Now we test for containers, because player
                     * can have items stored in it. So, go through
                     * the container and look for things to transfer. */
                    for (tmp = ob->inv; tmp; tmp = tmp2) {
                        tmp2 = tmp->below;

                        if (QUERY_FLAG(tmp, FLAG_SYS_OBJECT) || QUERY_FLAG(tmp, FLAG_NO_PICK)) {
                            continue;
                        }

                        object_remove(tmp, 0);
                        tmp->x = x;
                        tmp->y = y;
                        object_insert_map(tmp, newmap, NULL, INS_NO_MERGE | INS_NO_WALK_ON);
                    }
                }
            }
        }
    }

    /* Save the map */
    new_save_map(newmap, 0);

    /* Check for old save bed */
    if (strcmp(oldmap->path, CONTR(op)->savebed_map) == 0) {
        strcpy(CONTR(op)->savebed_map, EMERGENCY_MAPPATH);
        CONTR(op)->bed_x = EMERGENCY_X;
        CONTR(op)->bed_y = EMERGENCY_Y;
    }

    unlink(oldmap->path);

    /* Free the maps */
    free_map(newmap, 1);
    free_map(oldmap, 1);

    return 1;
}