I made a small patch for mpmf20 so that you can refer to the playlist number of
a song instead of it's name when deleting or downloading files. This is
especially useful when the name of a song is longer than what's displayed with
mpmf20 -d...

This is my first attempt on programming C/C++, so please point it out if I did
anything stupid. I'm not sure if I used diff correctly either :)

Known bugs: Can behave unexpectantly if you have a file on the MPMan with a
numeric name. I don't consider this a problem - if you do, you fix it :)


--- Start diff

diff -u mpmf20/mpmf20.cpp mpmf20new/mpmf20.cpp
--- mpmf20/mpmf20.cpp   Mon Apr 12 15:49:40 1999
+++ mpmf20new/mpmf20.cpp        Mon Sep  6 10:54:32 1999
@@ -4,6 +4,7 @@
 //
 ///////////////////////////////////////////////////////////////////////////////
 #include       <stdio.h>
+#include       <stdlib.h>
 #include       <string.h>
 #include       <stdarg.h>
 #include       <time.h>
@@ -696,13 +697,21 @@
 
 CDirEntry* CMPMF20::FindFile( char* pszFile )
 {
+
+        // set iFileNumber from pszFile
+        signed int iFileNumber;
+       if (!(iFileNumber = atoi(pszFile)))
+               iFileNumber = -1;
        // search directory entries for matching filename
        int iCountEntry = m_cDir.m_iCountEntry;
        CDirEntry* pDirEntry = m_cDir.m_acDirEntry;
        for( int iA=0; iA<iCountEntry; ++iA, ++pDirEntry )
        {
-               if ( !strcmp(pszFile, pDirEntry->m_szName) )
-                       return pDirEntry;
+               if ( !strcmp(pszFile, pDirEntry->m_szName) || iA+1 == iFileNumber )
+               {
+                       sprintf(pszFile, "%s", pDirEntry->m_szName); 
+                       return pDirEntry; 
+               }
        }
 
        return NULL;

--- End diff

--
%japh = (
 'name' => 'Niklas Nordebo',    'mail'  => '[EMAIL PROTECTED]',
 'work' => 'www.pipe-dd.com',   'phone' => '+46-708-444705'
);

Reply via email to