• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

C++ Boost Filesystem

Status
Not open for further replies.
Level 4
Joined
Jan 4, 2006
Messages
60
Hello, I'm working on a school project, and I'm so lost i can't even figure out how to start it.

What I'm trying to start off with is just a simple console application that gets these settings: program.exe [switch] [path] [filespec].

how can i accomplish this?

This is what i have at the moment, it was intended for files so that's why i believe this doesn't work.

Also check out the attachment for the project description.

Code:
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
namespace fs = boost::filesystem;

#include <boost/regex.hpp>

int main(int argc, char *argv[])
{
	if (argc != 4)
	{
		cout << "Usage: program.exe [switchs] [path] [filespec]" << endl;
	}
	else
	{
		istream switchs(argv[1]);
		istream path(argv[2]);
		istream filespec(argv[3]);

		string testSwitch = switchs;
	}
 

Attachments

  • Project 3 C++.zip
    11.8 KB · Views: 60
Level 15
Joined
Nov 1, 2004
Messages
1,058
If you want to capture the program arguments, they are stored in argv[].

For example
Code:
int main(int argc, char *argv[])
{
	if (argc != 4)
	{
		cout << "Usage: program.exe [switchs] [path] [filespec]" << endl;
		return 1; // Exit here.  We don't have the arguments so we cannot proceed.
	}
	else
	{
		// argv[0] contains the name of this program (ex: program.exe)
		string s_switchs(argv[1]);
		string s_path(argv[2]);
		string s_filespec(argv[3]);
	}

	// The rest of the program goes here....
	// You can use the strings s_switchs, s_path, and s_filespec now.

	return 0;
}
 
Level 4
Joined
Jan 4, 2006
Messages
60
Ok lets take it one step father now.... combine path and file spec.... so it should just be 3 args total and something like C:\, (B|b)ill (, separates the 2) take into consideration of white space between the , (so ' , ' ',' ' ,' ', ') will all work
 
Status
Not open for further replies.
Top