Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Иван Мажукин
mpd
Commits
ce925ba5
Commit
ce925ba5
authored
Feb 17, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/Charset: disable if GLib is disabled
parent
4ad14f6a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
2 deletions
+31
-2
AllocatedPath.cxx
src/fs/AllocatedPath.cxx
+10
-0
Charset.cxx
src/fs/Charset.cxx
+17
-0
Config.cxx
src/fs/Config.cxx
+4
-2
No files found.
src/fs/AllocatedPath.cxx
View file @
ce925ba5
...
@@ -24,22 +24,32 @@
...
@@ -24,22 +24,32 @@
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "Compiler.h"
#include "Compiler.h"
#ifdef HAVE_GLIB
#include <glib.h>
#include <glib.h>
#endif
#include <string.h>
#include <string.h>
#ifdef HAVE_GLIB
inline
AllocatedPath
::
AllocatedPath
(
Donate
,
pointer
_value
)
inline
AllocatedPath
::
AllocatedPath
(
Donate
,
pointer
_value
)
:
value
(
_value
)
{
:
value
(
_value
)
{
g_free
(
_value
);
g_free
(
_value
);
}
}
#endif
/* no inlining, please */
/* no inlining, please */
AllocatedPath
::~
AllocatedPath
()
{}
AllocatedPath
::~
AllocatedPath
()
{}
AllocatedPath
AllocatedPath
AllocatedPath
::
FromUTF8
(
const
char
*
path_utf8
)
AllocatedPath
::
FromUTF8
(
const
char
*
path_utf8
)
{
{
#ifdef HAVE_GLIB
return
AllocatedPath
(
Donate
(),
::
PathFromUTF8
(
path_utf8
));
return
AllocatedPath
(
Donate
(),
::
PathFromUTF8
(
path_utf8
));
#else
return
FromFS
(
path_utf8
);
#endif
}
}
AllocatedPath
AllocatedPath
...
...
src/fs/Charset.cxx
View file @
ce925ba5
...
@@ -25,7 +25,9 @@
...
@@ -25,7 +25,9 @@
#include "Log.hxx"
#include "Log.hxx"
#include "Traits.hxx"
#include "Traits.hxx"
#ifdef HAVE_GLIB
#include <glib.h>
#include <glib.h>
#endif
#include <algorithm>
#include <algorithm>
...
@@ -42,6 +44,7 @@
...
@@ -42,6 +44,7 @@
*/
*/
static
constexpr
size_t
MPD_PATH_MAX_UTF8
=
(
MPD_PATH_MAX
-
1
)
*
4
+
1
;
static
constexpr
size_t
MPD_PATH_MAX_UTF8
=
(
MPD_PATH_MAX
-
1
)
*
4
+
1
;
#ifdef HAVE_GLIB
static
std
::
string
fs_charset
;
static
std
::
string
fs_charset
;
gcc_pure
gcc_pure
...
@@ -71,10 +74,16 @@ SetFSCharset(const char *charset)
...
@@ -71,10 +74,16 @@ SetFSCharset(const char *charset)
"SetFSCharset: fs charset is: %s"
,
fs_charset
.
c_str
());
"SetFSCharset: fs charset is: %s"
,
fs_charset
.
c_str
());
}
}
#endif
const
char
*
const
char
*
GetFSCharset
()
GetFSCharset
()
{
{
#ifdef HAVE_GLIB
return
fs_charset
.
empty
()
?
"utf-8"
:
fs_charset
.
c_str
();
return
fs_charset
.
empty
()
?
"utf-8"
:
fs_charset
.
c_str
();
#else
return
"utf-8"
;
#endif
}
}
static
inline
void
FixSeparators
(
std
::
string
&
s
)
static
inline
void
FixSeparators
(
std
::
string
&
s
)
...
@@ -95,10 +104,13 @@ PathToUTF8(const char *path_fs)
...
@@ -95,10 +104,13 @@ PathToUTF8(const char *path_fs)
{
{
assert
(
path_fs
!=
nullptr
);
assert
(
path_fs
!=
nullptr
);
#ifdef HAVE_GLIB
if
(
fs_charset
.
empty
())
{
if
(
fs_charset
.
empty
())
{
#endif
auto
result
=
std
::
string
(
path_fs
);
auto
result
=
std
::
string
(
path_fs
);
FixSeparators
(
result
);
FixSeparators
(
result
);
return
result
;
return
result
;
#ifdef HAVE_GLIB
}
}
GIConv
conv
=
g_iconv_open
(
"utf-8"
,
fs_charset
.
c_str
());
GIConv
conv
=
g_iconv_open
(
"utf-8"
,
fs_charset
.
c_str
());
...
@@ -123,8 +135,11 @@ PathToUTF8(const char *path_fs)
...
@@ -123,8 +135,11 @@ PathToUTF8(const char *path_fs)
auto
result_path
=
std
::
string
(
path_utf8
,
sizeof
(
path_utf8
)
-
out_left
);
auto
result_path
=
std
::
string
(
path_utf8
,
sizeof
(
path_utf8
)
-
out_left
);
FixSeparators
(
result_path
);
FixSeparators
(
result_path
);
return
result_path
;
return
result_path
;
#endif
}
}
#ifdef HAVE_GLIB
char
*
char
*
PathFromUTF8
(
const
char
*
path_utf8
)
PathFromUTF8
(
const
char
*
path_utf8
)
{
{
...
@@ -137,3 +152,5 @@ PathFromUTF8(const char *path_utf8)
...
@@ -137,3 +152,5 @@ PathFromUTF8(const char *path_utf8)
fs_charset
.
c_str
(),
"utf-8"
,
fs_charset
.
c_str
(),
"utf-8"
,
nullptr
,
nullptr
,
nullptr
);
nullptr
,
nullptr
,
nullptr
);
}
}
#endif
src/fs/Config.cxx
View file @
ce925ba5
...
@@ -22,16 +22,17 @@
...
@@ -22,16 +22,17 @@
#include "Charset.hxx"
#include "Charset.hxx"
#include "config/ConfigGlobal.hxx"
#include "config/ConfigGlobal.hxx"
#include <glib.h>
#ifdef WIN32
#ifdef WIN32
#include <windows.h> // for GetACP()
#include <windows.h> // for GetACP()
#include <stdio.h> // for sprintf()
#include <stdio.h> // for sprintf()
#elif defined(HAVE_GLIB)
#include <glib.h>
#endif
#endif
void
void
ConfigureFS
()
ConfigureFS
()
{
{
#if defined(HAVE_GLIB) || defined(WIN32)
const
char
*
charset
=
nullptr
;
const
char
*
charset
=
nullptr
;
charset
=
config_get_string
(
CONF_FS_CHARSET
,
nullptr
);
charset
=
config_get_string
(
CONF_FS_CHARSET
,
nullptr
);
...
@@ -56,4 +57,5 @@ ConfigureFS()
...
@@ -56,4 +57,5 @@ ConfigureFS()
if
(
charset
!=
nullptr
)
if
(
charset
!=
nullptr
)
SetFSCharset
(
charset
);
SetFSCharset
(
charset
);
#endif
}
}
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