aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenis Krjuchkov <denis@crazydev.net>2013-02-02 20:25:13 +0600
committerDenis Krjuchkov <denis@crazydev.net>2013-02-02 20:52:02 +0600
commit99526219b7b882060e44408eafd7cb69d8761fd9 (patch)
tree3f8befb95ff20b9096e1c90f2c942081932b3d92 /src
parentd818b618af8b50d5a04a47cc0032c8f8c5d2bb02 (diff)
downloadmpd-99526219b7b882060e44408eafd7cb69d8761fd9.tar.gz
mpd-99526219b7b882060e44408eafd7cb69d8761fd9.tar.xz
mpd-99526219b7b882060e44408eafd7cb69d8761fd9.zip
UpdateIO.cxx: use file system API, log in UTF-8
Diffstat (limited to 'src')
-rw-r--r--src/UpdateIO.cxx29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/UpdateIO.cxx b/src/UpdateIO.cxx
index bd5fef69c..7e262555c 100644
--- a/src/UpdateIO.cxx
+++ b/src/UpdateIO.cxx
@@ -36,12 +36,15 @@ stat_directory(const Directory *directory, struct stat *st)
if (path_fs.IsNull())
return -1;
- int ret = stat(path_fs.c_str(), st);
- if (ret < 0)
+ if (!StatFile(path_fs, *st)) {
+ int error = errno;
+ const std::string path_utf8 = path_fs.ToUTF8();
g_warning("Failed to stat %s: %s",
- path_fs.c_str(), g_strerror(errno));
+ path_utf8.c_str(), g_strerror(error));
+ return -1;
+ }
- return ret;
+ return 0;
}
int
@@ -52,12 +55,15 @@ stat_directory_child(const Directory *parent, const char *name,
if (path_fs.IsNull())
return -1;
- int ret = stat(path_fs.c_str(), st);
- if (ret < 0)
+ if (!StatFile(path_fs, *st)) {
+ int error = errno;
+ const std::string path_utf8 = path_fs.ToUTF8();
g_warning("Failed to stat %s: %s",
- path_fs.c_str(), g_strerror(errno));
+ path_utf8.c_str(), g_strerror(error));
+ return -1;
+ }
- return ret;
+ return 0;
}
bool
@@ -82,8 +88,7 @@ directory_child_is_regular(const Directory *directory,
if (path_fs.IsNull())
return false;
- struct stat st;
- return stat(path_fs.c_str(), &st) == 0 && S_ISREG(st.st_mode);
+ return FileExists(path_fs);
}
bool
@@ -91,7 +96,7 @@ directory_child_access(const Directory *directory,
const char *name, int mode)
{
#ifdef WIN32
- /* access() is useless on WIN32 */
+ /* CheckAccess() is useless on WIN32 */
(void)directory;
(void)name;
(void)mode;
@@ -103,6 +108,6 @@ directory_child_access(const Directory *directory,
problem */
return true;
- return access(path.c_str(), mode) == 0 || errno != EACCES;
+ return CheckAccess(path, mode) || errno != EACCES;
#endif
}