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
2bb751d9
Commit
2bb751d9
authored
Feb 02, 2013
by
Denis Krjuchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
StateFile: use file system API, log in UTF-8
parent
3b620112
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
11 deletions
+16
-11
Main.cxx
src/Main.cxx
+4
-3
StateFile.cxx
src/StateFile.cxx
+9
-7
StateFile.hxx
src/StateFile.hxx
+3
-1
No files found.
src/Main.cxx
View file @
2bb751d9
...
@@ -243,16 +243,17 @@ glue_state_file_init(GError **error_r)
...
@@ -243,16 +243,17 @@ glue_state_file_init(GError **error_r)
Path
path_fs
=
Path
::
FromUTF8
(
path
);
Path
path_fs
=
Path
::
FromUTF8
(
path
);
g_free
(
path
);
if
(
path_fs
.
IsNull
())
{
if
(
path_fs
.
IsNull
())
{
g_free
(
path
);
g_set_error
(
error_r
,
main_quark
(),
0
,
g_set_error
(
error_r
,
main_quark
(),
0
,
"Failed to convert state file path to FS encoding"
);
"Failed to convert state file path to FS encoding"
);
return
false
;
return
false
;
}
}
state_file
=
new
StateFile
(
std
::
move
(
path_fs
),
state_file
=
new
StateFile
(
std
::
move
(
path_fs
),
path
,
*
global_partition
,
*
main_loop
);
*
global_partition
,
*
main_loop
);
g_free
(
path
);
state_file
->
Read
();
state_file
->
Read
();
return
true
;
return
true
;
}
}
...
...
src/StateFile.cxx
View file @
2bb751d9
...
@@ -34,8 +34,10 @@
...
@@ -34,8 +34,10 @@
#undef G_LOG_DOMAIN
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "state_file"
#define G_LOG_DOMAIN "state_file"
StateFile
::
StateFile
(
Path
&&
_path
,
Partition
&
_partition
,
EventLoop
&
_loop
)
StateFile
::
StateFile
(
Path
&&
_path
,
const
char
*
_path_utf8
,
:
TimeoutMonitor
(
_loop
),
path
(
std
::
move
(
_path
)),
partition
(
_partition
),
Partition
&
_partition
,
EventLoop
&
_loop
)
:
TimeoutMonitor
(
_loop
),
path
(
std
::
move
(
_path
)),
path_utf8
(
_path_utf8
),
partition
(
_partition
),
prev_volume_version
(
0
),
prev_output_version
(
0
),
prev_volume_version
(
0
),
prev_output_version
(
0
),
prev_playlist_version
(
0
)
prev_playlist_version
(
0
)
{
{
...
@@ -45,12 +47,12 @@ StateFile::StateFile(Path &&_path, Partition &_partition, EventLoop &_loop)
...
@@ -45,12 +47,12 @@ StateFile::StateFile(Path &&_path, Partition &_partition, EventLoop &_loop)
void
void
StateFile
::
Write
()
StateFile
::
Write
()
{
{
g_debug
(
"Saving state file %s"
,
path
.
c_str
());
g_debug
(
"Saving state file %s"
,
path
_utf8
.
c_str
());
FILE
*
fp
=
fopen
(
path
.
c_str
(),
"w"
);
FILE
*
fp
=
FOpen
(
path
,
FOpenMode
::
WriteText
);
if
(
G_UNLIKELY
(
!
fp
))
{
if
(
G_UNLIKELY
(
!
fp
))
{
g_warning
(
"failed to create %s: %s"
,
g_warning
(
"failed to create %s: %s"
,
path
.
c_str
(),
g_strerror
(
errno
));
path
_utf8
.
c_str
(),
g_strerror
(
errno
));
return
;
return
;
}
}
...
@@ -71,12 +73,12 @@ StateFile::Read()
...
@@ -71,12 +73,12 @@ StateFile::Read()
{
{
bool
success
;
bool
success
;
g_debug
(
"Loading state file %s"
,
path
.
c_str
());
g_debug
(
"Loading state file %s"
,
path
_utf8
.
c_str
());
TextFile
file
(
path
);
TextFile
file
(
path
);
if
(
file
.
HasFailed
())
{
if
(
file
.
HasFailed
())
{
g_warning
(
"failed to open %s: %s"
,
g_warning
(
"failed to open %s: %s"
,
path
.
c_str
(),
g_strerror
(
errno
));
path
_utf8
.
c_str
(),
g_strerror
(
errno
));
return
;
return
;
}
}
...
...
src/StateFile.hxx
View file @
2bb751d9
...
@@ -30,6 +30,7 @@ struct Partition;
...
@@ -30,6 +30,7 @@ struct Partition;
class
StateFile
final
:
private
TimeoutMonitor
{
class
StateFile
final
:
private
TimeoutMonitor
{
Path
path
;
Path
path
;
std
::
string
path_utf8
;
Partition
&
partition
;
Partition
&
partition
;
...
@@ -41,7 +42,8 @@ class StateFile final : private TimeoutMonitor {
...
@@ -41,7 +42,8 @@ class StateFile final : private TimeoutMonitor {
prev_playlist_version
;
prev_playlist_version
;
public
:
public
:
StateFile
(
Path
&&
path
,
Partition
&
partition
,
EventLoop
&
loop
);
StateFile
(
Path
&&
path
,
const
char
*
path_utf8
,
Partition
&
partition
,
EventLoop
&
loop
);
void
Read
();
void
Read
();
void
Write
();
void
Write
();
...
...
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