import unix.*; import libc; // 'resize' is not yet available currentDirectory() { var buf = String(); resize(buf, 1024); while (true) { var result = getcwd(&buf[0], size(buf)); if (not null?(result)) break; if (errno() != ERANGE) error(errorMessage()); resize(buf, 2*size(buf)); } resize(buf, libc.strlen(&buf[0])); return move(buf); }