MCPcopy Create free account
hub / github.com/MusicPlayerDaemon/MPD / LoadPlaylistFileInfo

Function LoadPlaylistFileInfo

src/PlaylistFile.cxx:110–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110static bool
111LoadPlaylistFileInfo(PlaylistInfo &info,
112 const Path parent_path_fs,
113 const Path name_fs)
114{
115 if (name_fs.HasNewline())
116 return false;
117
118 const auto *const name_fs_str = name_fs.c_str();
119 const auto *const name_fs_end =
120 FindStringSuffix(name_fs_str,
121 PATH_LITERAL(PLAYLIST_FILE_SUFFIX));
122 if (name_fs_end == nullptr ||
123 /* no empty playlist names (raw file name = ".m3u") */
124 name_fs_end == name_fs_str)
125 return false;
126
127 FileInfo fi;
128 if (!GetFileInfo(parent_path_fs / name_fs, fi) ||
129 !fi.IsRegular())
130 return false;
131
132 const auto name = AllocatedPath::FromFS(name_fs_str, name_fs_end);
133
134 try {
135 info.name = name.ToUTF8Throw();
136 } catch (...) {
137 return false;
138 }
139
140 info.mtime = fi.GetModificationTime();
141 return true;
142}
143
144PlaylistVector
145ListPlaylistFiles()

Callers 1

ListPlaylistFilesFunction · 0.85

Calls 2

ToUTF8ThrowMethod · 0.80
FindStringSuffixFunction · 0.50

Tested by

no test coverage detected