亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? tree.c

?? ReactOS是一些高手根據(jù)Windows XP的內(nèi)核編寫出的類XP。內(nèi)核實現(xiàn)機理和API函數(shù)調(diào)用幾乎相同。甚至可以兼容XP的程序。喜歡研究系統(tǒng)內(nèi)核的人可以看一看。
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* Directory tree browser for the Midnight Commander
   Copyright (C) 1994, 1995, 1996, 1997 The Free Software Foundation

   Written: 1994, 1996 Janne Kukonlehto
            1997 Norbert Warmuth
            1996 Miguel de Icaza

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

   This module has been converted to be a widget.

   The program load and saves the tree each time the tree widget is
   created and destroyed.  This is required for the future vfs layer,
   it will be possible to have tree views over virtual file systems.

   */
#include <config.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <fcntl.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <errno.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>	/* For free() and atoi() */
#include <string.h>
#include "tty.h"
#include "mad.h"
#include "global.h"
#include "util.h"
#include "color.h"
#include "dialog.h"
#include "dir.h"
#include "dlg.h"
#include "widget.h"
#include "panel.h"
#include "mouse.h"
#include "main.h"
#include "file.h"	/* For copy_dir_dir(), move_dir_dir(), erase_dir() */
#include "help.h"
#include "key.h"	/* For mi_getch() */
#include "tree.h"
#include "cmd.h"
#include "../vfs/vfs.h"
#ifdef OS2_NT
#   include <io.h>
#endif

extern int command_prompt;

#define TREE_NORMALC HOT_FOCUSC

/* Specifies the display mode: 1d or 2d */
int tree_navigation_flag;

/* If this is true, then when browsing the tree the other window will
 * automatically reload it's directory with the contents of the currently
 * selected directory.
 */
int xtree_mode = 0;

/* Forwards */
static int tree_callback (Dlg_head *h, WTree *tree, int msg, int par);
#define tcallback (callback_fn) tree_callback

/* "$Id: tree.c 15091 2005-05-07 21:24:31Z sedwards $" */

/* Returns number of common characters */
static inline int str_common (char *s1, char *s2)
{
    int result = 0;

    while (*s1++ == *s2++)
	result++;
    return result;
}

static tree_entry *back_ptr (tree_entry *ptr, int *count)
{
    int i = 0;

    while (ptr && ptr->prev && i < *count){
	ptr = ptr->prev;
	i ++;
    }
    *count = i;
    return ptr;
}

static tree_entry *forw_ptr (tree_entry *ptr, int *count)
{
    int i = 0;

    while (ptr && ptr->next && i < *count){
	ptr = ptr->next;
	i ++;
    }
    *count = i;
    return ptr;
}

/* The directory names are arranged in a single linked list in the same
   order as they are displayed. When the tree is displayed the expected
   order is like this:
        /
        /bin
        /etc
        /etc/X11
        /etc/rc.d
        /etc.old/X11
        /etc.old/rc.d
        /usr

   i.e. the required collating sequence when comparing two directory names is
        '\0' < PATH_SEP < all-other-characters-in-encoding-order

    Since strcmp doesn't fulfil this requirement we use pathcmp when
    inserting directory names into the list. The meaning of the return value
    of pathcmp and strcmp are the same (an integer less than, equal to, or
    greater than zero if p1 is found to be less than, to match, or be greater
    than p2.
 */
int
pathcmp (const char *p1, const char *p2)
{
    for ( ;*p1 == *p2; p1++, p2++)
        if (*p1 == '\0' )
    	    return 0;

    if (*p1 == '\0')
        return -1;
    if (*p2 == '\0')
        return 1;
    if (*p1 == PATH_SEP)
        return -1;
    if (*p2 == PATH_SEP)
        return 1;
    return (*p1 - *p2);
}

/* Searches for specified directory */
static tree_entry *whereis (WTree *tree, char *name)
{
    tree_entry *current = tree->tree_first;
    int flag = -1;

#if 0
    if (tree->tree_last){
	flag = strcmp (tree->tree_last->name, name);
	if (flag <= 0){
	    current = tree->tree_last;
	} else if (tree->selected_ptr){
	    flag = strcmp (tree->selected_ptr->name, name);
	    if (flag <= 0){
		current = tree->selected_ptr;
	    }
	}
    }
#endif
    while (current && (flag = pathcmp (current->name, name)) < 0)
	current = current->next;

    if (flag == 0)
	return current;
    else
	return NULL;
}

