1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2006,2008 Oracle. All rights reserved. 5 * 6 * $Id: getcwd.c,v 1.5 2008/01/08 20:58:44 bostic Exp $ 7 */ 8 9#include "db_config.h" 10 11#include "db_int.h" 12 13/* 14 * getcwd -- 15 */ 16char * 17getcwd(buf, size) 18 char *buf; 19 size_t size; 20{ 21 IFileMgr *pIFileMgr; 22 int ret; 23#ifndef HAVE_BREW_SDK2 24 int outlen; 25#endif 26 27 FILE_MANAGER_CREATE(NULL, pIFileMgr, ret); 28 if (ret != 0) { 29 __os_set_errno(ret); 30 return (NULL); 31 } 32 33 buf[0] = '\0'; 34 35#ifdef AEE_SIMULATOR 36 /* If AEE_SIMULATOR, we should mimic the resolvepath. */ 37 if (IFILEMGR_Test(pIFileMgr, "fs:/") == SUCCESS) 38 /* Current directory. */ 39 (void)strncpy(buf, "fs:/", size - 1); 40 else 41 FILE_MANAGER_ERR( 42 NULL, pIFileMgr, NULL, "IFILEMGR_ResolvePath", ret); 43#else 44#ifndef HAVE_BREW_SDK2 45 outlen = size; 46 if (IFILEMGR_ResolvePath(pIFileMgr, ".", buf, &outlen) != SUCCESS) 47 FILE_MANAGER_ERR( 48 NULL, pIFileMgr, NULL, "IFILEMGR_ResolvePath", ret); 49#endif 50#endif 51 52 IFILEMGR_Release(pIFileMgr); 53 54 if (ret == 0) 55 return (buf); 56 57 __os_set_errno(ret); 58 59 COMPQUIET(size, 0); 60 return (NULL); 61} 62