Commit 92d71cc7 authored by Denis Krjuchkov's avatar Denis Krjuchkov

PlaylistFile.cxx: use file system API

parent 227eca7d
...@@ -211,7 +211,7 @@ SavePlaylistFile(const PlaylistFileContents &contents, const char *utf8path, ...@@ -211,7 +211,7 @@ SavePlaylistFile(const PlaylistFileContents &contents, const char *utf8path,
if (path_fs.IsNull()) if (path_fs.IsNull())
return false; return false;
FILE *file = fopen(path_fs.c_str(), "w"); FILE *file = FOpen(path_fs, FOpenMode::WriteText);
if (file == NULL) { if (file == NULL) {
playlist_errno(error_r); playlist_errno(error_r);
return false; return false;
...@@ -312,7 +312,7 @@ spl_clear(const char *utf8path, GError **error_r) ...@@ -312,7 +312,7 @@ spl_clear(const char *utf8path, GError **error_r)
if (path_fs.IsNull()) if (path_fs.IsNull())
return false; return false;
FILE *file = fopen(path_fs.c_str(), "w"); FILE *file = FOpen(path_fs, FOpenMode::WriteText);
if (file == NULL) { if (file == NULL) {
playlist_errno(error_r); playlist_errno(error_r);
return false; return false;
...@@ -331,8 +331,7 @@ spl_delete(const char *name_utf8, GError **error_r) ...@@ -331,8 +331,7 @@ spl_delete(const char *name_utf8, GError **error_r)
if (path_fs.IsNull()) if (path_fs.IsNull())
return false; return false;
int ret = unlink(path_fs.c_str()); if (!RemoveFile(path_fs)) {
if (ret < 0) {
playlist_errno(error_r); playlist_errno(error_r);
return false; return false;
} }
...@@ -376,7 +375,7 @@ spl_append_song(const char *utf8path, struct song *song, GError **error_r) ...@@ -376,7 +375,7 @@ spl_append_song(const char *utf8path, struct song *song, GError **error_r)
if (path_fs.IsNull()) if (path_fs.IsNull())
return false; return false;
FILE *file = fopen(path_fs.c_str(), "a"); FILE *file = FOpen(path_fs, FOpenMode::AppendText);
if (file == NULL) { if (file == NULL) {
playlist_errno(error_r); playlist_errno(error_r);
return false; return false;
...@@ -446,7 +445,7 @@ spl_rename_internal(const Path &from_path_fs, const Path &to_path_fs, ...@@ -446,7 +445,7 @@ spl_rename_internal(const Path &from_path_fs, const Path &to_path_fs,
return false; 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); playlist_errno(error_r);
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment