-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_dir.c
49 lines (42 loc) · 1.41 KB
/
get_dir.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_dir.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ttshivhu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/08/15 09:24:10 by ttshivhu #+# #+# */
/* Updated: 2018/08/15 09:24:46 by ttshivhu ### ########.fr */
/* */
/* ************************************************************************** */
#include <ftp.h>
char *get_root(void)
{
static char root[MAXPATHLEN] = "";
if (*root != 0)
return (root);
if (getcwd(root, MAXPATHLEN) == NULL)
ft_die(ERROR" getcwd failed\n", 1);
return (root);
}
char *get_dir(void)
{
static char dir[MAXPATHLEN] = "";
if (getcwd(dir, MAXPATHLEN) == NULL)
ft_die(ERROR" getcwd failed\n", 1);
return (dir);
}
char *basename(char *str)
{
char *tmp;
if (str == NULL)
return (NULL);
tmp = str + ft_strlen(str);
while (tmp != str)
{
if (*(tmp - 1) == '/')
break ;
tmp--;
}
return (tmp);
}