Skip to content

Commit

Permalink
Set title meta data for FileStream
Browse files Browse the repository at this point in the history
  • Loading branch information
badaix committed Jan 7, 2024
1 parent cece838 commit 2b6774b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
12 changes: 3 additions & 9 deletions common/utils/file_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <unistd.h>
#endif

#include <filesystem>
#include <fstream>
#include <stdexcept>
#include <vector>
Expand All @@ -45,17 +46,10 @@ namespace file

static bool exists(const std::string& filename)
{
if (filename.empty())
return false;
#ifdef WINDOWS
DWORD dwAttrib = GetFileAttributes(filename.c_str());
return (dwAttrib != INVALID_FILE_ATTRIBUTES);
#else
struct stat buffer;
return (stat(filename.c_str(), &buffer) == 0);
#endif
return std::filesystem::exists(filename);
}


#ifndef WINDOWS
static void do_chown(const std::string& file_path, const std::string& user_name, const std::string& group_name)
{
Expand Down
7 changes: 7 additions & 0 deletions server/streamreader/file_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
// 3rd party headers

// standard headers
#include <filesystem>
#include <memory>


Expand All @@ -50,6 +51,12 @@ FileStream::FileStream(PcmStream::Listener* pcmListener, boost::asio::io_context
{
throw SnapException("Not a regular file: \"" + uri_.path + "\"");
}

Properties properties;
Metadata meta;
meta.title = std::filesystem::path(uri_.path).filename().replace_extension("");
properties.metadata = meta;
setProperties(properties);
}


Expand Down

0 comments on commit 2b6774b

Please sign in to comment.