code for *.mp3 masking stuff

This is a discussion on code for *.mp3 masking stuff within the C++ Programming forums, part of the General Programming Boards category; You know when you search for a file using something like *.mp3 or whatever, does anyone have any code that ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    552

    code for *.mp3 masking stuff

    You know when you search for a file using something like *.mp3 or whatever, does anyone have any code that will determine if a particular string matches a particular mask?
    C Code. C Code Run. Run Code Run... Please!

    "Love is like a blackhole, you fall into it... then you get ripped apart"

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    This is (presumably) OS specific. You'll need to tell us what OS you're using...
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    Im using Windows...
    C Code. C Code Run. Run Code Run... Please!

    "Love is like a blackhole, you fall into it... then you get ripped apart"

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    Hmmm, not quite what I had in mind. More like this...

    Code:
    string fname = "Eine Kleine Nachtmusik.mp3", mask = "*ee*ven*.mp?";
    if (DoesFilenameMatchMask(fname, mask))
      cout << "We have a match" << endl;
    else
      cout << "No match" << endl;
    Basically I need an implementation for 'DoesFilenameMatchMask'. I'd write one myself but im kinda busy with other stuff right now and its implementation seemed like it would be kinda involved.
    C Code. C Code Run. Run Code Run... Please!

    "Love is like a blackhole, you fall into it... then you get ripped apart"

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    Unfortunately none of those pages seemed to actually have the source code on them... so I ended up writing my own

    Here it is if anyone wants it. If anyone has a more efficient implementation i'd like to see it

    Code:
    bool MatchMask(const char *str, const char *mask)
    {
      char c;
      const char *p;
    
      while (*mask) {
        c = *mask++;
    
        if (c == '*') {
          while (*mask == '*' && *mask)
            mask++;
    
          if (*mask) {
            p = str;
            while (*p) {
              while (*p && *p != *mask)
                p++;
              if (MatchMask(p, mask)) return true;
              p++;
            }
          }
          else
            return true;
        }
        else if (c == '?') {
          if (!*str)
            return false;
        }
        else if (c != *str) {
          return false;
        }
        str++;
      }
      return !*mask && !*str;
    }
    C Code. C Code Run. Run Code Run... Please!

    "Love is like a blackhole, you fall into it... then you get ripped apart"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Proposal: Code colouring
    By Perspective in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 05-14-2007, 08:23 AM
  2. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 11:20 AM
  3. Explain this C code in english
    By soadlink in forum C Programming
    Replies: 16
    Last Post: 08-31-2006, 01:48 AM
  4. Replies: 1
    Last Post: 03-21-2006, 07:52 AM
  5. Seems like correct code, but results are not right...
    By OmniMirror in forum C Programming
    Replies: 4
    Last Post: 02-13-2003, 01:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21