Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
879c696c
Commit
879c696c
authored
May 02, 2006
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid code duplication
parent
9ddc8d6a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
98 deletions
+25
-98
src/misc/unicode.c
src/misc/unicode.c
+25
-98
No files found.
src/misc/unicode.c
View file @
879c696c
...
...
@@ -306,20 +306,7 @@ void LocaleFree( const char *str )
*/
FILE
*
utf8_fopen
(
const
char
*
filename
,
const
char
*
mode
)
{
#if !(defined (WIN32) || defined (UNDER_CE))
const
char
*
local_name
=
ToLocale
(
filename
);
if
(
local_name
!=
NULL
)
{
FILE
*
stream
=
fopen
(
local_name
,
mode
);
LocaleFree
(
local_name
);
return
stream
;
}
else
errno
=
ENOENT
;
return
NULL
;
#else
/* retrieve OS version */
#if defined (WIN32) || defined (UNDER_CE)
if
(
GetVersion
()
<
0x80000000
)
{
/* for Windows NT and above */
...
...
@@ -341,43 +328,19 @@ FILE *utf8_fopen( const char *filename, const char *mode )
*/
return
_wfopen
(
wpath
,
wmode
);
}
else
{
/* for Windows Me/98/95 */
const
char
*
local_name
=
ToLocale
(
filename
);
#endif
const
char
*
local_name
=
ToLocale
(
filename
);
if
(
local_name
!=
NULL
)
{
FILE
*
p_file
=
fopen
(
local_name
,
mode
);
LocaleFree
(
local_name
);
return
p_file
;
}
errno
=
ENOENT
;
return
NULL
;
#if 0
/* Following code might work better in most cases but fails if file
doesn't already exist on call to GetShortPathNameW.
I'll keep it here in case we ever decide to try this first and
then fallback to previous solution if it fails. */
/* we use GetShortFileNameW to get the DOS 8.3 version of the file we need to open */
wchar_t spath[MAX_PATH + 1];
if( GetShortPathNameW( wpath, spath, MAX_PATH ) )
{
char path[ MAX_PATH + 1 ];
int len;
UINT i_codepage = AreFileApisANSI()?GetACP():GetOEMCP();
len = WideCharToMultiByte( i_codepage, 0, spath, -1, NULL, 0, NULL, NULL );
if( len == 0 )
return NULL;
WideCharToMultiByte( i_codepage, 0, spath, -1, path, len, NULL, NULL );
return fopen( path, mode );
}
errno = ENOENT;
return NULL;
#endif
if
(
local_name
!=
NULL
)
{
FILE
*
stream
=
fopen
(
local_name
,
mode
);
LocaleFree
(
local_name
);
return
stream
;
}
#endif
else
errno
=
ENOENT
;
return
NULL
;
}
/**
...
...
@@ -440,6 +403,7 @@ int utf8_mkdir( const char *dirname )
void
*
utf8_opendir
(
const
char
*
dirname
)
{
/* TODO: support for WinNT non-ACP filenames */
const
char
*
local_name
=
ToLocale
(
dirname
);
if
(
local_name
!=
NULL
)
...
...
@@ -534,21 +498,7 @@ int utf8_scandir( const char *dirname, char ***namelist,
static
int
utf8_statEx
(
const
char
*
filename
,
void
*
buf
,
vlc_bool_t
deref
)
{
#if !(defined (WIN32) || defined (UNDER_CE))
# ifdef HAVE_SYS_STAT_H
const
char
*
local_name
=
ToLocale
(
filename
);
if
(
local_name
!=
NULL
)
{
int
res
=
deref
?
stat
(
local_name
,
(
struct
stat
*
)
buf
)
:
lstat
(
local_name
,
(
struct
stat
*
)
buf
);
LocaleFree
(
local_name
);
return
res
;
}
errno
=
ENOENT
;
# endif
return
-
1
;
#else
#if defined (WIN32) || defined (UNDER_CE)
/* retrieve Windows OS version */
if
(
GetVersion
()
<
0x80000000
)
{
...
...
@@ -564,43 +514,20 @@ static int utf8_statEx( const char *filename, void *buf,
return
_wstati64
(
wpath
,
(
struct
_stati64
*
)
buf
);
}
else
{
/* for Windows Me/98/95 */
const
char
*
local_name
=
ToLocale
(
filename
);
#endif
#ifdef HAVE_SYS_STAT_H
const
char
*
local_name
=
ToLocale
(
filename
);
if
(
local_name
!=
NULL
)
{
int
res
=
_stati64
(
local_name
,
(
struct
stat
*
)
buf
);
LocaleFree
(
local_name
);
return
res
;
}
errno
=
ENOENT
;
return
-
1
;
#if 0
/* Following code might work better in most cases but fails if file
doesn't already exist on call to GetShortPathNameW.
I'll keep it here in case we ever decide to try this first and
then fallback to previous solution if it fails. */
/* we use GetShortFileNameW to get the DOS 8.3 version */
wchar_t spath[MAX_PATH + 1];
if( GetShortPathNameW( wpath, spath, MAX_PATH ) )
{
char path[ MAX_PATH + 1 ];
int len;
UINT i_codepage = AreFileApisANSI()?GetACP():GetOEMCP();
len = WideCharToMultiByte( i_codepage, 0, spath, -1, NULL, 0, NULL, NULL );
if( len == 0 )
return -1;
WideCharToMultiByte( i_codepage, 0, spath, -1, path, len, NULL, NULL );
return _stati64( path, (struct _stati64 *)buf );
}
errno = ENOENT;
return -1;
#endif
if
(
local_name
!=
NULL
)
{
int
res
=
deref
?
stat
(
local_name
,
(
struct
stat
*
)
buf
)
:
lstat
(
local_name
,
(
struct
stat
*
)
buf
);
LocaleFree
(
local_name
);
return
res
;
}
errno
=
ENOENT
;
#endif
return
-
1
;
}
...
...
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