Code::Blocks Forums

User forums => Help => Topic started by: Xogue on October 08, 2009, 07:39:04 pm

Title: Fairly new to C++ ..... file permissions.
Post by: Xogue on October 08, 2009, 07:39:04 pm
kinda new to C++   and the forums, so if i mess something up, let me and and i will fix it next time.

but here goes the problem:

i wrote a program that will accept a file path, determined by the user, read each line, and make a new folder in another user defined location.
one folder per line from the text file. the program works just fine, as long as both user defined locations are in unprotected folders (i.e... user folders). id like to know if there is a way to give the program read/write permissions so this wont be a problem. even if i have to prompt the user to allow the program to do so.

here is the code:

#include <iostream>
#include <fstream>
#include <direct.h>
#include <string>

using namespace std;

string filename;
string path;
string name;
string startpath;
fstream file;

int main()
{
cout << "Enter the file path of your text file:";
getline (cin, filename);
cout << "Enter the path that you would like the folders to be created:";
getline (cin, startpath);
ifstream file (filename.c_str());
do {
getline (file, name);
path=startpath + name;
mkdir (path.c_str());}
while (name != "");
cin.ignore();
return 0;
}
Title: Re: Fairly new to C++ ..... file permissions.
Post by: MortenMacFly on October 08, 2009, 08:37:24 pm
kinda new to C++   and the forums, so if i mess something up, let me and and i will fix it next time.
Sorry, wrong forum. Here only discussions related to the Code::Blocks IDE are allowed. Please try a C/C++ programming forum. topic locked.