add lowercase short filenames support
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10422 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e0169612c9
commit
0c46f3c6e9
@ -180,7 +180,8 @@ static status_t _next_dirent_(struct diri *iter, struct _dirent_info_ *oinfo,
|
|||||||
// process short name
|
// process short name
|
||||||
if (start_index == 0xffff) {
|
if (start_index == 0xffff) {
|
||||||
start_index = iter->current_index;
|
start_index = iter->current_index;
|
||||||
msdos_to_utf8(buffer, (uchar *)filename, len);
|
// korli : seen on FreeBSD /src/sys/fs/msdosfs/direntry.h
|
||||||
|
msdos_to_utf8(buffer, (uchar *)filename, len, buffer[0xc] & 0x18);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oinfo) {
|
if (oinfo) {
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -1503,7 +1504,7 @@ status_t generate_short_name(const uchar *name, const uchar *uni,
|
|||||||
/* called to convert a short ms-dos filename to utf8.
|
/* called to convert a short ms-dos filename to utf8.
|
||||||
XXX: encoding is assumed to be standard US code page, never shift-JIS
|
XXX: encoding is assumed to be standard US code page, never shift-JIS
|
||||||
*/
|
*/
|
||||||
status_t msdos_to_utf8(uchar *msdos, uchar *utf8, uint32 utf8len)
|
status_t msdos_to_utf8(uchar *msdos, uchar *utf8, uint32 utf8len, bool toLower)
|
||||||
{
|
{
|
||||||
uchar normalized[8+1+3+1];
|
uchar normalized[8+1+3+1];
|
||||||
int32 i, pos;
|
int32 i, pos;
|
||||||
@ -1513,14 +1514,15 @@ status_t msdos_to_utf8(uchar *msdos, uchar *utf8, uint32 utf8len)
|
|||||||
pos = 0;
|
pos = 0;
|
||||||
for (i=0;i<8;i++) {
|
for (i=0;i<8;i++) {
|
||||||
if (msdos[i] == ' ') break;
|
if (msdos[i] == ' ') break;
|
||||||
normalized[pos++] = ((i == 0) && (msdos[i] == 5)) ? 0xe5 : msdos[i];
|
normalized[pos++] = ((i == 0) && (msdos[i] == 5)) ? 0xe5 :
|
||||||
|
(toLower ? tolower(msdos[i]) : msdos[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msdos[8] != ' ') {
|
if (msdos[8] != ' ') {
|
||||||
normalized[pos++] = '.';
|
normalized[pos++] = '.';
|
||||||
for (i=8;i<11;i++) {
|
for (i=8;i<11;i++) {
|
||||||
if (msdos[i] == ' ') break;
|
if (msdos[i] == ' ') break;
|
||||||
normalized[pos++] = msdos[i];
|
normalized[pos++] = (toLower ? tolower(msdos[i]) : msdos[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ status_t munge_short_name1(uchar nshort[11], int iteration, int encoding);
|
|||||||
status_t generate_short_name(const uchar *name, const uchar *uni,
|
status_t generate_short_name(const uchar *name, const uchar *uni,
|
||||||
uint32 unilen, uchar nshort[11], int *encoding);
|
uint32 unilen, uchar nshort[11], int *encoding);
|
||||||
|
|
||||||
status_t msdos_to_utf8(uchar *msdos, uchar *utf8, uint32 utf8len);
|
status_t msdos_to_utf8(uchar *msdos, uchar *utf8, uint32 utf8len, bool toLower);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user