2 * Copyright 2005-2007, Ingo Weinhold, bonefish@cs.tu-berlin.de.
3 * Distributed under the terms of the MIT License.
11 #include "fssh_errors.h"
18 get_last_path_component(const char *path
, char *buffer
, int bufferLen
)
20 int len
= strlen(path
);
22 return FSSH_B_BAD_VALUE
;
25 while (len
> 0 && path
[len
- 1] == '/')
34 while (pos
> 0 && path
[pos
] != '/')
44 return FSSH_B_NAME_TOO_LONG
;
46 memcpy(buffer
, path
, len
);
52 make_path(const char *dir
, const char *entry
)
55 int dirLen
= strlen(dir
);
56 int entryLen
= strlen(entry
);
57 bool insertSeparator
= (dir
[dirLen
- 1] != '/');
58 int pathLen
= dirLen
+ entryLen
+ (insertSeparator
? 1 : 0) + 1;
61 char *path
= (char*)malloc(pathLen
);
68 strcat(path
+ dirLen
, "/");
69 strcat(path
+ dirLen
, entry
);
75 } // namespace FSShell