⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 change_current_name.c

📁 阿基米德操作系统的源代码
💻 C
字号:

//////////////////////////////////////////////////////////////////////
#include "general.h"

#include "hd_info_struct.h"
#include "dir_entry.h"
#include "msdos_dir_entry.h"
#include "d_inode.h"
#include "m_inode.h"
#include "buffer_head.h"
#include "fat_cache.h"
#include "file.h"
#include "hd_request_struct.h"
#include "super_block.h"

#include "common_head.h"
//////////////////////////////////////////////////////////////////////
int change_current_name(void)
{
	int	temp_i,temp_j;

	if (!current_namelen || (current_namelen > MSDOS_NAME_LEN + 1))
		return 0;

	current_dir_type = 0;
	if ((current_namelen == 1) && (current_name[0] == '.'))
	{
		current_dir_type = 1;
		for (temp_i = 1; temp_i < MSDOS_NAME_LEN + 1; temp_i++)
			current_name[temp_i] = 0x20;
		return 1;
	}
	if ((current_namelen == 2) && (current_name[0] == '.') && (current_name[1] == '.'))
	{
		current_dir_type = 2;
		for (temp_i = 2; temp_i < MSDOS_NAME_LEN + 1; temp_i++)
			current_name[temp_i] = 0x20;
		return 1;
	}
	
	temp_i = 0;
	while ((temp_i < current_namelen) && (current_name[temp_i] != '.'))
		temp_i++;

	if ((temp_i > 8) ||(temp_i + 4 < current_namelen))
		return 0;

	if (temp_i < 8)
	{
		for (temp_j = current_namelen; temp_j < MSDOS_NAME_LEN + 1; temp_j++)
			current_name[temp_j] = 0x20;

		for (temp_j = current_namelen - 1; temp_j > temp_i; temp_j--)
			current_name[temp_j - temp_i + 7] = current_name[temp_j];
	}
	else
	{
		for (temp_j = temp_i + 1; temp_j < current_namelen; temp_j++)
			current_name[temp_j - 1] = current_name[temp_j];

		temp_j = 8;
		if (current_namelen > 8)
			temp_j = current_namelen - 1;
		while (temp_j < MSDOS_NAME_LEN + 1)
		{
			current_name[temp_j] = 0x20;
			temp_j++;
		}
	}
	
	while (temp_i < 8)
	{
		current_name[temp_i] = 0x20;
		temp_i++;
	}

	for (temp_i = 0; temp_i < MSDOS_NAME_LEN + 1; temp_i++)
		if ((current_name[temp_i] >= 0x61) && (current_name[temp_i] <= 0x7a))
			current_name[temp_i] = current_name[temp_i] - 0x20;

	return 1;
}

void change_current_name0(void)
{
	int	temp_i,temp_j;

	current_name[11] = 0x20;
	if (current_name[8] == 0x20)
		return;

	temp_i = 0;
	while ((temp_i <= 7) && (current_name[temp_i] != 0x20))
		temp_i++;

	if (temp_i == 8)
	{
		for (temp_j = 10; temp_j >= 8; temp_j--)
			current_name[temp_j + 1] = current_name[temp_j];
		current_name[8] = '.';
	}
	else
	{
		current_name[temp_i] = '.';
		temp_i++;
		for (temp_j = 8; temp_j <= 10; temp_j++,temp_i++)
			current_name[temp_i] = current_name[temp_j];
		while (temp_i <= 10)
		{
			current_name[temp_i] = 0x20;
			temp_i++;
		}
	}

	return;
}

int msdos_match(struct msdos_dir_entry * de)
{
	int same;

	if (!de)
		return 0;
	__asm__("cld\n\t"
			"repe ; cmpsb\n\t"
			"setz %%al"
		   :"=a" (same)
		   :"0" (0),"S" ((long) current_name),"D" ((long) de->dir_name),"c" (MSDOS_NAME_LEN));
	return same;
}

int msdos_match0(struct msdos_dir_entry * de)
{
	int same;

	if (!de)
		return 0;
	__asm__("cld\n\t"
			"repe ; cmpsb\n\t"
			"setz %%al"
		   :"=a" (same)
		   :"0" (0),"S" ((long) sys_dir_name0),"D" ((long) de->dir_name),"c" (MSDOS_NAME_LEN));
	return same;
}

int msdos_match1(struct msdos_dir_entry * de)
{
	int same;

	if (!de)
		return 0;
	__asm__("cld\n\t"
			"repe ; cmpsb\n\t"
			"setz %%al"
		   :"=a" (same)
		   :"0" (0),"S" ((long) sys_dir_name1),"D" ((long) de->dir_name),"c" (MSDOS_NAME_LEN));
	return same;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -