Author Topic: Fairly new to C++ ..... file permissions.  (Read 1929 times)

Xogue

  • Guest
Fairly new to C++ ..... file permissions.
« 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;
}

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9489
Re: Fairly new to C++ ..... file permissions.
« Reply #1 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