aboutsummaryrefslogtreecommitdiff
path: root/Src/Winamp/M3u.cpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Winamp/M3u.cpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/Winamp/M3u.cpp')
-rw-r--r--Src/Winamp/M3u.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/Src/Winamp/M3u.cpp b/Src/Winamp/M3u.cpp
new file mode 100644
index 00000000..0eab2567
--- /dev/null
+++ b/Src/Winamp/M3u.cpp
@@ -0,0 +1,73 @@
+/** (c) Nullsoft, Inc. C O N F I D E N T I A L
+ ** Filename:
+ ** Project:
+ ** Description:
+ ** Author:
+ ** Created:
+ **/
+#include "Main.h"
+#include "strutil.h"
+#include "api.h"
+#include "WinampPlaylist.h"
+#include "../nu/AUtoWide.h"
+#include "../nu/AUtoChar.h"
+
+#include "../WAT/WAT.h"
+
+int savem3ufn(const wchar_t *filename, int rel, int useBase)
+{
+ UINT conv=CP_ACP;
+ if (!lstrcmpiW(PathFindExtensionW(filename), L".m3u8"))
+ conv=CP_UTF8;
+ FILE *fp = 0;
+ int ext = 1;
+ int pos = PlayList_getPosition();
+ fp = _wfopen(filename, L"wt");
+ if (!fp) return -1;
+ if (conv==CP_UTF8)
+ fputs("\xEF\xBB\xBF", fp); // write UTF-8 BOM
+ if (ext) fprintf(fp, "#EXTM3U\n");
+ PlayList_setposition(0);
+ if (PlayList_getlength()) for (;;)
+ {
+ if ( !PlayList_gethidden(PlayList_getPosition())
+ && !PlayList_hasanycurtain(PlayList_getPosition())
+ )
+ {
+ wchar_t fnbuf[FILENAME_SIZE] = {0};
+ wchar_t ftbuf[FILETITLE_SIZE] = {0};
+ PlayList_getitem2W(PlayList_getPosition(), fnbuf, ftbuf);
+ int len = PlayList_getcurrentlength();
+ if (rel)
+ {
+ PlayList_makerelative(filename, fnbuf, useBase);
+ if (fnbuf[0]=='#') // woops, can't start a line with #
+ PlayList_getitem2W(PlayList_getPosition(), fnbuf, 0); // retrieve file name again
+ }
+
+
+ if ( ext && PlayList_getcached( PlayList_getPosition() ) )
+ {
+ const char *l_ext_inf = PlayList_getExtInf( PlayList_getPosition() );
+
+ wa::strings::wa_string l_filename( fnbuf );
+
+ if ( ext && l_ext_inf && *l_ext_inf && l_filename.contains( "://" ) )
+ {
+ fprintf( fp, "#EXTINF:%d%s,%s\n%s\n", len, l_ext_inf, (char *)AutoChar( ftbuf, conv ), (char *)AutoChar( fnbuf, conv ) );
+
+ delete( l_ext_inf );
+ }
+ else
+ fprintf( fp, "#EXTINF:%d,%s\n%s\n", len, (char *)AutoChar( ftbuf, conv ), (char *)AutoChar( fnbuf, conv ) );
+ }
+ else
+ fprintf(fp, "%s\n", (char *)AutoChar(fnbuf, conv));
+ }
+ if (PlayList_advance(1) < 0)
+ break;
+ }
+ fclose(fp);
+ PlayList_setposition(pos);
+ return 0;
+}