Exemplo n.º 1
0
Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flags) {
	List<String> dirs;

	String curdir = get_current_dir();
	list_dir_begin();
	String n = get_next();
	while (n != String()) {

		if (n != "." && n != "..") {

			if (current_is_dir())
				dirs.push_back(n);
			else {
				String rel_path = n;
				if (!n.is_rel_path()) {
					list_dir_end();
					return ERR_BUG;
				}
				Error err = copy(get_current_dir() + "/" + n, p_to + rel_path, p_chmod_flags);
				if (err) {
					list_dir_end();
					return err;
				}
			}
		}

		n = get_next();
	}

	list_dir_end();

	for (List<String>::Element *E = dirs.front(); E; E = E->next()) {
		String rel_path = E->get();
		String target_dir = p_to + rel_path;
		if (!p_target_da->dir_exists(target_dir)) {
			Error err = p_target_da->make_dir(target_dir);
			ERR_FAIL_COND_V(err, err);
		}

		Error err = change_dir(E->get());
		ERR_FAIL_COND_V(err, err);
		err = _copy_dir(p_target_da, p_to + rel_path + "/", p_chmod_flags);
		if (err) {
			change_dir("..");
			ERR_PRINT("Failed to copy recursively");
			return err;
		}
		err = change_dir("..");
		if (err) {
			ERR_PRINT("Failed to go back");
			return err;
		}
	}

	return OK;
}
Exemplo n.º 2
0
static void
show_hide_file_view_cb(GtkWidget *widget, GdkEventButton *event, FileView *view)
{
  if (event->button == 1)
  {
    toggle_panel_size(view);
  }
  else if (event->button == 3)
  {
    if (view != curr_view)
      change_dir(curr_view, view->dir);
    else
      change_dir(other_view, view->dir);
  }
}
Exemplo n.º 3
0
void download_folder(char* file_name, char* local_path, char* remote_path, unsigned long IPaddr, int PN)
{
	char local_temp[1024], remote_temp[1024];
	char* msg = 0, * resp_msg = 0, *err_msg_string = 0;
	uint64_t msg_len;
	uint32_t num_metas;
	int i;
	basic_meta_t *basic_metas = 0;
	ErrorCode error;
	struct Node* resp;
    	strcpy(local_temp, local_path);
    	strcpy(remote_temp, remote_path);
    	make_dir(file_name, 0, local_path, IPaddr, PN);
    	change_dir(file_name, local_temp, 0, IPaddr, PN);
    	change_dir(file_name, remote_temp, 1, IPaddr, PN);

	create_msg_get_folder_meta_request(remote_temp, &msg, &msg_len);
	error = mysend(msg, IPaddr, PN, msg_len);
	free(msg);
	if(error == FAILURE || error == RETRY)
	{	printf("error in send\n");
		return;
	}
	resp = myrecv(CLIENT_PORT);
	resp_msg = resp->message;
	if(get_header_type(resp_msg) == BACS_ERROR)
	{
      		parse_msg_error(resp_msg, &err_msg_string);
		printf("%s",err_msg_string);
		free(resp->message);
		free(resp);
		free(err_msg_string);
		return;
	}
	parse_msg_get_folder_meta_response(resp_msg, &basic_metas, &num_metas);
	free(resp->message);
	free(resp);
	free(err_msg_string);
	for(i=0; i < num_metas; i++)
	{
		if(strcmp(basic_metas[i].name,".")!=0 && strcmp(basic_metas[i].name,"..")!=0)
			download_file(basic_metas[i].name, local_temp, remote_temp, IPaddr, PN);
		//free(basic_metas[i].name);
	}
	free(basic_metas);
 	/*download file complete*/
    	printf("Directory downloaded to path: %s\n",local_path);
}
Exemplo n.º 4
0
static void
goto_bookmark (GtkWidget * menu_item, gchar *value)
{
	GList *tmp;
	gint i;
	gchar *file;

	for(tmp = cfg.bookmarks; tmp != NULL; tmp = tmp->next)
	{
		Bookmarks *bk = tmp->data;
		if(!strcmp(value, bk->mark))
		{
			change_dir(curr_view, bk->dir);
			gtk_clist_freeze(GTK_CLIST(curr_view->clist));
			for(i = 0; i < GTK_CLIST(curr_view->clist)->rows; i++)
			{
				gtk_clist_get_text(GTK_CLIST(curr_view->clist), i, 0, &file);

				if(!strcmp(bk->file, file))
				{
					focus_on_row(curr_view, i);
					gtk_clist_thaw(GTK_CLIST(curr_view->clist));
					return;
				}
			}
			focus_on_row(curr_view, 0);
			gtk_clist_thaw(GTK_CLIST(curr_view->clist));
			return;
		}
	}
	status_bar_message("Mark not found");
	return;
}
Exemplo n.º 5
0
void handle_record_mode(FILINFO* pfile_info) {
  const char* ppitems[] = {S_REC_MODE_MANUAL, S_REC_MODE_AUTO};
  uint8_t cur_mode = 0;

  lcd_title_P(S_SELECT_RECORD_MODE);

  // attempt to open the recording dir
  strcpy_P((char*)g_fat_buffer, S_DEFAULT_RECORD_DIR);
  // change to the recording dir
  if (change_dir((char*)g_fat_buffer) != FR_OK) {
    lcd_status_P(S_CHDIR_FAILED);
    lcd_busy_spinner();
    return;
  }
  
  while (1) {
    cur_mode = handle_select_mode(S_SELECT_RECORD_MODE, ppitems, 2, cur_mode);
    switch (cur_mode) {
      case REC_MODE_AUTO:
        handle_record_mode_ready(NULL);
        return;
      break;
      case REC_MODE_MANUAL:
        if (handle_manual_filename(pfile_info)) {
          handle_record_mode_ready(pfile_info->lfname);
          return;
        }
      break;
      case SELECT_MODE_EXIT:
        return;
      break;
    }
  }
}
Exemplo n.º 6
0
static gint mh_scan_tree(Folder *folder)
{
	FolderItem *item;
	gchar *rootpath;

	cm_return_val_if_fail(folder != NULL, -1);

	if (!folder->node) {
		item = folder_item_new(folder, folder->name, NULL);
		item->folder = folder;
		folder->node = item->node = g_node_new(item);
	} else
		item = FOLDER_ITEM(folder->node->data);

	rootpath = folder_item_get_path(item);
	if (change_dir(rootpath) < 0) {
		g_free(rootpath);
		return -1;
	}
	g_free(rootpath);

	mh_create_tree(folder);
	mh_remove_missing_folder_items(folder);
	mh_scan_tree_recursive(item);

	return 0;
}
Exemplo n.º 7
0
void FileList::change_dir( QTreeWidgetItem * item, int column )
{
  qDebug("in DirTreeView::change_dir");

  FileListWidgetItem *fi = dynamic_cast<FileListWidgetItem*>(item);
  //FileListWidgetItem *fi = (FileListWidgetItem*)(item);
  if (fi==0)
  {
    qDebug("fi==0");
    return;
  } 
  QString cd_dir;	


  //QString select_fn = fi->text(0);

  if (cur_dir_ == "") // in win32, this mean current is list all drives
  {
    cd_dir =  fi->get_real_str() + QDIR_SEPARATOR;
  }
  else
  {
    cd_dir =  cur_dir_ + QDIR_SEPARATOR + fi->get_real_str();
  }

  //change_dir(cd_dir);
  change_dir(cd_dir.toStdString().c_str() );
  //change_dir("c:\\");

  //change_dir(const QString &cd_dir)
}
Exemplo n.º 8
0
void print_spiral(Matr *matr,int n,int m)
{
	int c=1,i=0,j=0,i1,j1;
	print(matr[j+i*m].num);
	matr[j+i*m].dir=RIGHT;
	matr[j+i*m].ctrl = 1;
	j++;
	Matr *current = &matr[j+i*m];
	direction past = matr[j-1+i*m].dir;
	while(c < n*m){
		print(current->num);
		current->ctrl = 1;
		current->dir = past;
		i1=i;
		j1=j;
		next(current->dir,&i1,&j1);
		if(i1 == n || i1 == -1 || j1 == m || j1 == -1 || 
			matr[j1+i1*m].ctrl == 1){
			current->dir = change_dir(matr,i,j,m,n);
			next(current->dir,&i,&j);
			past = current->dir;
			current = &matr[j+i*m];
		}
		else{
			i=i1;j=j1;
			past = current->dir;			
			current = &matr[j+i*m];
		}
		c++;
	}
	printf("\n");
}
Exemplo n.º 9
0
/* on the file list, that is */
static void handle_enter_key(void)
{
	dmoz_file_t *file;
	int cur = instrument_get_current();

	if (current_file < 0 || current_file >= flist.num_files) return;
	file = flist.files[current_file];
	dmoz_cache_update(inst_cwd, &flist, NULL);

	if (file->type & TYPE_BROWSABLE_MASK) {
		change_dir(file->path);
		status.flags |= NEED_UPDATE;
	} else if (file->type & TYPE_INST_MASK) {
		if (_library_mode) return;
		status.flags |= SONG_NEEDS_SAVE;
		if (file->instnum > -1) {
			song_load_instrument_ex(cur, NULL,
					file->path, file->instnum);
		} else {
			song_load_instrument(cur, file->path);
		}
		if (!song_is_instrument_mode()) {
			dialog_create(DIALOG_YES_NO,
				"Enable instrument mode?",
				do_enable_inst, dont_enable_inst, 0, NULL);
		} else {
			set_page(PAGE_INSTRUMENT_LIST);
		}
		memused_songchanged();
	}

	/* TODO */
}
Exemplo n.º 10
0
void handle_events(int evfd)
{
	struct input_event ev[64];
	int i, rd;

	rd = read(evfd, ev, sizeof(struct input_event) * 64);
	if (rd < (int) sizeof(struct input_event)) {
		fprintf(stderr, "expected %d bytes, got %d\n",
		        (int) sizeof(struct input_event), rd);
		return;
	}
	for (i = 0; i < rd / sizeof(struct input_event); i++) {
		if (ev->type != EV_KEY)
			continue;
		if (ev->value != 1)
			continue;
		switch (ev->code) {
			case KEY_ENTER:
				running = 0;
				break;
			default:
				change_dir(ev->code);
		}
	}
}
Exemplo n.º 11
0
//matches a command executes it,
//returns whether the shell should continue running.
bool match_command(struct CommandBuffer * cb,char ** cwd,const char ** path){
    bool res = true;
    if(strcmp(cb->command_buffer,"exit") == 0){
        res = false;
    }else{
        char ** buff = parse_command(cb->command_buffer);
        if(strcmp(buff[0],"cd") == 0){
            change_dir(buff[0],cwd);
        }else{
            bool found_pipe = false;
            size_t pos = 0;
            while(buff[pos]){
                if(strcmp(buff[pos],"|") == 0){
                    found_pipe = true;
                    buff[pos] = NULL;
                    break;
                }
                ++pos;
            }
            if(found_pipe){
                res = execute_pipe(path,buff[0],&buff[0],buff[pos+1],&buff[pos+1]);
            }else{
                res = execute(path,buff[0],&buff[0]);
            }
        }
        free(buff);
    }
    return res;
}
Exemplo n.º 12
0
Arquivo: main.c Projeto: S010/misc
void
handle_path_entered(GtkWidget *widget, gchar *text, gpointer unused) {
    const gchar *path;

    path = gtk_entry_get_text(GTK_ENTRY(widget));
    change_dir(path);
}
Exemplo n.º 13
0
void Ozette::edit_file(std::string path) {
	struct stat st;
	if (0 == stat(path.c_str(), &st) && S_ISDIR(st.st_mode)) {
		change_dir(path);
	} else {
		open_editor(path);
	}
}
Exemplo n.º 14
0
rethink_settings()
{
attatch_tools();
attatch_dm();
clip_rmove_menu(cur_menu, 0, vs.rmyoff-cur_menu->y);
change_dir(vs.drawer);
check_cel_options();
}
Exemplo n.º 15
0
static Errcode po_set_dir(Popot dir)
/*****************************************************************************
 * ErrCode SetDir(char *dir);
 ****************************************************************************/
{
if (dir.pt == NULL)
	return( builtin_err = Err_null_ref );
return(change_dir(dir.pt));
}
Exemplo n.º 16
0
Arquivo: main.c Projeto: S010/misc
void
handle_up_clicked(GtkWidget *widget, gpointer unused) {
    char buf[PATH_MAX];

    if (current_fsnode) {
        snprintf(buf, sizeof buf, "%s/..", current_fsnode->path);
        change_dir(buf);
    }
}
Exemplo n.º 17
0
static int
new_bdrawer(void)
{
    if (!change_dir(vs.drawer))
        return(0);
    init_bscroller();
    draw_sel(&bro_pat_sel);
    redraw_bscroller();
    return(1);
}
Exemplo n.º 18
0
int handle_builtin(char **argv)
{
  if(strcmp(argv[0], "cd") == 0)
  {
    if(argv[1])
      change_dir(argv[1]);
    return 0;
  }
  return 1;
}
Exemplo n.º 19
0
void xml_base_resource::handle_child_end(string element_name){

	if(element_name == "chdir"){
		change_dir(dir_path);
	}else if(element_name == "input"){
		if(input_path != "" ){
			xml_core->load(get_dir() +input_path);
		}
	}
}
Exemplo n.º 20
0
int		cd_to_env_var(char *var) {
  char		*path;

  if ((path = sh_getenv(var)) != NULL) {
    return change_dir(path);
  }
  else
    shell_warn("cd: %s not set.\n", var);
  return -1;
}
Exemplo n.º 21
0
void read_args(int argc, char* argv[]) {
	for (int i = 1; i < argc; i++) {
		if (strcmp(argv[i], "-l") == 0) 
			l = 1;
		else if (strcmp(argv[i], "-r") == 0)
			r = 1;
		else if (change_dir(argv[i]) < 0) 
			_exit(1);
	}
}
Exemplo n.º 22
0
void change_dir(char *argm)
{
	char current[MAX],final[MAX],temp[MAX];
	getcwd(current,sizeof(current));
	if(!strcmp(argm,"."))
		return;
	else if( (!strcmp(argm,"..")) && !strcmp(current,"/"))
		return;
	else if(!strcmp(argm,"/"))
		chdir("/");
	else if(!strcmp(argm,".."))
	{
		int len = strlen(current),i;
		for(i=len-1;i>=0;i--)
			if(current[i]=='/')
				break;
		current[i] = '\0';
		if(i==0)
			strcpy(current,"/");
		chdir(current);
	}
	else
	{
		if(argm[0] != '/' || argm[0] != '.')
		{
			strcat(current,"/");
			strcat(current,argm);
			chdir(current);
		}
		else if(argm[0] == '/')
			chdir(argm);
		else
		{
			int len = strlen(current),i;
			for(i=0;i<len;i++)
				if(current[i]=='/')
					break;
			change_dir(strndup(current,i));
			change_dir(&current[i]);
		}
	}
}
Exemplo n.º 23
0
/*
 * FILEVIEW CALLBACKS
 */
static void
updir_click_cb(GtkWidget *widget, GdkEventButton *event, FileView *view)
{
  if (event->button == 1)
  {
    gchar path[PATH_MAX];
    g_snprintf(path, sizeof(path), "%s/..", view->dir);
    change_dir(view, path);
  }
  else if (event->button == 3)
  {
    gchar *home;
    if ((home = getenv("HOME")) != NULL)
      change_dir(view, home);
    else
      status_message(_("Environment variable 'HOME' not set."));
  }
  gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), "button_press_event");
  focus_row(view, view->row, TRUE, TRUE, TRUE);
}
Exemplo n.º 24
0
void FileList::list_first_layer_dir()
{
  QFileInfoList file_info_list;


  if (cur_dir_=="") // win 
  {
    file_info_list=QDir::drives();
    change_dir(file_info_list);
  }
  if (cur_dir_==QDIR_SEPARATOR) // unix 
  {
    QDir root_dir=QDir::root();
    root_dir.setFilter(QDir::AllEntries | QDir::AllDirs| QDir::System | QDir::Hidden);
    file_info_list = root_dir.entryInfoList();
    change_dir(cur_dir_.toStdString().c_str());
  }


}
Exemplo n.º 25
0
static Errcode clear_vtemps(Boolean reset)
{
	if (reset)
		{
		pj_delete(optics_name); /* get rid of optics moves */
		pj_delete(ppoly_name);	/* and optics path */
		}
	pj_delete(tflxname);	  /* and old tempflx */
	change_dir(vb.init_drawer);  /* go back to startup-dir */
	return(Success);
}
Exemplo n.º 26
0
static int			cd_home(void)
{
	char				*path;
	int					ret;

	if ((path = get_env("HOME")) == NULL)
		return (sh_error(FALSE, 13, NULL, NULL));
	ret = change_dir(path);
	ft_strdel(&path);
	return (ret);
}
Exemplo n.º 27
0
void Ozette::change_directory() {
	Dialog::Form dialog;
	dialog.fields = {
		{"Change Directory", Path::display(_current_dir), &Path::complete_dir}
	};
	dialog.commit = [this](UI::Frame &ctx, Dialog::Form::Result &res) {
		std::string path = res.selected_value;
		if (path.empty()) return;
		change_dir(path);
	};
	dialog.show(*_shell.active());
}
Exemplo n.º 28
0
long c_caller(long number, void *arg)  // exten c function switches on number
{
  switch (number)
  {
    case 0 : 
    {
      char cd[100];
      getcwd(cd,100);
      int t=change_dir(lstring_value(CAR(arg)));
      change_dir(cd);
      return t;
    } break;    
    case 1 :
    {
      if (change_dir(lstring_value(eval(CAR(arg)))))
        return 1;
      else return 0;
    } break; 
    case 2 :
    {
      return K_avail(lstring_value(CAR(arg)));
    } break;
    case 3 :
    {
      void *title=eval(CAR(arg)); arg=CDR(arg);   p_ref r1(title);
      void *source=eval(CAR(arg)); arg=CDR(arg);  p_ref r2(source);
      void *dest=eval(CAR(arg)); arg=CDR(arg);    p_ref r3(dest);

      return nice_copy(lstring_value(title),lstring_value(source),lstring_value(dest));
    } break;
    case 4 :
    {
      if (access(lstring_value(eval(CAR(arg))),R_OK)==0)
        return 1;
      else
        return 0;
    } break;
  }
  return 0;
}
Exemplo n.º 29
0
int ls(char* name, int depth) {
	struct stat stbuf;
	if (change_dir(name) < 0) 
		return 0;
	DIR *dir = opendir("./");
	if (dir == NULL) {
		perror(name);
		return 0;
	}
	struct dirent *curr_dir;
	while ((curr_dir = readdir(dir)) != NULL) {
		if (stat(curr_dir->d_name, &stbuf) == -1)
			fprintf(stderr, "fsize: can't access %s\n", name);
		print(curr_dir, &stbuf, depth);
		if (r == 1 && S_ISDIR(stbuf.st_mode) && depth < Max_Depth && curr_dir->d_name[0] != '.')
			if (ls(curr_dir->d_name, depth + 1) == 1)
				if (change_dir("./../") < 0)
					return 0;
	}
	closedir(dir);
	return 1;
}
Exemplo n.º 30
0
int		builtin_cd(char **argv) {

  if (argv[1] == NULL) {
    return cd_to_env_var("HOME");
  }
  if (argv[2] != NULL) {
    shell_warn("cd: Too many arguments.\n");
    return -1;
  }
  if (strcmp("-", argv[1]) == 0)
    return cd_to_env_var("OLDPWD");
  return change_dir(argv[1]);
}