FreeBASIC  0.91.0
sys_cdir.c
Go to the documentation of this file.
1 /* curdir$ */
2 
3 #include "fb.h"
4 #ifdef HOST_WIN32
5 #include <windows.h> /* for MAX_PATH */
6 #endif
7 
9 {
10  FBSTRING *dst;
11  char tmp[MAX_PATH];
12  ssize_t len;
13 
14  FB_LOCK();
15 
16  len = fb_hGetCurrentDir( tmp, MAX_PATH );
17 
18  /* alloc temp string */
19  if( len > 0 ) {
20  dst = fb_hStrAllocTemp( NULL, len );
21  if( dst != NULL ) {
22  memcpy( dst->data, tmp, len + 1 );
23  } else {
24  dst = &__fb_ctx.null_desc;
25  }
26  } else {
27  dst = &__fb_ctx.null_desc;
28  }
29 
30  FB_UNLOCK();
31 
32  return dst;
33 }