Changeset 38b3baf in mainline for uspace/srv/devman/util.c
- Timestamp:
- 2010-10-23T07:16:14Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7e66a5ec
- Parents:
- 032e0bb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/util.c
r032e0bb r38b3baf 32 32 33 33 #include <stdlib.h> 34 #include <str.h> 35 34 #include <str.h> 35 36 36 #include "util.h" 37 38 37 39 char * get_abs_path(const char *base_path, const char *name, const char *ext)38 char *get_abs_path(const char *base_path, const char *name, const char *ext) 40 39 { 41 40 char *res; 42 41 int base_len = str_size(base_path); 43 int size = base_len + 2 *str_size(name) + str_size(ext) + 3;42 int size = base_len + 2 * str_size(name) + str_size(ext) + 3; 44 43 45 44 res = malloc(size); … … 47 46 if (res) { 48 47 str_cpy(res, size, base_path); 49 if(base_path[base_len - 1] != '/') { 50 str_append(res, size, "/"); 51 } 48 if (base_path[base_len - 1] != '/') 49 str_append(res, size, "/"); 52 50 str_append(res, size, name); 53 51 str_append(res, size, "/"); 54 52 str_append(res, size, name); 55 if (ext[0] != '.') {53 if (ext[0] != '.') 56 54 str_append(res, size, "."); 57 } 58 str_append(res, size, ext); 55 str_append(res, size, ext); 59 56 } 60 57 … … 62 59 } 63 60 64 char * 61 char *get_path_elem_end(char *path) 65 62 { 66 while (0 != *path && '/' != *path) {63 while (0 != *path && '/' != *path) 67 64 path++; 68 }69 65 return path; 70 66 } 67 68 /** @} 69 */
Note:
See TracChangeset
for help on using the changeset viewer.