FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
sys_getexepath.c
Go to the documentation of this file.
1
/* get the executable path */
2
3
#include "../fb.h"
4
5
char
*
fb_hGetExePath
(
char
*dst, ssize_t maxlen )
6
{
7
const
char
*
p
= strrchr(
__fb_ctx
.
argv
[0],
'/'
);
8
if
( p ) {
9
ssize_t len = p -
__fb_ctx
.
argv
[0];
10
if
( len > maxlen ) {
11
len = maxlen;
12
}
13
else
if
( len == 0 ) {
14
/* keep the "/" rather than returning "" */
15
len = 1;
16
}
17
18
memcpy( dst,
__fb_ctx
.
argv
[0], len );
19
dst[len] =
'\0'
;
20
}
else
{
21
*dst =
'\0'
;
22
}
23
return
dst;
24
}
rtlib
freebsd
sys_getexepath.c
Generated on Thu Jan 23 2014 19:40:10 for FreeBASIC by
1.8.4