Example #1
0
int do_move(const char *filename,uint64_t lv,uint32_t ts,char *ptr) {
	uint32_t inode,parent_src,parent_dst;
	uint8_t name_src[256],name_dst[256];
	EAT(ptr,filename,lv,'(');
	GETU32(parent_src,ptr);
	EAT(ptr,filename,lv,',');
	GETNAME(name_src,ptr,filename,lv,',');
	EAT(ptr,filename,lv,',');
	GETU32(parent_dst,ptr);
	EAT(ptr,filename,lv,',');
	GETNAME(name_dst,ptr,filename,lv,')');
	EAT(ptr,filename,lv,')');
	EAT(ptr,filename,lv,':');
	GETU32(inode,ptr);
	return fs_move(ts,parent_src,strlen((char*)name_src),name_src,parent_dst,strlen((char*)name_dst),name_dst,inode);
}
Example #2
0
/*
 * Moves source file path to destination
 *
 * req: TLV_TYPE_FILE_PATH - The file path to expand
 */
DWORD request_fs_file_move(Remote *remote, Packet *packet)
{
	Packet *response = packet_create_response(packet);
	DWORD result = ERROR_SUCCESS;
	char *oldpath;
	char *newpath;

	oldpath = packet_get_tlv_value_string(packet, TLV_TYPE_FILE_NAME);
	newpath = packet_get_tlv_value_string(packet, TLV_TYPE_FILE_PATH);

	if (!oldpath) {
		result = ERROR_INVALID_PARAMETER;
	} else {
		result = fs_move(oldpath, newpath);
	}

	return packet_transmit_response(result, remote, response);
}
Example #3
0
/*
 * Copies source file path to destination
 *
 * req: TLV_TYPE_FILE_PATH - The file path to expand
 */
