Commit 0974fd35 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

os2: inline ToLocale/LocaleFree

parent df2ecdd4
...@@ -65,7 +65,7 @@ int vlc_open (const char *filename, int flags, ...) ...@@ -65,7 +65,7 @@ int vlc_open (const char *filename, int flags, ...)
mode = va_arg (ap, unsigned int); mode = va_arg (ap, unsigned int);
va_end (ap); va_end (ap);
const char *local_name = ToLocale (filename); const char *local_name = ToLocaleDup (filename);
if (local_name == NULL) if (local_name == NULL)
{ {
...@@ -77,7 +77,7 @@ int vlc_open (const char *filename, int flags, ...) ...@@ -77,7 +77,7 @@ int vlc_open (const char *filename, int flags, ...)
if (fd != -1) if (fd != -1)
fcntl (fd, F_SETFD, FD_CLOEXEC); fcntl (fd, F_SETFD, FD_CLOEXEC);
LocaleFree (local_name); free (local_name);
return fd; return fd;
} }
...@@ -109,7 +109,7 @@ int vlc_openat (int dir, const char *filename, int flags, ...) ...@@ -109,7 +109,7 @@ int vlc_openat (int dir, const char *filename, int flags, ...)
*/ */
int vlc_mkdir (const char *dirname, mode_t mode) int vlc_mkdir (const char *dirname, mode_t mode)
{ {
char *locname = ToLocale (dirname); char *locname = ToLocaleDup (dirname);
if (unlikely(locname == NULL)) if (unlikely(locname == NULL))
{ {
errno = ENOENT; errno = ENOENT;
...@@ -117,7 +117,7 @@ int vlc_mkdir (const char *dirname, mode_t mode) ...@@ -117,7 +117,7 @@ int vlc_mkdir (const char *dirname, mode_t mode)
} }
int res = mkdir (locname, mode); int res = mkdir (locname, mode);
LocaleFree (locname); free (locname);
return res; return res;
} }
...@@ -130,7 +130,7 @@ int vlc_mkdir (const char *dirname, mode_t mode) ...@@ -130,7 +130,7 @@ int vlc_mkdir (const char *dirname, mode_t mode)
*/ */
DIR *vlc_opendir (const char *dirname) DIR *vlc_opendir (const char *dirname)
{ {
const char *locname = ToLocale (dirname); const char *locname = ToLocaleDup (dirname);
if (unlikely(locname == NULL)) if (unlikely(locname == NULL))
{ {
errno = ENOENT; errno = ENOENT;
...@@ -139,7 +139,7 @@ DIR *vlc_opendir (const char *dirname) ...@@ -139,7 +139,7 @@ DIR *vlc_opendir (const char *dirname)
DIR *dir = opendir (locname); DIR *dir = opendir (locname);
LocaleFree (locname); free (locname);
return dir; return dir;
} }
...@@ -180,14 +180,14 @@ char *vlc_readdir( DIR *dir ) ...@@ -180,14 +180,14 @@ char *vlc_readdir( DIR *dir )
if (val != 0) if (val != 0)
errno = val; errno = val;
else if (ent != NULL) else if (ent != NULL)
path = FromLocaleDup (ent->d_name); path = FromCharset ("", ent->d_name, strlen(ent->d_name));
free (buf); free (buf);
return path; return path;
} }
static int vlc_statEx (const char *filename, struct stat *buf, bool deref) static int vlc_statEx (const char *filename, struct stat *buf, bool deref)
{ {
const char *local_name = ToLocale (filename); const char *local_name = ToLocaleDup (filename);
if (unlikely(local_name == NULL)) if (unlikely(local_name == NULL))
{ {
errno = ENOENT; errno = ENOENT;
...@@ -196,7 +196,7 @@ static int vlc_statEx (const char *filename, struct stat *buf, bool deref) ...@@ -196,7 +196,7 @@ static int vlc_statEx (const char *filename, struct stat *buf, bool deref)
int res = deref ? stat (local_name, buf) int res = deref ? stat (local_name, buf)
: lstat (local_name, buf); : lstat (local_name, buf);
LocaleFree (local_name); free (local_name);
return res; return res;
} }
...@@ -231,7 +231,7 @@ int vlc_lstat (const char *filename, struct stat *buf) ...@@ -231,7 +231,7 @@ int vlc_lstat (const char *filename, struct stat *buf)
*/ */
int vlc_unlink (const char *filename) int vlc_unlink (const char *filename)
{ {
const char *local_name = ToLocale (filename); const char *local_name = ToLocaleDup (filename);
if (unlikely(local_name == NULL)) if (unlikely(local_name == NULL))
{ {
errno = ENOENT; errno = ENOENT;
...@@ -239,7 +239,7 @@ int vlc_unlink (const char *filename) ...@@ -239,7 +239,7 @@ int vlc_unlink (const char *filename)
} }
int ret = unlink (local_name); int ret = unlink (local_name);
LocaleFree (local_name); free (local_name);
return ret; return ret;
} }
...@@ -253,22 +253,22 @@ int vlc_unlink (const char *filename) ...@@ -253,22 +253,22 @@ int vlc_unlink (const char *filename)
*/ */
int vlc_rename (const char *oldpath, const char *newpath) int vlc_rename (const char *oldpath, const char *newpath)
{ {
const char *lo = ToLocale (oldpath); const char *lo = ToLocaleDup (oldpath);
if (lo == NULL) if (lo == NULL)
goto error; goto error;
const char *ln = ToLocale (newpath); const char *ln = ToLocaleDup (newpath);
if (ln == NULL) if (ln == NULL)
{ {
LocaleFree (lo); free (lo);
error: error:
errno = ENOENT; errno = ENOENT;
return -1; return -1;
} }
int ret = rename (lo, ln); int ret = rename (lo, ln);
LocaleFree (lo); free (lo);
LocaleFree (ln); free (ln);
return ret; return ret;
} }
......
...@@ -49,16 +49,16 @@ int module_Load( vlc_object_t *p_this, const char *psz_file, ...@@ -49,16 +49,16 @@ int module_Load( vlc_object_t *p_this, const char *psz_file,
module_handle_t *p_handle, bool lazy ) module_handle_t *p_handle, bool lazy )
{ {
const int flags = lazy ? RTLD_LAZY : RTLD_NOW; const int flags = lazy ? RTLD_LAZY : RTLD_NOW;
char *path = ToLocale( psz_file ); char *path = ToLocaleDup( psz_file );
module_handle_t handle = dlopen( path, flags ); module_handle_t handle = dlopen( path, flags );
if( handle == NULL ) if( handle == NULL )
{ {
msg_Warn( p_this, "cannot load module `%s' (%s)", path, dlerror() ); msg_Warn( p_this, "cannot load module `%s' (%s)", path, dlerror() );
LocaleFree( path ); free( path );
return -1; return -1;
} }
LocaleFree( path ); free( path );
*p_handle = handle; *p_handle = handle;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment