Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
9197cdff
Commit
9197cdff
authored
Jul 12, 2011
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Win32: handle file paths of arbitrary length (in file system code)
parent
058e5676
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
36 deletions
+75
-36
src/win32/filesystem.c
src/win32/filesystem.c
+68
-30
src/win32/plugin.c
src/win32/plugin.c
+7
-6
No files found.
src/win32/filesystem.c
View file @
9197cdff
...
...
@@ -48,20 +48,25 @@
# include <tchar.h>
#endif
static
int
convert_path
(
const
char
*
restrict
path
,
wchar_t
*
restrict
w
path
)
static
wchar_t
*
widen_path
(
const
char
*
path
)
{
if
(
!
MultiByteToWideChar
(
CP_UTF8
,
0
,
path
,
-
1
,
wpath
,
MAX_PATH
))
wchar_t
*
wpath
;
errno
=
0
;
wpath
=
ToWide
(
path
);
if
(
wpath
==
NULL
)
{
if
(
errno
==
0
)
errno
=
ENOENT
;
return
-
1
;
return
NULL
;
}
wpath
[
MAX_PATH
]
=
L'\0'
;
return
0
;
return
wpath
;
}
#define CONVERT_PATH(path, wpath, err) \
wchar_t wpath[MAX_PATH+1]
; \
if (convert_path (path, wpath)) \
return (err)
wchar_t *wpath = wide_path(path)
; \
if (wpath == NULL) return (err)
int
vlc_open
(
const
char
*
filename
,
int
flags
,
...)
{
...
...
@@ -81,9 +86,13 @@ int vlc_open (const char *filename, int flags, ...)
* open() cannot open files with non-“ANSI” characters on Windows.
* We use _wopen() instead. Same thing for mkdir() and stat().
*/
CONVERT_PATH
(
filename
,
wpath
,
-
1
);
return
_wopen
(
wpath
,
flags
,
mode
);
wchar_t
*
wpath
=
widen_path
(
filename
);
if
(
wpath
==
NULL
)
return
-
1
;
int
fd
=
_wopen
(
wpath
,
flags
,
mode
);
free
(
wpath
);
return
fd
;
#endif
}
...
...
@@ -101,10 +110,14 @@ int vlc_mkdir( const char *dirname, mode_t mode )
/* mkdir converts internally to wchar */
return
_mkdir
(
dirname
);
#else
(
void
)
mode
;
CONVERT_PATH
(
dirname
,
wpath
,
-
1
);
return
_wmkdir
(
wpath
)
;
wchar_t
*
wpath
=
widen_path
(
dirname
)
;
if
(
wpath
==
NULL
)
return
-
1
;
int
ret
=
_wmkdir
(
wpath
);
free
(
wpath
);
(
void
)
mode
;
return
ret
;
#endif
}
...
...
@@ -134,15 +147,20 @@ typedef struct vlc_DIR
DIR
*
vlc_opendir
(
const
char
*
dirname
)
{
CONVERT_PATH
(
dirname
,
wpath
,
NULL
);
wchar_t
*
wpath
=
widen_path
(
dirname
);
if
(
wpath
==
NULL
)
return
NULL
;
vlc_DIR
*
p_dir
=
malloc
(
sizeof
(
*
p_dir
));
if
(
unlikely
(
p_dir
==
NULL
))
{
free
(
wpath
);
return
NULL
;
}
if
(
wpath
==
NULL
||
wpath
[
0
]
==
'\0'
||
(
wcscmp
(
wpath
,
L"
\\
"
)
==
0
))
if
(
wpath
[
0
]
==
L'\0'
||
(
wcscmp
(
wpath
,
L"
\\
"
)
==
0
))
{
free
(
wpath
);
/* Special mode to list drive letters */
p_dir
->
wdir
=
NULL
;
#ifdef UNDER_CE
...
...
@@ -153,16 +171,17 @@ DIR *vlc_opendir (const char *dirname)
return
(
void
*
)
p_dir
;
}
assert
(
wpath
[
0
]);
// wpath[1] is defined
p_dir
->
u
.
insert_dot_dot
=
!
wcscmp
(
wpath
+
1
,
L":
\\
"
);
_WDIR
*
wdir
=
_wopendir
(
wpath
);
free
(
wpath
);
if
(
wdir
==
NULL
)
{
free
(
p_dir
);
return
NULL
;
}
p_dir
->
wdir
=
wdir
;
assert
(
wpath
[
0
]);
// wpath[1] is defined
p_dir
->
u
.
insert_dot_dot
=
!
wcscmp
(
wpath
+
1
,
L":
\\
"
);
return
(
void
*
)
p_dir
;
}
...
...
@@ -212,8 +231,13 @@ int vlc_stat (const char *filename, struct stat *buf)
/* _stat translates to wchar internally on WinCE */
return
_stat
(
filename
,
buf
);
#else
CONVERT_PATH
(
filename
,
wpath
,
-
1
);
return
_wstati64
(
wpath
,
buf
);
wchar_t
*
wpath
=
widen_path
(
filename
);
if
(
wpath
==
NULL
)
return
-
1
;
int
ret
=
_wstati64
(
wpath
,
buf
);
free
(
wpath
);
return
ret
;
#endif
}
...
...
@@ -228,31 +252,45 @@ int vlc_unlink (const char *filename)
/*_open translates to wchar internally on WinCE*/
return
_unlink
(
filename
);
#else
CONVERT_PATH
(
filename
,
wpath
,
-
1
);
return
_wunlink
(
wpath
);
wchar_t
*
wpath
=
widen_path
(
filename
);
if
(
wpath
==
NULL
)
return
-
1
;
int
ret
=
_wunlink
(
wpath
);
free
(
wpath
);
return
ret
;
#endif
}
int
vlc_rename
(
const
char
*
oldpath
,
const
char
*
newpath
)
{
CONVERT_PATH
(
oldpath
,
wold
,
-
1
);
CONVERT_PATH
(
newpath
,
wnew
,
-
1
);
int
ret
=
-
1
;
wchar_t
*
wold
=
widen_path
(
oldpath
),
*
wnew
=
widen_path
(
newpath
);
if
(
wold
==
NULL
||
wnew
==
NULL
)
goto
out
;
# ifdef UNDER_CE
/* FIXME: errno support */
return
MoveFileW
(
wold
,
wnew
)
?
0
:
-
1
;
if
(
MoveFileW
(
wold
,
wnew
))
ret
=
0
;
#else
if
(
_wrename
(
wold
,
wnew
)
&&
(
errno
==
EACCES
||
errno
==
EEXIST
))
{
/* Windows does not allow atomic file replacement */
if
(
_wremove
(
wnew
))
{
errno
=
EACCES
;
/* restore errno */
return
-
1
;
goto
out
;
}
if
(
_wrename
(
wold
,
wnew
))
return
-
1
;
goto
out
;
}
ret
urn
0
;
ret
=
0
;
#endif
out:
free
(
wnew
);
free
(
wold
);
return
ret
;
}
int
vlc_dup
(
int
oldfd
)
...
...
src/win32/plugin.c
View file @
9197cdff
...
...
@@ -53,23 +53,23 @@ static char *GetWindowsError( void )
int
module_Load
(
vlc_object_t
*
p_this
,
const
char
*
psz_file
,
module_handle_t
*
p_handle
,
bool
lazy
)
{
module_handle_t
handle
;
wchar_t
psz_wfile
[
MAX_PATH
];
MultiByteToWideChar
(
CP_UTF8
,
0
,
psz_file
,
-
1
,
psz_wfile
,
MAX_PATH
);
wchar_t
*
wfile
=
ToWide
(
psz_file
);
if
(
wfile
==
NULL
)
return
-
1
;
(
void
)
lazy
;
module_handle_t
handle
;
#ifndef UNDER_CE
/* FIXME: this is not thread-safe -- Courmisch */
UINT
mode
=
SetErrorMode
(
SEM_FAILCRITICALERRORS
);
SetErrorMode
(
mode
|
SEM_FAILCRITICALERRORS
);
#endif
handle
=
LoadLibraryW
(
psz_wfile
);
handle
=
LoadLibraryW
(
wfile
);
#ifndef UNDER_CE
SetErrorMode
(
mode
);
#endif
free
(
wfile
);
if
(
handle
==
NULL
)
{
...
...
@@ -80,6 +80,7 @@ int module_Load( vlc_object_t *p_this, const char *psz_file,
}
*
p_handle
=
handle
;
(
void
)
lazy
;
return
0
;
}
...
...
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