mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-07-21 05:24:22 -04:00
Since a currently played file is deleted, the player goes to the next file from the list. A special case: if the deleted file is the last one, the playback stops (and can be resumed by the user).
27 lines
614 B
C++
27 lines
614 B
C++
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#pragma once
|
|
|
|
#include <log/log.hpp>
|
|
#include <sys/stat.h>
|
|
#include <cerrno>
|
|
#include <cstdio>
|
|
|
|
namespace
|
|
{
|
|
inline bool statFd(FILE *fd, char const *logMessage)
|
|
{
|
|
struct stat fdStats;
|
|
constexpr int statFailed = -1;
|
|
if (fstat(fileno(fd), &fdStats) != statFailed) {
|
|
return true;
|
|
}
|
|
|
|
auto originalErrno = errno;
|
|
LOG_WARN("%s", logMessage);
|
|
errno = originalErrno;
|
|
return false;
|
|
}
|
|
} // namespace
|