Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
a98f1297
Commit
a98f1297
authored
Sep 02, 2003
by
Stefan Leichter
Committed by
Alexandre Julliard
Sep 02, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved implementation of QueryDosDevice from ascii to unicode.
parent
514521bf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
109 additions
and
33 deletions
+109
-33
dos_fs.c
files/dos_fs.c
+109
-33
No files found.
files/dos_fs.c
View file @
a98f1297
...
...
@@ -111,6 +111,19 @@ static const DOS_DEVICE DOSFS_Devices[] =
{
{
'E'
,
'M'
,
'M'
,
'X'
,
'X'
,
'X'
,
'X'
,
'0'
,
0
},
0x0000
}
};
static
const
WCHAR
devW
[]
=
{
'\\'
,
'D'
,
'e'
,
'v'
,
'i'
,
'c'
,
'e'
,
'\\'
,
0
};
static
const
WCHAR
dosW
[]
=
{
'\\'
,
'D'
,
'o'
,
's'
,
'D'
,
'e'
,
'v'
,
'i'
,
'c'
,
'e'
,
's'
,
'\\'
,
0
};
static
const
WCHAR
auxW
[]
=
{
'A'
,
'U'
,
'X'
,
0
};
static
const
WCHAR
comW
[]
=
{
'C'
,
'O'
,
'M'
,
0
};
static
const
WCHAR
lptW
[]
=
{
'L'
,
'P'
,
'T'
,
0
};
static
const
WCHAR
nulW
[]
=
{
'N'
,
'U'
,
'L'
,
0
};
static
const
WCHAR
nullW
[]
=
{
'N'
,
'u'
,
'l'
,
'l'
,
0
};
static
const
WCHAR
parW
[]
=
{
'P'
,
'a'
,
'r'
,
'a'
,
'l'
,
'l'
,
'e'
,
'l'
,
0
};
static
const
WCHAR
serW
[]
=
{
'S'
,
'e'
,
'r'
,
'i'
,
'a'
,
'l'
,
0
};
static
const
WCHAR
oneW
[]
=
{
'1'
,
0
};
/*
* Directory info for DOSFS_ReadDir
* contains the names of *all* the files in the directory
...
...
@@ -2354,15 +2367,67 @@ BOOL WINAPI FileTimeToDosDateTime( const FILETIME *ft, LPWORD fatdate,
*/
DWORD
WINAPI
QueryDosDeviceA
(
LPCSTR
devname
,
LPSTR
target
,
DWORD
bufsize
)
{
LPSTR
s
;
char
buffer
[
200
];
DWORD
ret
=
0
,
retW
;
LPWSTR
targetW
=
(
LPWSTR
)
HeapAlloc
(
GetProcessHeap
(),
0
,
bufsize
*
sizeof
(
WCHAR
));
UNICODE_STRING
devnameW
;
if
(
devname
)
RtlCreateUnicodeStringFromAsciiz
(
&
devnameW
,
devname
);
else
devnameW
.
Buffer
=
NULL
;
retW
=
QueryDosDeviceW
(
devnameW
.
Buffer
,
targetW
,
bufsize
);
ret
=
WideCharToMultiByte
(
CP_ACP
,
0
,
targetW
,
retW
,
target
,
bufsize
,
NULL
,
NULL
);
TRACE
(
"(%s,...)
\n
"
,
devname
?
devname
:
"<null>"
);
RtlFreeUnicodeString
(
&
devnameW
);
if
(
targetW
)
HeapFree
(
GetProcessHeap
(),
0
,
targetW
);
return
ret
;
}
/***********************************************************************
* QueryDosDeviceW (KERNEL32.@)
*
* returns array of strings terminated by \0, terminated by \0
*
* FIXME
* - Win9x returns for all calls ERROR_INVALID_PARAMETER
* - the returned devices for devname == NULL is far from complete
* - its not checked that the returned device exist
*/
DWORD
WINAPI
QueryDosDeviceW
(
LPCWSTR
devname
,
LPWSTR
target
,
DWORD
bufsize
)
{
const
WCHAR
*
pDev
,
*
pName
,
*
pNum
=
NULL
;
int
numsiz
=
0
;
DWORD
ret
;
TRACE
(
"(%s,...)
\n
"
,
debugstr_w
(
devname
));
if
(
!
devname
)
{
/* return known MSDOS devices */
static
const
char
devices
[
24
]
=
"CON
\0
COM1
\0
COM2
\0
LPT1
\0
NUL
\0\0
"
;
memcpy
(
target
,
devices
,
min
(
bufsize
,
sizeof
(
devices
))
);
return
min
(
bufsize
,
sizeof
(
devices
));
DWORD
ret
=
0
;
int
i
;
static
const
WCHAR
devices
[][
5
]
=
{{
'A'
,
'U'
,
'X'
,
0
},
{
'C'
,
'O'
,
'M'
,
'1'
,
0
},
{
'C'
,
'O'
,
'M'
,
'2'
,
0
},
{
'L'
,
'P'
,
'T'
,
'1'
,
0
},
{
'N'
,
'U'
,
'L'
,
0
,}};
for
(
i
=
0
;
(
i
<
(
sizeof
(
devices
)
/
sizeof
(
devices
[
0
])));
i
++
)
{
DWORD
len
=
strlenW
(
devices
[
i
]);
if
(
target
&&
(
bufsize
>=
ret
+
len
+
2
))
{
lstrcpyW
(
target
+
ret
,
devices
[
i
]);
ret
+=
len
+
1
;
}
else
{
/* in this case WinXP returns 0 */
FIXME
(
"function return is wrong for WinXP!
\n
"
);
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
break
;
}
}
/* append drives here */
if
(
target
&&
bufsize
>
0
)
target
[
ret
++
]
=
0
;
FIXME
(
"Returned list is not complete
\n
"
);
return
ret
;
}
/* In theory all that are possible and have been defined.
* Now just those below, since mirc uses it to check for special files.
...
...
@@ -2370,39 +2435,50 @@ DWORD WINAPI QueryDosDeviceA(LPCSTR devname,LPSTR target,DWORD bufsize)
* (It is more complex, and supports netmounted stuff, and \\.\ stuff,
* but currently we just ignore that.)
*/
#define CHECK(x) (strstr(devname,#x)==devname)
if
(
CHECK
(
con
)
||
CHECK
(
com
)
||
CHECK
(
lpt
)
||
CHECK
(
nul
))
{
strcpy
(
buffer
,
"
\\
DEV
\\
"
);
strcat
(
buffer
,
devname
);
if
((
s
=
strchr
(
buffer
,
':'
)))
*
s
=
'\0'
;
lstrcpynA
(
target
,
buffer
,
bufsize
);
return
strlen
(
buffer
)
+
1
;
}
else
{
if
(
strchr
(
devname
,
':'
)
||
devname
[
0
]
==
'\\'
)
{
/* This might be a DOS device we do not handle yet ... */
FIXME
(
"(%s) not detected as DOS device!
\n
"
,
devname
);
if
(
!
strcmpiW
(
devname
,
auxW
))
{
pDev
=
dosW
;
pName
=
comW
;
numsiz
=
1
;
pNum
=
oneW
;
}
else
if
(
!
strcmpiW
(
devname
,
nulW
))
{
pDev
=
devW
;
pName
=
nullW
;
}
else
if
(
!
strncmpiW
(
devname
,
comW
,
strlenW
(
comW
)))
{
pDev
=
devW
;
pName
=
serW
;
pNum
=
devname
+
strlenW
(
comW
);
for
(
numsiz
=
0
;
isdigitW
(
*
(
pNum
+
numsiz
));
numsiz
++
);
if
(
*
(
pNum
+
numsiz
))
{
SetLastError
(
ERROR_FILE_NOT_FOUND
);
return
0
;
}
SetLastError
(
ERROR_DEV_NOT_EXIST
);
}
else
if
(
!
strncmpiW
(
devname
,
lptW
,
strlenW
(
lptW
)))
{
pDev
=
devW
;
pName
=
parW
;
pNum
=
devname
+
strlenW
(
lptW
);
for
(
numsiz
=
0
;
isdigitW
(
*
(
pNum
+
numsiz
));
numsiz
++
);
if
(
*
(
pNum
+
numsiz
))
{
SetLastError
(
ERROR_FILE_NOT_FOUND
);
return
0
;
}
}
else
{
/* This might be a DOS device we do not handle yet ... */
FIXME
(
"(%s) not detected as DOS device!
\n
"
,
debugstr_w
(
devname
));
/* Win9x set the error ERROR_INVALID_PARAMETER */
SetLastError
(
ERROR_FILE_NOT_FOUND
);
return
0
;
}
FIXME
(
"device %s may not exist on this computer
\n
"
,
debugstr_w
(
devname
));
/***********************************************************************
* QueryDosDeviceW (KERNEL32.@)
*
* returns array of strings terminated by \0, terminated by \0
*/
DWORD
WINAPI
QueryDosDeviceW
(
LPCWSTR
devname
,
LPWSTR
target
,
DWORD
bufsize
)
{
LPSTR
devnameA
=
devname
?
HEAP_strdupWtoA
(
GetProcessHeap
(),
0
,
devname
)
:
NULL
;
LPSTR
targetA
=
(
LPSTR
)
HeapAlloc
(
GetProcessHeap
(),
0
,
bufsize
);
DWORD
ret
=
QueryDosDeviceA
(
devnameA
,
targetA
,
bufsize
);
ret
=
MultiByteToWideChar
(
CP_ACP
,
0
,
targetA
,
ret
,
target
,
bufsize
);
if
(
devnameA
)
HeapFree
(
GetProcessHeap
(),
0
,
devnameA
);
if
(
targetA
)
HeapFree
(
GetProcessHeap
(),
0
,
targetA
);
ret
=
strlenW
(
pDev
)
+
strlenW
(
pName
)
+
numsiz
+
2
;
if
(
ret
>
bufsize
)
ret
=
0
;
if
(
target
&&
ret
)
{
lstrcpyW
(
target
,
pDev
);
lstrcatW
(
target
,
pName
);
if
(
pNum
)
lstrcatW
(
target
,
pNum
);
target
[
ret
-
1
]
=
0
;
}
return
ret
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment