FreeBASIC  0.91.0
sys_getcwd.c
Go to the documentation of this file.
1 /* get current dir */
2 
3 #include "../fb.h"
4 #include <unistd.h>
5 
6 ssize_t fb_hGetCurrentDir( char *dst, ssize_t maxlen )
7 {
8  ssize_t len, i;
9  if( getcwd( dst, maxlen ) != NULL ) {
10  len = strlen( dst );
11  /* Always return path with native path separator (backslash).
12  * Returning a slash might break compatibility with older sources.
13  */
14  for (i=0; i!=len; ++i)
15  if (dst[i]=='/')
16  dst[i]='\\';
17 
18  /* make drive letter uppercase */
19  if( dst[1] == ':' )
20  dst[0] = toupper( dst[0] );
21 
22  return len;
23  }
24  return 0;
25 }