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
cce7e258
Commit
cce7e258
authored
Apr 08, 2003
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make DRIVE_FindRootW really behave like DRIVE_FindRoot.
parent
3dec4c52
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
19 deletions
+60
-19
drive.c
files/drive.c
+60
-19
No files found.
files/drive.c
View file @
cce7e258
...
...
@@ -476,35 +476,76 @@ int DRIVE_FindDriveRoot( const char **path )
*/
int
DRIVE_FindDriveRootW
(
LPCWSTR
*
path
)
{
int
drive
,
rootdrive
=
-
1
;
char
buffer
[
MAX_PATHNAME_LEN
];
LPCWSTR
p
=
*
path
;
int
len
,
match_len
=
-
1
;
int
drive
,
level
,
len
;
WCHAR
buffer
[
MAX_PATHNAME_LEN
];
WCHAR
*
p
;
struct
stat
st
;
strcpyW
(
buffer
,
*
path
);
while
((
p
=
strchrW
(
buffer
,
'\\'
))
!=
NULL
)
*
p
=
'/'
;
len
=
strlenW
(
buffer
);
/* strip off trailing slashes */
while
(
len
>
1
&&
buffer
[
len
-
1
]
==
'/'
)
buffer
[
--
len
]
=
0
;
for
(;;)
{
int
codepage
=
-
1
;
/* Find the drive */
for
(
drive
=
0
;
drive
<
MAX_DOS_DRIVES
;
drive
++
)
{
if
(
!
DOSDrives
[
drive
].
root
||
(
DOSDrives
[
drive
].
flags
&
DRIVE_DISABLED
))
continue
;
char
buffA
[
MAX_PATHNAME_LEN
];
WideCharToMultiByte
(
DOSDrives
[
drive
].
codepage
,
0
,
*
path
,
-
1
,
buffer
,
MAX_PATHNAME_LEN
,
NULL
,
NULL
);
if
(
!
DOSDrives
[
drive
].
root
||
(
DOSDrives
[
drive
].
flags
&
DRIVE_DISABLED
))
continue
;
len
=
strlen
(
DOSDrives
[
drive
].
root
);
if
(
strncmp
(
DOSDrives
[
drive
].
root
,
buffer
,
len
))
if
(
codepage
!=
DOSDrives
[
drive
].
codepage
)
{
WideCharToMultiByte
(
DOSDrives
[
drive
].
codepage
,
0
,
buffer
,
-
1
,
buffA
,
sizeof
(
buffA
),
NULL
,
NULL
);
if
(
stat
(
buffA
,
&
st
)
==
-
1
||
!
S_ISDIR
(
st
.
st_mode
))
{
codepage
=
-
1
;
continue
;
if
(
len
<=
match_len
)
continue
;
match_len
=
len
;
rootdrive
=
drive
;
p
=
*
path
+
len
;
}
codepage
=
DOSDrives
[
drive
].
codepage
;
}
if
((
DOSDrives
[
drive
].
dev
==
st
.
st_dev
)
&&
(
DOSDrives
[
drive
].
ino
==
st
.
st_ino
))
{
static
const
WCHAR
rootW
[]
=
{
'\\'
,
0
};
if
(
len
==
1
)
len
=
0
;
/* preserve root slash in returned path */
TRACE
(
"%s -> drive %c:, root=%s, name=%s
\n
"
,
debugstr_w
(
*
path
),
'A'
+
drive
,
debugstr_w
(
buffer
),
debugstr_w
(
*
path
+
len
));
*
path
+=
len
;
if
(
!**
path
)
*
path
=
rootW
;
return
drive
;
}
}
if
(
len
<=
1
)
return
-
1
;
/* reached root */
if
(
rootdrive
!=
-
1
)
level
=
0
;
while
(
level
<
1
)
{
*
path
=
p
;
TRACE
(
"%s -> drive %c:, root='%s', name=%s
\n
"
,
buffer
,
'A'
+
rootdrive
,
DOSDrives
[
rootdrive
].
root
,
debugstr_w
(
*
path
)
);
static
const
WCHAR
dotW
[]
=
{
'.'
,
0
};
static
const
WCHAR
dotdotW
[]
=
{
'.'
,
'.'
,
0
};
/* find start of the last path component */
while
(
len
>
1
&&
buffer
[
len
-
1
]
!=
'/'
)
len
--
;
if
(
!
buffer
[
len
])
break
;
/* empty component -> reached root */
/* does removing it take us up a level? */
if
(
strcmpW
(
buffer
+
len
,
dotW
)
!=
0
)
level
+=
strcmpW
(
buffer
+
len
,
dotdotW
)
?
1
:
-
1
;
buffer
[
len
]
=
0
;
/* strip off trailing slashes */
while
(
len
>
1
&&
buffer
[
len
-
1
]
==
'/'
)
buffer
[
--
len
]
=
0
;
}
}
return
rootdrive
;
}
...
...
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