From 11c04d6fbc27ec1f2bd4329012925b3e7459af95 Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Wed, 11 May 2016 14:22:54 +0200 Subject: [PATCH] Fixed issues with playlists directory, and added warning messages. --- RetroFE/Source/Collection/CollectionInfo.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/RetroFE/Source/Collection/CollectionInfo.cpp b/RetroFE/Source/Collection/CollectionInfo.cpp index 725c767..45ce6b9 100644 --- a/RetroFE/Source/Collection/CollectionInfo.cpp +++ b/RetroFE/Source/Collection/CollectionInfo.cpp @@ -92,14 +92,14 @@ bool CollectionInfo::Save() { // Create playlists directory if it does not exist yet. struct stat info; - if ( stat( dir.c_str(), &info ) != 0 && (info.st_mode & S_IFDIR) ) + if ( stat( dir.c_str(), &info ) != 0 ) { #if defined(_WIN32) && !defined(__GNUC__) if(!CreateDirectory(dir, NULL)) { if(ERROR_ALREADY_EXISTS != GetLastError()) { - std::cout << "Could not create folder \"" << *it << "\"" << std::endl; + Logger::write(Logger::ZONE_WARNING, "Collection", "Could not create directory " + dir); return false; } } @@ -110,10 +110,16 @@ bool CollectionInfo::Save() if(mkdir(dir.c_str(), 0755) == -1) #endif { - std::cout << "Could not create folder \"" << dir << "\":" << errno << std::endl; + Logger::write(Logger::ZONE_WARNING, "Collection", "Could not create directory " + dir); + return false; } #endif } + else if ( !(info.st_mode & S_IFDIR) ) + { + Logger::write(Logger::ZONE_WARNING, "Collection", dir + " exists, but is not a directory."); + return false; + } filestream.open(file.c_str()); std::vector *saveitems = playlists["favorites"];