Exemple #1
0
void enter_archive(const char *name, struct_panel *panel, int update_config)
{
  char *saved_work_dir=xgetcwd(NULL);
  #ifdef debug_printf
  printf("Entering into '%s'\n", name);
  #endif
  (void)chdir(panel->path); /* Переходим в каталог где лежит архив */
  if (get_archive_list(name, panel->archive_list))
  {
    char *text;
    if(update_config)
    {
      panel->archive_depth++;
      strcpy(panel->archive_stack[panel->archive_depth], name);
      if ( panel == &top_panel )
        write_archive_stack("top_panel.archive_stack", &top_panel);
      else
        write_archive_stack("bottom_panel.archive_stack", &bottom_panel);
      (void)chdir(saved_work_dir); /* Переходим в каталог откуда нас дёрнули */
    }
    update(panel); /* Строим список */
    move_selection("1", panel); /* Переходим на первый же файл в списке, чтобы не прокручивать */
    text=xconcat_path_file(panel->archive_stack[panel->archive_depth],panel->archive_cwd);
    gtk_label_set_text (GTK_LABEL(panel->path_label), text); /* Пишем имя архива с путём в поле снизу */
    free(text);
  }
  free(saved_work_dir);
}
Exemple #2
0
int enter_archive(const char *name, struct_panel *panel, int update_config)
{
  char *saved_work_dir=xgetcwd(NULL);
  TRACE("Entering into '%s'\n", name);
  if (chdir(panel->path) == -1) /* Переходим в каталог где лежит архив */
  {
    char *message;
    asprintf(&message, UNABLE_TO_CHANGE_DIRECTORY_TO, panel->path, strerror(errno));
    Message(ERROR, message);
    free (message);
    return FALSE;
  }

  if (access(name, R_OK) == -1 )
  {
    char *message;
    asprintf(&message, UNABLE_TO_ACCESS_FILE, name, strerror(errno));
    Message(ERROR, message);
    free (message);
    return FALSE;
  }

  int res = FALSE;
  if (archive_supported(name))
  {
    char *text;
    if(update_config)
    {
      panel->archive_depth++;
      strcpy(panel->archive_stack[panel->archive_depth], name);
      if ( panel == &top_panel )
        write_archive_stack("top_panel.archive_stack", &top_panel);
      else
        write_archive_stack("bottom_panel.archive_stack", &bottom_panel);
      (void)chdir(saved_work_dir); /* Переходим в каталог откуда нас дёрнули */
    }
    panel->archive_list=archive_list_get(name);
    update(panel); /* Строим список */
    move_selection("0", panel); /* Переходим на первый же файл в списке */
    text=xconcat_path_file(panel->archive_stack[panel->archive_depth],panel->archive_cwd);
    gtk_label_set_text (GTK_LABEL(panel->path_label), text); /* Пишем имя архива с путём в поле снизу */
    free(text);
    res = TRUE;
  } else {
    TRACE("Archive is unsupported: %s", name);
  }
  free(saved_work_dir);
  return res;
}
Exemple #3
0
void archive_enter_subdir(const char *subdir, struct_panel *panel)
{
  char *path, *temp;
  TRACE("archive_enter_subdir '%s'\n", subdir);
  temp=panel->archive_cwd;
  panel->archive_cwd=xconcat(temp, subdir);
  free(temp);
  if ( panel == &top_panel )
    write_config_string("top_panel.archive_cwd", panel->archive_cwd);
  else
    write_config_string("bottom_panel.archive_cwd", panel->archive_cwd);
  update(panel); /* Перерисовываем список */
  move_selection("0", panel); /* Выбираем первый элемент */
  path=xconcat_path_file(panel->archive_stack[panel->archive_depth], panel->archive_cwd);
  gtk_label_set_text (GTK_LABEL(panel->path_label), path); /* Пишем имя архива с путём в поле снизу */
  free(path);
}
Exemple #4
0
void archive_go_upper(struct_panel *panel) /* Переходим на уровень выше внутри архива */
{
  if (panel->archive_cwd[0] == '\0') /* Если на верхнем уровне архива - то покидаем его*/
    leave_archive(panel);
  else /* А если нет - */
  {
    char *slash=NULL, *path, *iter;
    trim_line(panel->archive_cwd); /* Удяляем последний символ (слэш) из текущего имени */
    archive_cwd_prev=xconcat(basename(panel->archive_cwd),"/");
    slash=strrchr(panel->archive_cwd, '/'); /* Ищем последний слэш в пути */
    if (slash==NULL) /* Если значение пути вырождается в NULL (слэша больше не оказалось) то делаем archive_cwd нулевой строкой*/
      panel->archive_cwd[0]='\0';
    else /* А иначе просто обрезаем путь в архиве на один уровень */
      *(slash+1)='\0';

    if (panel == &top_panel)
    {
      write_config_string("top_panel.archive_cwd", panel->archive_cwd);
      top_panel.last_name[0]='\0';
      write_config_string("top_panel.last_name", top_panel.last_name);
    }
    else
    {
      write_config_string("bottom_panel.archive_cwd", panel->archive_cwd);
      bottom_panel.last_name[0]='\0';
      write_config_string("bottom_panel.last_name", bottom_panel.last_name);
    }
    update(panel); /* Перерисовываем список */
    iter=iter_from_filename (archive_cwd_prev, panel);
    move_selection(iter, panel); /* И выделяем предыдущий каталог в архиве */
    free(iter);
    path=xconcat_path_file(panel->archive_stack[panel->archive_depth],panel->archive_cwd);
    gtk_label_set_text (GTK_LABEL(panel->path_label), path); /* Пишем имя архива с путём в поле снизу */
    free(path);
  }
}