Directory MP3 Search

This is a discussion on Directory MP3 Search within the Windows Programming forums, part of the Platform Specific Boards category; Hi guys, i've got myself in a bit of a jam. I'm in an 'intro to C++' class. My professor ...

  1. #1
    Young C n00b
    Join Date
    Jul 2006
    Posts
    59

    Directory MP3 Search

    Hi guys, i've got myself in a bit of a jam. I'm in an 'intro to C++' class. My professor is a first time teacher. He's a great programmer, but frankly, he sucks at teaching. He's already trying to teach us windows programming and not even one person in the class has an idea of what's going on (half of the class doesn't even know what a function is!!).

    We have a project due wednesday. The project is to develop an application that can search a windows directory (and subdirectories) for mp3s and display the paths of the mp3 files that are found.

    I'm not exactly sure how to go about doing this. The obvious solution would be to read read read, but I can't learn windows programming by wednesday.

    So my question is would anyone be willing to kind of walk me through designing an application like this? I'd imagine i'd need to write some type of recursive function to do the actual searching..

    How do I have windows go to a certain directory?
    How could I write a function that searches the current directory for an mp3 file?


    Thanks for any help, i'm really stuck on this.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,498
    Mmm, have you ever considered reading the FAQ?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Young C n00b
    Join Date
    Jul 2006
    Posts
    59
    I was asking for some one-to-one help, not a reference to an FAQ. Windows programming is far beyond my skill level so I wouldn't make good use of an FAQ. I'd need help from someone to explain it a little to me, or at least a detailed tutorial.

  4. #4
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    You don't need to use windows programming to find the file. As for the GUI, have you looked at the link at the top of the board?
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,498
    Reading files from the file system isn't a GUI problem.

    Displaying the filenames might be a GUI problem, depending on how you do it.

    You seemed to be lost on step 1, nevermind step 2.

    So post some actual code of what you can and cannot achieve if you want better answers in future.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Young C n00b
    Join Date
    Jul 2006
    Posts
    59
    this is what i've got so far. I'm currently only interested in programming option 1 of the menu.


    Code:
    #include "stdafx.h"
    #include <iostream>
    using std::cout;
    using std::endl;
    using std::cin;
    #include <string>
    using std::string;
    
    //prototypes
    void mainMenu();
    void inputDirectory();
    void undefined();
    
    
    //global data
    int menuSelection = 0;
    string directoryToSearch;
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    
    	mainMenu();
    	return 0;
    }
    
    void mainMenu()
    {
    system("cls");
    
    	cout << "\t\t\tWelcome to Kyle's MP3 Tool." << endl
    		 << "\t\tSelect a menu option  ( 1 - 4)" << endl
    		 << "\n\n\n(1) ~~> Scan a directory to build a playlist of MP3s" << endl
    		 << "(2) ~~> Filter playlist" << endl
    		 << "(3) ~~> Save a playlist of MP3s" << endl
    		 << "(4) ~~> Load a playlist of MP3s" << endl
    		 << "(5) ~~> Play a playlist of MP3s\n\n\n" << endl;
    
    	int x = 1;
    	while (x == 1)
    	{
    		cin >> menuSelection;
    
    		if (menuSelection >= 1 &&
    			menuSelection <= 5)
    			x = 0;
    		else 
    			cout << "Invalid menu selection. Try again." << endl;
    	} //end while loop
    
    	switch(menuSelection)
    	{
    	case 1:
    		inputDirectory();
    		break;
    	case 2:
    		undefined();
    		break;
    	case 3:
    		undefined();
    		break;
    	case 4:
    		undefined();
    		break;
    	case 5:
    		undefined();
    		break;
    	} //end switch statement
    
    } //end mainMenu
    
    
    void inputDirectory()
    {
    	cout << "Enter a directory to search. All subdirectories will also be searched." << endl
    		<< "Example:   C:\\Music\n" << endl;
    	cin >> directoryToSearch;
    	cout << "\nDirectory Entered: " << directoryToSearch << endl;
    }
    
    void undefined()
    {
    cout << "This function is under construction.\n" << endl;
    for(long stall = 0; stall < 350000000; stall++); //stalls the computer so the user can see the message
    
    mainMenu();
    }

  7. #7
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Can you deal with this code from the FAQ?

    Code:
    HANDLE          h;
    WIN32_FIND_DATA info;
    
    h = FindFirstFile("*.*", &info);
    if (h != INVALID_HANDLE_VALUE)
    {
        do
        {
            if (!(strcmp(info.cFileName, ".") == 0 || strcmp(info.cFileName, "..") == 0))
            {
                // do additional processing to see if file extension is .mp3 or something
            }
        } while (FindNextFile(h, &info));
        FindClose(h);
    }
    I didn't see you mention it, but manutd mentioned something about a GUI. Do you need one for this project?

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

  8. #8
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    I assumed by windows programming he meant he had to use a GUI Obviously not, but other than that, what "windows programming" would he have to do for this assignment?
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  9. #9
    Young C n00b
    Join Date
    Jul 2006
    Posts
    59
    ok i did some reading and i learned a bit about the WIN32_DATA_FIND.

    So what I'm guessing is that i'll have to declare an object of the WIN32_DATA_FIND structure, then call functions from it.

    What header files will I need to include?
    Where can I learn more about HANDLES?

  10. #10
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,498
    You can lead a horse to water, but you can't make him think.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  11. #11
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Quote Originally Posted by kwikness
    What header files will I need to include?
    Where can I learn more about HANDLES?
    msdn.microsoft.com
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  12. #12
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Where can I learn more about HANDLES?
    HANDLE, like any other windows data type (HWND, HINSTANCE, HBRUSH) is an int, but has been given such name, so you could easily recognize it in some piece of code.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  13. #13
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    has been given such name, so you could easily recognize it in some piece of code.
    Actually it gives a microsoft a possibility to change the int to some other type in the future, and no need to make changes in the code using windows API
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  14. #14
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    That too, but if that would be the only reason, the would've just made one APIINT or something.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  15. #15
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Quote Originally Posted by maxorator
    HANDLE, like any other windows data type (HWND, HINSTANCE, HBRUSH) is an int, but has been given such name, so you could easily recognize it in some piece of code.

    Is that a int, int32 or int64?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How can i check a directory for certain files?
    By patrioticpar883 in forum C++ Programming
    Replies: 13
    Last Post: 02-01-2008, 04:27 PM
  2. Finding files in a directory
    By smarta_982002 in forum C Programming
    Replies: 1
    Last Post: 01-25-2008, 09:10 AM
  3. Search For a Directory
    By IdioticCreation in forum C++ Programming
    Replies: 2
    Last Post: 06-03-2007, 02:53 PM
  4. Simple search program
    By colinuk in forum C Programming
    Replies: 6
    Last Post: 12-18-2004, 12:58 AM
  5. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM

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