/* Add a directory to the list of directories */
tree_entry *tree_add_entry (WTree *tree, char *name)
{
    int flag = -1;
    tree_entry *current = tree->tree_first;
    tree_entry *old = NULL;
    tree_entry *new;
    int i, len;
    int submask = 0;

    if (!tree)
	return 0;

    if (tree->tree_last && tree->tree_last->next)
	abort ();
#if 0
    if (tree->tree_last){
	flag = strcmp (tree->tree_last->name, name);
	if (flag <= 0){
	    current = tree->tree_last;
	    old = current->prev;
	} else if (tree->selected_ptr){
	    flag = strcmp (tree->selected_ptr->name, name);
	    if (flag <= 0){
		current = tree->selected_ptr;
		old = current->prev;
	    }
	}
    }
#endif
    /* Search for the correct place */
    while (current && (flag = pathcmp (current->name, name)) < 0){
	old = current;
	current = current->next;
    }

    if (flag == 0)
	return current; /* Already in the list */

    /* Not in the list -> add it */
    new = xmalloc (sizeof (tree_entry), "tree, tree_entry");
    if (!current){
	/* Append to the end of the list */
	if (!tree->tree_first){
	    /* Empty list */
	    tree->tree_first = new;
	    new->prev = NULL;
	} else {
	    old->next = new;
	    new->prev = old;
	}
	new->next = NULL;
	tree->tree_last = new;
    } else {
	/* Insert in to the middle of the list */
	new->prev = old;
	if (old){
	    /* Yes, in the middle */
	    new->next = old->next;
	    old->next = new;
	} else {
	    /* Nope, in the beginning of the list */
	    new->next = tree->tree_first;
	    tree->tree_first = new;
	}
	new->next->prev = new;
    }
    /* tree_count++; */

    /* Calculate attributes */
    new->name = strdup (name);
    len = strlen (new->name);
    new->sublevel = 0;
    for (i = 0; i < len; i++)
	if (new->name [i] == PATH_SEP){
	    new->sublevel++;
	    new->subname = new->name + i + 1;
	}
    if (new->next)
	submask = new->next->submask;
    else
	submask = 0;
    submask |= 1 << new->sublevel;
    submask &= (2 << new->sublevel) - 1;
    new->submask = submask;
    new->mark = 0;

    /* Correct the submasks of the previous entries */
    current = new->prev;
    while (current && current->sublevel > new->sublevel){
	current->submask |= 1 << new->sublevel;
	current = current->prev;
    }

    /* The entry has now been added */

    if (new->sublevel > 1){
	/* Let's check if the parent directory is in the tree */
	char *parent = strdup (new->name);
	int i;

	for (i = strlen (parent) - 1; i > 1; i--){
	    if (parent [i] == PATH_SEP){
		parent [i] = 0;
		tree_add_entry (tree, parent);
		break;
	    }
	}
	free (parent);
    }

    return new;
}

#if 0
/* Append a directory to the list of directories */
static tree_entry *tree_append_entry (WTree *tree, char *name)
{
    tree_entry *current, *new;
    int i, len;
    int submask = 0;

    /* We assume the directory is not yet in the list */

    new = xmalloc (sizeof (tree_entry), "tree, tree_entry");
    if (!tree->tree_first){
        /* Empty list */
        tree->tree_first = new;
        new->prev = NULL;
    } else {
        tree->tree_last->next = new;
        new->prev = tree->tree_last;
    }
    new->next = NULL;
    tree->tree_last = new;

    /* Calculate attributes */
    new->name = strdup (name);
    len = strlen (new->name);
    new->sublevel = 0;
    for (i = 0; i < len; i++)
	if (new->name [i] == PATH_SEP){
	    new->sublevel++;
	    new->subname = new->name + i + 1;
	}
    submask = 1 << new->sublevel;
    submask &= (2 << new->sublevel) - 1;
    new->submask = submask;
    new->mark = 0;

    /* Correct the submasks of the previous entries */
    current = new->prev;
    while (current && current->sublevel > new->sublevel){
	current->submask |= 1 << new->sublevel;
	current = current->prev;
    }

    /* The entry has now been appended */
    return new;
}
#endif

