www.digitalmars.com         C & C++   DMDScript  

D.gnu - getcwd from file.d under AIX

reply John Gibbons <JohnAGibbons bigpond.com> writes:
First let me thank David Friedman for the AIX port of gdc.

I have encountered a minor problem in the phobos library on AIX. AIX 
doesn't allow the size  parameter to be 0 for getcwd, it returns an 
EINVAL error.

Currently file.d contains the line
	
	p = unix.getcwd(null, 0);

For my own needs I have just hacked this to replace 0 by 1024,  but it 
probably should be a loop (pardon my limited D)

   for (bsz = 1024; (p = unix.getcwd(0, bsz)) == null; bsz += 1024) {
     if (getErrno() != ERANGE)
       break;
   }
Jun 28 2005
parent Brad Beveridge <brad somewhere.net> writes:
John Gibbons wrote:
 First let me thank David Friedman for the AIX port of gdc.
 
 I have encountered a minor problem in the phobos library on AIX. AIX 
 doesn't allow the size  parameter to be 0 for getcwd, it returns an 
 EINVAL error.
 
 Currently file.d contains the line
     
     p = unix.getcwd(null, 0);
 
 For my own needs I have just hacked this to replace 0 by 1024,  but it 
 probably should be a loop (pardon my limited D)
 
   for (bsz = 1024; (p = unix.getcwd(0, bsz)) == null; bsz += 1024) {
     if (getErrno() != ERANGE)
       break;
   }
I believe that this will leak in the unlikely situation where the current path is > 1024. for (....) { if (...) break; free(p); } Brad
Jun 28 2005