asdf
asdf

Reputation: 1475

linux path in fstream

i try to create a new file and save it in a subdirectory of the current folder ON LINUX

the path(convert) should look something like markus/123456 where markus is an (existing) subdirectory and 123456 is the non existing file

the strange thing is: it works when i dont use a subdirectory to say it short:

"123456" works and makes a file in the current directory

"markus/123456" dont works and does nothing at all...

ofstream handle;
string convert = "1234";
convert=name +"/"+ convert;
cout << convert<< endl;
handle.open(convert.c_str(),ios::out); // dont works with subdirectory in string
handle<<message;
handle.close();

NOTICE: I am using linux not windows. I need a solution for linux (3.0.0-12-generic-pae).

EDIT: Thx to one of the commends i found out its proberply a right problem. I post the code how i created the folder:

user::user(string aaa)
{
    name=aaa;
    mkdir(name.c_str(),0600);

}

NOTICE: I also tried it with 0666 without sucess. Still dont know how to do it right

Upvotes: 0

Views: 1327

Answers (1)

Robᵩ
Robᵩ

Reputation: 168646

mkdir(name.c_str(),0600);

This is wrong. Try

mkdir(name.c_str(), 0700);

Upvotes: 1

Related Questions