static void remove_entry (WTree *tree, tree_entry *entry)
{
    tree_entry *current = entry->prev;
    long submask = 0;

    if (tree->selected_ptr == entry){
	if (tree->selected_ptr->next)
	    tree->selected_ptr = tree->selected_ptr->next;
	else
	    tree->selected_ptr = tree->selected_ptr->prev;
    }

    /* Correct the submasks of the previous entries */
    if (entry->next)
	submask = entry->next->submask;
    while (current && current->sublevel > entry->sublevel){
	submask |= 1 << current->sublevel;
	submask &= (2 << current->sublevel) - 1;
	current->submask = submask;
	current = current->prev;
    }

    /* Unlink the entry from the list */
    if (entry->prev)
	entry->prev->next = entry->next;
    else
	tree->tree_first = entry->next;
    if (entry->next)
	entry->next->prev = entry->prev;
    else
	tree->tree_last = entry->prev;
    /* tree_count--; */

    /* Free the memory used by the entry */
    free (entry->name);
    free (entry);
}

void tree_remove_entry (WTree *tree, char *name)
{
    tree_entry *current, *base, *old;
    int len, base_sublevel;

    /* Miguel Ugly hack */
    if (name [0] == PATH_SEP && name [1] == 0)
	return;
    /* Miguel Ugly hack end */

    base = whereis (tree, name);
    if (!base)
	return;	/* Doesn't exist */
    if (tree->check_name [0] == PATH_SEP && tree->check_name [1] == 0)
	base_sublevel = base->sublevel;
    else
	base_sublevel = base->sublevel + 1;
    len = strlen (base->name);
    current = base->next;
    while (current
	   && strncmp (current->name, base->name, len) == 0
	   && (current->name[len] == '\0' || current->name[len] == PATH_SEP)){
	old = current;
	current = current->next;
	remove_entry (tree, old);
    }
    remove_entry (tree, base);
}

void tree_destroy (WTree *tree)
{
    tree_entry *current, *old;

    save_tree (tree);
    current = tree->tree_first;
    while (current){
	old = current;
	current = current->next;
	free (old->name);
	free (old);
    }
    if (tree->tree_shown){
	free (tree->tree_shown);
	tree->tree_shown = 0;
    }
    tree->selected_ptr = tree->tree_first = tree->tree_last = NULL;
}

/* Mark the subdirectories of the current directory for delete */
void start_tree_check (WTree *tree)
{
    tree_entry *current;
    int len;

    if (!tree)
	tree = (WTree *) find_widget_type (current_dlg, tcallback);
    if (!tree)
	return;

    /* Search for the start of subdirectories */
    mc_get_current_wd (tree->check_name, MC_MAXPATHLEN);
    tree->check_start = NULL;
    current = whereis (tree, tree->check_name);
    if (!current){
	/* Cwd doesn't exist -> add it */
	current = tree_add_entry (tree, tree->check_name);
	return;
    }

    /* Mark old subdirectories for delete */
    tree->check_start = current->next;
    len = strlen (tree->check_name);

    current = tree->check_start;
    while (current
	   && strncmp (current->name, tree->check_name, len) == 0
	   && (current->name[len] == '\0' || current->name[len] == PATH_SEP || len == 1)){
	current->mark = 1;
	current = current->next;
    }
}

