Quote:
Originally Posted by
Corona688
Why not just append to the string instead of recreating every time?
There is nothing to recreate.
I m doing a sequence of
mkdir(dir);
chdir(dir)
for(subdir to create)
mkdir(subdir[i]);
chdir("..");
and so on, which in my case seems perfect, as I have to create a director hierarchy from a structure (list of list).
In his case, it could do something similar.
---------- Post updated at 01:50 AM ---------- Previous update was at 01:44 AM ----------
Quote:
Originally Posted by
achenle
That solution introduces an effect that impacts the entire process it's running in: the changing of the current directory.
If you do something like that you will then have what's almost certainly an undocumented and definitely an unnecessary dependency on the internal implementation of what should in theory be reusable code. Unless you fully document all the internals of such calls, then you'll only have an unnecessary dependency.
And you'll outright break multithreaded apps because threads other than the one calling a mkdir() call that changes the current directory will have the current directory modified right out from under their processing.
Hmm.. Although I thought about the change of the current directory ( I use chdir(".."); to restore the current directory), I honestly didn't think about the multithreading problem. Thanks for the heads up.
S.