DWORD request_fs_file_move(Remote *remote, Packet *packet)
{
	Packet *response = packet_create_response(packet);
	DWORD result = ERROR_SUCCESS;
	char *oldpath;
	char *newpath;

	oldpath = packet_get_tlv_value_string(packet, TLV_TYPE_FILE_NAME);
	newpath = packet_get_tlv_value_string(packet, TLV_TYPE_FILE_PATH);

	if (!oldpath) {
		result = ERROR_INVALID_PARAMETER;
	} else {
		result = fs_move(oldpath, newpath);
	}

	packet_add_tlv_uint(response, TLV_TYPE_RESULT, result);
	return PACKET_TRANSMIT(remote, response, NULL);
}
Example #4
0
static int update_op(struct update_context *uc)
{
    fs_rid_vector *vec[4];
    switch (uc->op->type) {
    case RASQAL_UPDATE_TYPE_UNKNOWN:
        add_message(uc, "Unknown update operation", 0);
        return 1;
    case RASQAL_UPDATE_TYPE_CLEAR:
        fs_clear(uc, graph_arg(uc->op->graph_uri));
        return 0;
    case RASQAL_UPDATE_TYPE_CREATE:
        return 0;
    case RASQAL_UPDATE_TYPE_DROP:
        fs_clear(uc, graph_arg(uc->op->graph_uri));
        return 0;
    case RASQAL_UPDATE_TYPE_LOAD:
        fs_load(uc, graph_arg(uc->op->document_uri),
                    graph_arg(uc->op->graph_uri));
        return 0;
#if RASQAL_VERSION >= 924
    case RASQAL_UPDATE_TYPE_ADD:
        fs_add(uc, graph_arg(uc->op->graph_uri),
                   graph_arg(uc->op->document_uri));
        return 0;
    case RASQAL_UPDATE_TYPE_MOVE:
        fs_move(uc, graph_arg(uc->op->graph_uri),
                    graph_arg(uc->op->document_uri));
        return 0;
    case RASQAL_UPDATE_TYPE_COPY:
        fs_copy(uc, graph_arg(uc->op->graph_uri),
                    graph_arg(uc->op->document_uri));
        return 0;
#endif
    case RASQAL_UPDATE_TYPE_UPDATE:
        break;
    }

    fs_hash_freshen();

    raptor_sequence *todel = NULL;
    raptor_sequence *toins = NULL;

    if (uc->op->delete_templates && !uc->op->where) {
        int where = 0;

        /* check to see if it's a DELETE WHERE { } */
        for (int t=0; t<raptor_sequence_size(uc->op->delete_templates); t++) {
            rasqal_triple *tr = raptor_sequence_get_at(uc->op->delete_templates, t);
            if (any_vars(tr)) {
                where = 1;
                break;
            }
        }
        if (where) {
            fs_error(LOG_ERR, "DELETE WHERE { x } not yet supported");
            add_message(uc, "DELETE WHERE { x } not yet supported, use DELETE { x } WHERE { x }", 0);

            return 1;
        }
    }

#if RASQAL_VERSION >= 923
    if (uc->op->where) {
        todel = raptor_new_sequence(NULL, NULL);
        toins = raptor_new_sequence(NULL, NULL);
        raptor_sequence *todel_p = raptor_new_sequence(NULL, NULL);
        raptor_sequence *toins_p = raptor_new_sequence(NULL, NULL);
        raptor_sequence *vars = raptor_new_sequence(NULL, NULL);

        fs_query *q = calloc(1, sizeof(fs_query));
        uc->q = q;
        q->qs = uc->qs;
        q->rq = uc->rq;
        q->flags = FS_BIND_DISTINCT;
#ifdef DEBUG_MERGE
        q->flags |= FS_QUERY_CONSOLE_OUTPUT;
#endif
        q->boolean = 1;
        q->opt_level = 3;
        q->soft_limit = -1;
        q->segments = fsp_link_segments(uc->link);
        q->link = uc->link;
        q->bb[0] = fs_binding_new();
        q->bt = q->bb[0];

        /* hashtable to hold runtime created resources */
        q->tmp_resources = g_hash_table_new_full(fs_rid_hash, fs_rid_equal, g_free, fs_free_cached_resource);

        /* add column to denote join ordering */
        fs_binding_create(q->bb[0], "_ord", FS_RID_NULL, 0);

        if (uc->op->delete_templates) {
            for (int t=0; t<raptor_sequence_size(uc->op->delete_templates); t++) {
                rasqal_triple *tr = raptor_sequence_get_at(uc->op->delete_templates, t);
                if (any_vars(tr)) {
                    fs_check_cons_slot(q, vars, tr->subject);
                    fs_check_cons_slot(q, vars, tr->predicate);
                    fs_check_cons_slot(q, vars, tr->object);
                    raptor_sequence_push(todel_p, tr);
                } else {
                    raptor_sequence_push(todel, tr);
                }
            }
        }

        if (uc->op->insert_templates) {
            for (int t=0; t<raptor_sequence_size(uc->op->insert_templates); t++) {
                rasqal_triple *tr = raptor_sequence_get_at(uc->op->insert_templates, t);
                if (any_vars(tr)) {
                    fs_check_cons_slot(q, vars, tr->subject);
                    fs_check_cons_slot(q, vars, tr->predicate);
                    fs_check_cons_slot(q, vars, tr->object);
                    raptor_sequence_push(toins_p, tr);
                } else {
                    raptor_sequence_push(toins, tr);
                }
            }
        }

        q->num_vars = raptor_sequence_size(vars);

        for (int i=0; i < q->num_vars; i++) {
            rasqal_variable *v = raptor_sequence_get_at(vars, i);
            fs_binding_add(q->bb[0], v, FS_RID_NULL, 1);
        }

        /* perform the WHERE match */
        fs_query_process_pattern(q, uc->op->where, vars);

        q->length = fs_binding_length(q->bb[0]);

        for (int s=0; s<4; s++) {
            vec[s] = fs_rid_vector_new(0);
        }
        for (int t=0; t<raptor_sequence_size(todel_p); t++) {
            rasqal_triple *triple = raptor_sequence_get_at(todel_p, t);
            for (int row=0; row < q->length; row++) {
                delete_rasqal_triple(uc, vec, triple, row);
            }
            if (fs_rid_vector_length(vec[0]) > 1000) {
                fsp_delete_quads_all(uc->link, vec);
            }
        }
        if (fs_rid_vector_length(vec[0]) > 0) {
            fsp_delete_quads_all(uc->link, vec);
        }
        for (int s=0; s<4; s++) {
//fs_rid_vector_print(vec[s], 0, stdout);
            fs_rid_vector_free(vec[s]);
            vec[s] = NULL;
        }

        for (int t=0; t<raptor_sequence_size(toins_p); t++) {
            rasqal_triple *triple = raptor_sequence_get_at(toins_p, t);
            for (int row=0; row < q->length; row++) {
                insert_rasqal_triple(uc, triple, row);
            }
        }

        /* must not free the rasqal_query */
        q->rq = NULL;
        fs_query_free(q);
        uc->q = NULL;
    } else {
        todel = uc->op->delete_templates;
        toins = uc->op->insert_templates;
    }
#else
    if (uc->op->where) {
        fs_error(LOG_ERR, "DELETE/INSERT WHERE requires Rasqal 0.9.23 or newer");
        add_message(uc, "DELETE/INSERT WHERE requires Rasqal 0.9.23 or newer", 0);
    }
#endif

    /* delete constant triples */
    if (todel) {
        for (int s=0; s<4; s++) {
            vec[s] = fs_rid_vector_new(0);
        }
        for (int t=0; t<raptor_sequence_size(todel); t++) {
            rasqal_triple *triple = raptor_sequence_get_at(todel, t);
            if (any_vars(triple)) {
                continue;
            }
            delete_rasqal_triple(uc, vec, triple, 0);
        }
        if (fs_rid_vector_length(vec[0]) > 0) {
            fsp_delete_quads_all(uc->link, vec);
        }
        for (int s=0; s<4; s++) {
            fs_rid_vector_free(vec[s]);
            vec[s] = NULL;
        }
    }

    /* insert constant triples */
    if (toins) {
        for (int t=0; t<raptor_sequence_size(toins); t++) {
            rasqal_triple *triple = raptor_sequence_get_at(toins, t);
            if (any_vars(triple)) {
                continue;
            }
            insert_rasqal_triple(uc, triple, 0);
        }
    }
    fs_hash_freshen();

    return 0;
}
Example #5
0
char cmd_copymove1(uchar copymode, uchar shiftPressed) {
  char *name;
  char e;
  FileInfo* f;
  char sourceFile[256];
  char mask[11];
  char forMask[11];
  char type;
  uint i;

  if(shiftPressed) {
    // Копируем имя c первой панели (без пути)
    f = getSelNoBack();
    if(!f) return 0; // Файл не выбран, выходим без ошибки
    unpackName(cmdLine, f->fname);
  } else {
    // Копируем путь со второй панели
    i = strlen(panelB.path1);
    if(i >= 254) return ERR_RECV_STRING; // Так как прибавим 2 символа
    cmdLine[0] = '/';
    strcpy(cmdline+1, panelB.path1);
    if(i != 0) strcpy(cmdline+i+1, "/");
  }

  // Позволяем пользователю изменить путь или имя
  if(!inputBox(copymode ? " kopirowatx " : " pereimenowatx/peremestitx ") && cmdline[0]!=0) return 0;

  // Преобразование относительного пути в абсолютный
  if(!absolutePath(cmdline)) return ERR_RECV_STRING;

  // Используется ли маска?
  mask[0] = 0;  
  name = getname(cmdline);
  if(name[0] != 0) {
    // Сохраняем маску
    packName(mask, name);
    // Убираем из пути маску
    dropPathInt(cmdLine, 0);
  } else {
    // Если в ком строке что то есть, а имя не выделено, значит ком строка оканчивается на /.
    // Этот символ надо удалить
    if(cmdline[0] != 0 && name[0] == 0) name[-1] = 0;
  }

  // Ищем первый файл
  type = getFirstSelected(sourceFile);
  if(type == 0) return 0; // Нет выбранных файлов

  for(;;) {
    // Преобразование относительного пути в абсолютный
    if(!absolutePath(sourceFile)) { e = ERR_RECV_STRING; break; }

    // Добавляем имя
    packName(forMask, getname(sourceFile));
    if(mask[0]) applyMask(forMask, mask);
    if(catPathAndUnpack(cmdline, forMask)) return ERR_RECV_STRING;

    // Самого в мебя не копируем и не переименовываем
    if(0!=strcmp(sourceFile, cmdline)) {
      // Выполнение операции
      if(copymode) {
        if(type==2) {
          e = cmd_copyFolder(sourceFile, cmdline);
        } else {
          e = cmd_copyFile(sourceFile, cmdline);
        }
      } else {
        // Простое окно
        drawWindow(" pereimenowanie/pereme}enie ");
        drawWindowText(0, 1, "iz:");
        drawWindowText(4, 1, sourceFile);
        drawWindowText(0, 2, "w:");
        drawWindowText(4, 2, cmdline);
        drawAnyKeyButton();

        // Прерывание
        if(fs_bioskey(1) == KEY_ESC) { e = ERR_USER; break; }

        e = fs_move(sourceFile, cmdline);    
      }

      if(e) break;
    }

    // Убираем из пути имя файла
    dropPathInt(cmdLine, 0);

    // Следующий выбранный файл
    type = getNextSelected(sourceFile);
    if(type == 0) { e=0; break; }
  } // конец цикла

  // При переносе файла надо обновить обе панели
  // А при копировании список файов используется под буфер
  getFiles();
  dupFiles(1);

  return e;
}