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
a688745b
Commit
a688745b
authored
May 05, 2013
by
Denis Krjuchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ClientFile: use Path and file system API, update usages accordingly
This commit also fixes incorrect passing of UTF-8 strings to client_allow_file
parent
459d824c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
10 deletions
+36
-10
ClientFile.cxx
src/ClientFile.cxx
+4
-2
ClientFile.hxx
src/ClientFile.hxx
+2
-1
OtherCommands.cxx
src/OtherCommands.cxx
+9
-1
QueueCommands.cxx
src/QueueCommands.cxx
+21
-6
No files found.
src/ClientFile.cxx
View file @
a688745b
...
...
@@ -22,6 +22,8 @@
#include "Client.hxx"
#include "ack.h"
#include "io_error.h"
#include "fs/Path.hxx"
#include "fs/FileSystem.hxx"
#include <sys/stat.h>
#include <sys/types.h>
...
...
@@ -29,7 +31,7 @@
#include <unistd.h>
bool
client_allow_file
(
const
Client
*
client
,
const
char
*
path_fs
,
client_allow_file
(
const
Client
*
client
,
const
Path
&
path_fs
,
GError
**
error_r
)
{
#ifdef WIN32
...
...
@@ -54,7 +56,7 @@ client_allow_file(const Client *client, const char *path_fs,
}
struct
stat
st
;
if
(
stat
(
path_fs
,
&
st
)
<
0
)
{
if
(
!
StatFile
(
path_fs
,
st
)
)
{
set_error_errno
(
error_r
);
return
false
;
}
...
...
src/ClientFile.hxx
View file @
a688745b
...
...
@@ -25,6 +25,7 @@
#include <stdbool.h>
class
Client
;
class
Path
;
/**
* Is this client allowed to use the specified local file?
...
...
@@ -37,7 +38,7 @@ class Client;
* @return true if access is allowed
*/
bool
client_allow_file
(
const
Client
*
client
,
const
char
*
path_fs
,
client_allow_file
(
const
Client
*
client
,
const
Path
&
path_fs
,
GError
**
error_r
);
#endif
src/OtherCommands.cxx
View file @
a688745b
...
...
@@ -34,6 +34,7 @@
#include "ls.hxx"
#include "Volume.hxx"
#include "util/UriUtil.hxx"
#include "fs/Path.hxx"
extern
"C"
{
#include "stats.h"
...
...
@@ -117,9 +118,16 @@ handle_lsinfo(Client *client, int argc, char *argv[])
if
(
strncmp
(
uri
,
"file:///"
,
8
)
==
0
)
{
/* print information about an arbitrary local file */
const
char
*
path_utf8
=
uri
+
7
;
const
Path
path_fs
=
Path
::
FromUTF8
(
path_utf8
);
if
(
path_fs
.
IsNull
())
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"unsupported file name"
);
return
COMMAND_RETURN_ERROR
;
}
GError
*
error
=
NULL
;
if
(
!
client_allow_file
(
client
,
path_
utf8
,
&
error
))
if
(
!
client_allow_file
(
client
,
path_
fs
,
&
error
))
return
print_error
(
client
,
error
);
struct
song
*
song
=
song_file_load
(
path_utf8
,
NULL
);
...
...
src/QueueCommands.cxx
View file @
a688745b
...
...
@@ -32,6 +32,7 @@
#include "protocol/Result.hxx"
#include "ls.hxx"
#include "util/UriUtil.hxx"
#include "fs/Path.hxx"
#include <string.h>
...
...
@@ -42,13 +43,20 @@ handle_add(Client *client, G_GNUC_UNUSED int argc, char *argv[])
enum
playlist_result
result
;
if
(
strncmp
(
uri
,
"file:///"
,
8
)
==
0
)
{
const
char
*
path
=
uri
+
7
;
const
char
*
path_utf8
=
uri
+
7
;
const
Path
path_fs
=
Path
::
FromUTF8
(
path_utf8
);
if
(
path_fs
.
IsNull
())
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"unsupported file name"
);
return
COMMAND_RETURN_ERROR
;
}
GError
*
error
=
NULL
;
if
(
!
client_allow_file
(
client
,
path
,
&
error
))
if
(
!
client_allow_file
(
client
,
path
_fs
,
&
error
))
return
print_error
(
client
,
error
);
result
=
client
->
partition
.
AppendFile
(
path
);
result
=
client
->
partition
.
AppendFile
(
path
_utf8
);
return
print_playlist_result
(
client
,
result
);
}
...
...
@@ -78,13 +86,20 @@ handle_addid(Client *client, int argc, char *argv[])
enum
playlist_result
result
;
if
(
strncmp
(
uri
,
"file:///"
,
8
)
==
0
)
{
const
char
*
path
=
uri
+
7
;
const
char
*
path_utf8
=
uri
+
7
;
const
Path
path_fs
=
Path
::
FromUTF8
(
path_utf8
);
if
(
path_fs
.
IsNull
())
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"unsupported file name"
);
return
COMMAND_RETURN_ERROR
;
}
GError
*
error
=
NULL
;
if
(
!
client_allow_file
(
client
,
path
,
&
error
))
if
(
!
client_allow_file
(
client
,
path
_fs
,
&
error
))
return
print_error
(
client
,
error
);
result
=
client
->
partition
.
AppendFile
(
path
,
&
added_id
);
result
=
client
->
partition
.
AppendFile
(
path
_utf8
,
&
added_id
);
}
else
{
if
(
uri_has_scheme
(
uri
)
&&
!
uri_supported_scheme
(
uri
))
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
...
...
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