Esempio n. 1
0
void label_name(struct doscp_t *cp, const char *filename, int *mangled, struct dos_name_t *ans)
{
	memset(ans, ' ', 8 + 3);
	ans->sentinel = '\0';

	wchar_t wbuffer[12];
	int len = native_to_wchar(filename, wbuffer, 11, 0, 0);

	if (len > 11)
	{
		*mangled = 1;
		len = 11;
	}
	else
		*mangled = 0;

	int have_lower = 0;
	int have_upper = 0;
	int i = 0;

	for(i = 0; i < len; i++)
	{
		if (islower(wbuffer[i]))
			have_lower = 1;

		if (isupper(wbuffer[i]))
			have_upper = 1;

		wbuffer[i] = towupper(wbuffer[i]);

		if (wcschr(L"^+=/[]:,?*\\<>|\".", wbuffer[i]))
		{
			*mangled = 1;
			wbuffer[i] = '~';
		}
	}

	if (have_lower && have_upper)
		*mangled = 1;

	wchar_to_dos(cp, wbuffer, ans->base, len, mangled);
}
Esempio n. 2
0
static void TranslateToDos(doscp_t *toDos, const char *in, char *out, int count,
			   char *end, Case_t *Case, int *mangled)
{
	wchar_t buffer[12];
	wchar_t *s=buffer;
	wchar_t *t=buffer;

	/* first convert to wchar, so we get to use towupper etc. */
	native_to_wchar(in, buffer, count, end, mangled);
	buffer[count]='\0';

	*Case = NONE;
	for( ;  *s ; s++) {
		/* skip spaces & dots */
		if(*s == ' ' || *s == '.') {
			*mangled |= 3;
			continue;
		}

		if (iswcntrl(*s)) {
			/* "control" characters */
			*mangled |= 3;
			*t = '_';
		} else if (iswlower(*s)) {
			*t = towupper(*s);
			if(*Case == UPPER && !mtools_no_vfat)
				*mangled |= 1;
			else
				*Case = LOWER;
		} else if (iswupper(*s)) {
			*t = *s;
			if(*Case == LOWER && !mtools_no_vfat)
				*mangled |= 1;
			else
				*Case = UPPER;
		} else
			*t = *s;
		t++;
	}
	wchar_to_dos(toDos, buffer, out, t - buffer, mangled);
}
Esempio n. 3
0
void label_name(doscp_t *cp, const char *filename, int verbose,
		int *mangled, dos_name_t *ans)
{
	int len;
	int i;
	int have_lower, have_upper;
	wchar_t wbuffer[12];

	memset(ans, ' ', sizeof(ans)-1);
	ans->sentinel = '\0';
	len = native_to_wchar(filename, wbuffer, 11, 0, 0);
	if(len > 11){
		*mangled = 1;
		len = 11;
	} else
		*mangled = 0;

	have_lower = have_upper = 0;
	for(i=0; i<len; i++){
		if(islower(wbuffer[i]))
			have_lower = 1;
		if(isupper(wbuffer[i]))
			have_upper = 1;
		wbuffer[i] = towupper(wbuffer[i]);
		if(
#ifdef HAVE_WCHAR_H
		   wcschr(L"^+=/[]:,?*\\<>|\".", wbuffer[i])
#else
		   strchr("^+=/[]:,?*\\<>|\".", wbuffer[i])
#endif
		   ){
			*mangled = 1;
			wbuffer[i] = '~';
		}
	}
	if (have_lower && have_upper)
		*mangled = 1;
	wchar_to_dos(cp, wbuffer, ans->base, len, mangled);
}