Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
d580b834
Commit
d580b834
authored
Dec 12, 1999
by
Peter Ganten
Committed by
Alexandre Julliard
Dec 12, 1999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed GetShortPathNameA.
parent
088a76b8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
50 deletions
+44
-50
dos_fs.c
files/dos_fs.c
+44
-50
No files found.
files/dos_fs.c
View file @
d580b834
...
...
@@ -889,8 +889,8 @@ BOOL DOSFS_GetFullName( LPCSTR name, BOOL check_last, DOS_FULL_NAME *full )
* b) file does exist -> set the short filename.
* - trailing slashes are reproduced in the short name, even if the
* file is not a directory
* - the absolute/relative path of the short name is reproduced
in the
*
same way, like
the long name
* - the absolute/relative path of the short name is reproduced
like found
*
in
the long name
* - longpath and shortpath may have the same adress
* Peter Ganten, 1999
*/
...
...
@@ -899,8 +899,11 @@ DWORD WINAPI GetShortPathNameA( LPCSTR longpath, LPSTR shortpath,
{
DOS_FULL_NAME
full_name
;
LPSTR
tmpshortpath
;
DWORD
length
=
0
,
pos
=
0
;
INT
start
=-
1
,
end
=-
1
,
tmplen
;
DWORD
sp
=
0
,
lp
=
0
;
int
tmplen
,
drive
;
UINT
flags
;
TRACE
(
"%s
\n
"
,
longpath
);
if
(
!
longpath
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
...
...
@@ -911,69 +914,60 @@ DWORD WINAPI GetShortPathNameA( LPCSTR longpath, LPSTR shortpath,
return
0
;
}
tmpshortpath
=
HeapAlloc
(
GetProcessHeap
(),
0
,
MAX_PATHNAME_LEN
);
if
(
!
tmpshortpath
)
{
if
(
(
tmpshortpath
=
HeapAlloc
(
GetProcessHeap
(),
0
,
MAX_PATHNAME_LEN
)
)
==
NULL
)
{
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
0
;
}
/*
Check for Drive-L
etter */
/*
check for drive l
etter */
if
(
longpath
[
1
]
==
':'
)
{
lstrcpynA
(
tmpshortpath
,
longpath
,
3
)
;
length
=
2
;
pos
=
2
;
tmpshortpath
[
0
]
=
longpath
[
0
]
;
tmpshortpath
[
1
]
=
':'
;
sp
=
2
;
}
/* loop over each part of the name */
while
(
longpath
[
pos
]
)
{
if
((
longpath
[
pos
]
==
'\\'
)
||
(
longpath
[
pos
+
1
]
==
'\0'
)
||
(
longpath
[
pos
]
==
'/'
))
{
if
(
start
!=
-
1
)
{
if
(
DOSFS_ValidDOSName
(
longpath
+
start
,
TRUE
))
{
tmplen
=
end
-
start
+
(
((
longpath
[
pos
]
==
'\\'
)
||
(
longpath
[
pos
]
==
'/'
))
?
1
:
2
);
lstrcpynA
(
tmpshortpath
+
length
,
longpath
+
start
,
tmplen
);
length
+=
tmplen
-
1
;
}
else
{
DOSFS_Hash
(
longpath
+
start
,
tmpshortpath
+
length
,
FALSE
,
FALSE
);
length
=
lstrlenA
(
tmpshortpath
);
/* Check if the path, up to this point exists */
if
(
!
DOSFS_GetFullName
(
tmpshortpath
,
TRUE
,
&
full_name
)
)
{
SetLastError
(
ERROR_FILE_NOT_FOUND
);
return
0
;
}
if
(
(
drive
=
DOSFS_GetPathDrive
(
&
longpath
))
==
-
1
)
return
0
;
flags
=
DRIVE_GetFlags
(
drive
);
}
}
while
(
longpath
[
lp
]
)
{
if
((
longpath
[
pos
]
==
'\\'
)
||
(
longpath
[
pos
]
==
'/'
))
{
tmpshortpath
[
length
]
=
'\\'
;
tmpshortpath
[
length
+
1
]
=
'\0'
;
length
++
;
}
pos
++
;
start
=
-
1
;
end
=
-
1
;
/* check for path delimiters and reproduce them */
if
(
longpath
[
lp
]
==
'\\'
||
longpath
[
lp
]
==
'/'
)
{
tmpshortpath
[
sp
]
=
longpath
[
lp
];
sp
++
;
lp
++
;
continue
;
}
if
(
start
==
-
1
)
{
start
=
pos
;
tmplen
=
strcspn
(
longpath
+
lp
,
"
\\
/"
);
lstrcpynA
(
tmpshortpath
+
sp
,
longpath
+
lp
,
tmplen
+
1
);
/* Check, if the current element is a valid dos name */
if
(
DOSFS_ValidDOSName
(
longpath
+
lp
,
!
(
flags
&
DRIVE_CASE_SENSITIVE
)
)
)
{
sp
+=
tmplen
;
lp
+=
tmplen
;
continue
;
}
pos
++
;
end
=
pos
;
/* Check if the file exists and use the existing file name */
if
(
DOSFS_GetFullName
(
tmpshortpath
,
TRUE
,
&
full_name
)
)
{
lstrcpyA
(
tmpshortpath
+
sp
,
strrchr
(
full_name
.
short_name
,
'\\'
)
+
1
);
sp
+=
lstrlenA
(
tmpshortpath
+
sp
);
lp
+=
tmplen
;
continue
;
}
TRACE
(
"not found!
\n
"
);
SetLastError
(
ERROR_FILE_NOT_FOUND
);
return
0
;
}
lstrcpynA
(
shortpath
,
tmpshortpath
,
shortlen
);
length
=
lstrlenA
(
tmpshortpath
);
TRACE
(
"returning %s
\n
"
,
shortpath
);
tmplen
=
lstrlenA
(
tmpshortpath
);
HeapFree
(
GetProcessHeap
(),
0
,
tmpshortpath
);
return
length
;
return
tmplen
;
}
...
...
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