/* This subdirectory exists -> clear deletion mark */
void do_tree_check (WTree *tree, const char *subname)
{
    char *name;
    tree_entry *current, *base;
    int flag = 1, len;

    /* Calculate the full name of the subdirectory */
    if (subname [0] == '.' &&
	(subname [1] == 0 || (subname [1] == '.' && subname [2] == 0)))
	return;
    if (tree->check_name [0] == PATH_SEP && tree->check_name [1] == 0)
	name = copy_strings (PATH_SEP_STR, subname, 0);
    else
	name = concat_dir_and_file (tree->check_name, subname);

    /* Search for the subdirectory */
    current = tree->check_start;
    while (current && (flag = pathcmp (current->name, name)) < 0)
	current = current->next;

    if (flag != 0)
	/* Doesn't exist -> add it */
	current = tree_add_entry (tree, name);
    free (name);

    /* Clear the deletion mark from the subdirectory and its children */
    base = current;
    if (base){
	len = strlen (base->name);
	base->mark = 0;
	current = base->next;
	while (current
	       && strncmp (current->name, base->name, len) == 0
	       && (current->name[len] == '\0' || current->name[len] == PATH_SEP || len == 1)){
	    current->mark = 0;
	    current = current->next;
	}
    }
}

/* Tree check searchs a tree widget in the current dialog and
 * if it finds it, it calls do_tree_check on the subname
 */
void tree_check (const char *subname)
{
    WTree *tree;

    tree = (WTree *) find_widget_type (current_dlg, tcallback);
    if (!tree)
	return;
    do_tree_check (tree, subname);
}


