Fixed issues with playlists directory, and added warning messages.

This commit is contained in:
Pieter Hulshoff 2016-05-11 14:22:54 +02:00
parent 4e2cc30cc0
commit 11c04d6fbc

View File

@ -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<Item *> *saveitems = playlists["favorites"];