From 92d71cc7fa690def8d7e2a79690fce16750e97dc Mon Sep 17 00:00:00 2001 From: Denis Krjuchkov Date: Sat, 2 Feb 2013 20:21:10 +0600 Subject: PlaylistFile.cxx: use file system API --- src/PlaylistFile.cxx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx index f8d924de..a879f70a 100644 --- a/src/PlaylistFile.cxx +++ b/src/PlaylistFile.cxx @@ -211,7 +211,7 @@ SavePlaylistFile(const PlaylistFileContents &contents, const char *utf8path, if (path_fs.IsNull()) return false; - FILE *file = fopen(path_fs.c_str(), "w"); + FILE *file = FOpen(path_fs, FOpenMode::WriteText); if (file == NULL) { playlist_errno(error_r); return false; @@ -312,7 +312,7 @@ spl_clear(const char *utf8path, GError **error_r) if (path_fs.IsNull()) return false; - FILE *file = fopen(path_fs.c_str(), "w"); + FILE *file = FOpen(path_fs, FOpenMode::WriteText); if (file == NULL) { playlist_errno(error_r); return false; @@ -331,8 +331,7 @@ spl_delete(const char *name_utf8, GError **error_r) if (path_fs.IsNull()) return false; - int ret = unlink(path_fs.c_str()); - if (ret < 0) { + if (!RemoveFile(path_fs)) { playlist_errno(error_r); return false; } @@ -376,7 +375,7 @@ spl_append_song(const char *utf8path, struct song *song, GError **error_r) if (path_fs.IsNull()) return false; - FILE *file = fopen(path_fs.c_str(), "a"); + FILE *file = FOpen(path_fs, FOpenMode::AppendText); if (file == NULL) { playlist_errno(error_r); return false; @@ -446,7 +445,7 @@ spl_rename_internal(const Path &from_path_fs, const Path &to_path_fs, return false; } - if (rename(from_path_fs.c_str(), to_path_fs.c_str()) < 0) { + if (!RenameFile(from_path_fs, to_path_fs)) { playlist_errno(error_r); return false; } -- cgit v1.2.3