/* Delete subdirectories which still have the deletion mark */
void end_tree_check (WTree *tree)
{
    tree_entry *current, *old;
    int len;

    if (!tree)
	tree = (WTree *) find_widget_type (current_dlg, tcallback);
    if (!tree)
	return;

    /* Check delete marks and delete if found */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕一区二区在线观看 | 成人av资源下载| 久久黄色级2电影| 99re在线精品| 久久九九久久九九| 婷婷综合五月天| kk眼镜猥琐国模调教系列一区二区| 91精品国产综合久久精品app| 亚洲丝袜另类动漫二区| 国产麻豆视频精品| 欧美va在线播放| 日韩影院精彩在线| 欧美日韩精品免费观看视频| 最新国产精品久久精品| 风间由美一区二区av101| 欧美va亚洲va香蕉在线| 调教+趴+乳夹+国产+精品| 色婷婷激情综合| 欧美日韩高清影院| 青娱乐精品在线视频| 国产精品欧美一区喷水| 欧美亚洲综合在线| 欧美日韩亚洲国产综合| 亚洲一区二区三区小说| 欧美在线观看18| 亚洲综合图片区| 91浏览器在线视频| 亚洲乱码一区二区三区在线观看| 国产精品一区二区在线播放| 久久久影院官网| 国产成人免费视频精品含羞草妖精| 精品久久久网站| 激情国产一区二区| 国产午夜一区二区三区| 国产不卡视频在线播放| 国产精品久久久久影院老司| 91亚洲精华国产精华精华液| 亚洲美女屁股眼交| 欧美午夜在线一二页| 欧美国产丝袜视频| 97国产精品videossex| 极品美女销魂一区二区三区| 一区二区三区四区精品在线视频| 精品一区二区久久久| 欧美精品欧美精品系列| 美脚の诱脚舐め脚责91 | 国产女主播一区| 成人av免费在线播放| 一区二区三区中文字幕电影| 欧美日韩免费高清一区色橹橹| 图片区小说区国产精品视频| wwwwxxxxx欧美| 99久久精品一区| 一区二区三区欧美亚洲| 欧美一区二区播放| 懂色av中文一区二区三区| 亚洲另类色综合网站| 日韩一区二区三区电影在线观看 | 奇米色777欧美一区二区| 亚洲精品videosex极品| 中文字幕制服丝袜一区二区三区 | 欧美肥大bbwbbw高潮| 精品在线观看视频| 最新热久久免费视频| 91精品国产综合久久久蜜臀粉嫩| 国产自产v一区二区三区c| 综合久久久久久久| 日韩你懂的在线观看| 91精品久久久久久久91蜜桃 | 一区二区三区欧美日| 日本精品视频一区二区| 丝袜亚洲另类丝袜在线| 国产亚洲成aⅴ人片在线观看| 色婷婷精品久久二区二区蜜臂av | 国产91在线观看| 久久国产人妖系列| 精品在线一区二区| 激情五月激情综合网| 韩国理伦片一区二区三区在线播放| 日本不卡一二三区黄网| 久久66热re国产| 亚洲欧美怡红院| 在线亚洲免费视频| 高清成人在线观看| 久草在线在线精品观看| 亚洲资源在线观看| 国产精品久久久久永久免费观看 | 久久美女高清视频| 欧美高清dvd| 91精品福利视频| 黄色资源网久久资源365| 亚洲6080在线| 一区二区三区四区蜜桃 | 色www精品视频在线观看| 国产电影一区在线| 精品一区二区在线看| 爽爽淫人综合网网站| 亚洲线精品一区二区三区| 一区在线播放视频| 国产精品久久久久久久久免费相片 | 国产精品久久久久久福利一牛影视 | 日韩欧美成人一区| 欧美理论在线播放| 欧美在线观看视频一区二区三区| 99re成人精品视频| 99热在这里有精品免费| www.日韩在线| av亚洲产国偷v产偷v自拍| 国产盗摄一区二区三区| 国产另类ts人妖一区二区| 国产在线视频不卡二| 看电视剧不卡顿的网站| 久久成人久久爱| 久久国产精品区| 国产自产v一区二区三区c| 久久66热偷产精品| 国内久久婷婷综合| 国产伦精品一区二区三区免费迷| 久久成人久久爱| 国产成人综合自拍| kk眼镜猥琐国模调教系列一区二区 | 精品一区二区三区影院在线午夜| 奇米影视在线99精品| 狠狠色2019综合网| 丁香五精品蜜臀久久久久99网站| 成人动漫av在线| 一本到三区不卡视频| 欧美在线一区二区| 91精品国产综合久久福利| 精品国产污网站| 国产亚洲欧美激情| 中文字幕综合网| 午夜视频一区在线观看| 久久精品免费看| 国产91精品久久久久久久网曝门| caoporm超碰国产精品| 欧美亚洲动漫精品| 日韩欧美在线网站| 中文字幕乱码日本亚洲一区二区| 18成人在线观看| 美美哒免费高清在线观看视频一区二区 | 午夜精品一区二区三区免费视频| 免费成人美女在线观看| 福利一区二区在线观看| 欧美午夜精品理论片a级按摩| 日韩精品一区二区三区老鸭窝| 国产女同性恋一区二区| 亚洲六月丁香色婷婷综合久久 | 美女视频黄频大全不卡视频在线播放 | 国产精品国产三级国产普通话三级 | 伊人一区二区三区| 免费看欧美美女黄的网站| 粉嫩嫩av羞羞动漫久久久| 欧美羞羞免费网站| 2021国产精品久久精品| 亚洲久草在线视频| 国产一区二区精品久久91| 在线一区二区三区| 久久久久久久久久美女| 性做久久久久久免费观看欧美| 国产揄拍国内精品对白| 欧美亚洲国产一区在线观看网站| 亚洲精品一区二区三区99| 亚洲一区二区偷拍精品| 成人av影院在线| 精品福利av导航| 日本亚洲最大的色成网站www| 成人av午夜电影| 久久精品夜色噜噜亚洲aⅴ| 日日噜噜夜夜狠狠视频欧美人| 99视频有精品| 久久精品亚洲乱码伦伦中文| 日本伊人色综合网| 欧洲精品在线观看| 亚洲同性gay激情无套| 国产精品1区2区3区| 日韩欧美一级在线播放| 亚欧色一区w666天堂| 在线免费一区三区| 国产精品久久99| 成人午夜激情视频| 久久―日本道色综合久久| 蜜臀av在线播放一区二区三区| 欧美一a一片一级一片| 一区二区在线观看av| 91视频精品在这里| 国产日韩av一区| 国产精品自拍在线| 久久久久久久久久久久电影| 美女一区二区三区在线观看| 欧美美女一区二区三区| 亚洲一区二区四区蜜桃| 日本精品一区二区三区高清| 18欧美亚洲精品| 日本精品视频一区二区三区| 一区二区三区在线观看国产| 欧洲另类一二三四区| 亚洲国产精品久久一线不卡| 欧美日韩大陆一区二区| 午夜激情一区二区|