2

I'm writing a C++ windows program that ends up writing a bunch of directories and sub directories. The code is running exactly how I want it to.

However, I'm hitting a point where I've created a bunch of sub directories and the path is too long when I try to either write or make another sub directory and it crashes.

Q: Is there a way around this (like linux directory pointers) for windows?

Some of the code that writes the folders and files:

path = path + "\\" + s.name.substr(0,s.name.size()-2);
mkdir(path.c_str());
//Write current file to folder anyway
writeToFile(opendir(path.c_str()), ss);

The code is just going through the above over and over again to create a semi map/tree using folders and files.

Neppinger
  • 148
  • 1
  • 2
  • 16
  • There is `dirent.h` port for windows. You can use that. Are you using windows API? Showing a couple of lines of code won't hurt and it might help understand the problem better. – tozka Mar 18 '13 at 14:08

1 Answers1

3

You can use subst to create a mapping between a drive name and a directory:

subst x: c:\path\to\resource\directory

This isn't particularly scalable, but might be good enough.

You could also try sharing the folder and then using that name relative to the machine.

These are both hacks, in my opinion.

Peter Wood
  • 23,859
  • 5
  • 60
  • 99