(Android) Added creation of .nomedia files in the themes and downloaded_media directories

This commit is contained in:
Leon Styhre 2024-01-31 21:03:28 +01:00
parent 1385b09c39
commit 0af45b03e3
3 changed files with 55 additions and 0 deletions

View file

@ -895,6 +895,17 @@ std::string MiximageGenerator::getSavePath() const
if (!Utils::FileSystem::exists(path))
Utils::FileSystem::createDirectory(path);
#if defined(__ANDROID__)
if (!Utils::FileSystem::exists(path + ".nomedia")) {
LOG(LogInfo) << "Creating \"no media\" file \"" << path + ".nomedia"
<< "\"...";
Utils::FileSystem::createEmptyFile(path + ".nomedia");
if (!Utils::FileSystem::exists(path + ".nomedia")) {
LOG(LogWarning) << "Couldn't create file, permission problems?";
}
}
#endif
path += mGame->getSystemName() + "/miximages" + subFolders + "/";
if (!Utils::FileSystem::exists(path))

View file

@ -796,6 +796,14 @@ int main(int argc, char* argv[])
LOG(LogWarning) << "Couldn't create directory, permission problems?";
}
}
if (!Utils::FileSystem::exists(themeDir + "/.nomedia")) {
LOG(LogInfo) << "Creating \"no media\" file \"" << themeDir + "/.nomedia"
<< "\"...";
Utils::FileSystem::createEmptyFile(themeDir + "/.nomedia");
if (!Utils::FileSystem::exists(themeDir + "/.nomedia")) {
LOG(LogWarning) << "Couldn't create file, permission problems?";
}
}
#else
// Create the themes folder in the application data directory (or elsewhere if the
// UserThemeDirectory setting has been defined).
@ -821,6 +829,21 @@ int main(int argc, char* argv[])
#endif
}
{
#if defined(__ANDROID__)
const std::string mediaDirectory {FileData::getMediaDirectory()};
if (Utils::FileSystem::exists(mediaDirectory))
if (!Utils::FileSystem::exists(mediaDirectory + ".nomedia")) {
LOG(LogInfo) << "Creating \"no media\" file \"" << mediaDirectory + ".nomedia"
<< "\"...";
Utils::FileSystem::createEmptyFile(mediaDirectory + ".nomedia");
if (!Utils::FileSystem::exists(mediaDirectory + ".nomedia")) {
LOG(LogWarning) << "Couldn't create file, permission problems?";
}
}
#endif
}
{
// Create the scripts folder in the application data directory. This is only required
// for custom event scripts so it's also created as a convenience.
@ -847,6 +870,16 @@ int main(int argc, char* argv[])
LOG(LogWarning) << "Couldn't create directory, permission problems?";
}
}
#if defined(__ANDROID__)
if (!Utils::FileSystem::exists(screensaversDir + "/.nomedia")) {
LOG(LogInfo) << "Creating \"no media\" file \"" << screensaversDir + "/.nomedia"
<< "\"...";
Utils::FileSystem::createEmptyFile(screensaversDir + "/.nomedia");
if (!Utils::FileSystem::exists(screensaversDir + "/.nomedia")) {
LOG(LogWarning) << "Couldn't create file, permission problems?";
}
}
#endif
if (!Utils::FileSystem::exists(slideshowDir)) {
LOG(LogInfo) << "Creating custom_slideshow directory \"" << slideshowDir << "\"...";
Utils::FileSystem::createDirectory(slideshowDir);

View file

@ -714,6 +714,17 @@ std::string getSaveAsPath(const ScraperSearchParams& params,
if (!Utils::FileSystem::exists(path))
Utils::FileSystem::createDirectory(path);
#if defined(__ANDROID__)
if (!Utils::FileSystem::exists(path + ".nomedia")) {
LOG(LogInfo) << "Creating \"no media\" file \"" << path + ".nomedia"
<< "\"...";
Utils::FileSystem::createEmptyFile(path + ".nomedia");
if (!Utils::FileSystem::exists(path + ".nomedia")) {
LOG(LogWarning) << "Couldn't create file, permission problems?";
}
}
#endif
path.append(systemsubdirectory)
.append("/")
.append(filetypeSubdirectory)