File Brower, boost filesysytems, get contents of my computer

I'm making a media player with a custom file browser using boost filesystems. But "My Computer" is not a directory. I need some way of either getting the directories in my computer, or I need to get the paths to all of the hard drives/removable storage devices on the system. Also I need to get the user name, so I can create a shortcut to places like C:/users/username/music.

Does anyone know how to do this?

Last edited on
But my computer is not a directory.
???

I need some way of either getting the directories in my computer
http://www.cplusplus.com/forum/general/68978/#msg370082

or I need to get the paths to all of the hard drives/removable storage devices on the system
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364972%28v=vs.85%29.aspx

Also I need to get the user name
Environment variable USERNAME.
MS Windows has the concept of a "location" that may or may not have representation in the hard disk drive. These locations are accessed by their special ID. This is a Windows-only thing so I doubt you'll find something to enumerate "My Computer" in portable libraries like Boost. But I have never used Boost before so I cannot categorically say so. Don't keep your hopes up, though.
I don't think boost can iterate through "my computer". Attempting to causes the program to crash.

Thanks kbw for msdn link.

The following from the other link looks a little strange.

1
2
3
4
5
6
7
8
9
10
11
12
if (boost::filesystem::is_regular_file(path))
	{
		static const std::string ext = ".mp3";

		std::string filename = path.string();
		if (filename.size() > ext.size() &&
		    stricmp(filename.c_str() + filename.size() - ext.size(), ext.c_str()) == 0)
		{
			files.push_back(path.string());
			return ++count;
		}
	}


The path class can do this,
1
2
if (path.ext() == ".mp3")
    files.push_back(path.string());


I iterate through directories like this.

1
2
3
4
5
6
7
8
9
10
11
12
13
vector <directory_entry> Temp;
vector <directory_entry> AudioFiles;
vector <directory_entry> Directories;

directory_entry Music("c://users//'username'//music");
copy(directory_iterator(Music), directory_iterator(), back_inserter(Temp));

for (int i=0; i < Temp.size(); ++i)
    if(is_directory(Temp[i]))
        Directories.push_back(Temp[i]);
    else if(is_reguar_file(Temp[i]))
        if(Temp.path().ext() == "wav" || Temp.path().ext() == "flac") //etc
            AudioFiles.push_back(Temp[i]);


And you can do this type of thing too.

1
2
//DE is a directory_entry
DE.path().string().c_str()
Last edited on
Topic archived. No new replies allowed.