addded str prefix to string functions
This commit is contained in:
parent
8d6775a480
commit
c3e8c508ae
|
@ -1,9 +1,9 @@
|
||||||
#ifndef GUARD_0941C997CB4D2297C8FEA1374912B5D1
|
#ifndef GUARD_0941C997CB4D2297C8FEA1374912B5D1
|
||||||
#define GUARD_0941C997CB4D2297C8FEA1374912B5D1
|
#define GUARD_0941C997CB4D2297C8FEA1374912B5D1
|
||||||
|
|
||||||
char *sw_concat(char *a, char *b);
|
char *sw_str_concat(char *a, char *b);
|
||||||
char *sw_concat3(char *a, char *b, char *c);
|
char *sw_str_concat3(char *a, char *b, char *c);
|
||||||
char *sw_concat4(char *a, char *b, char *c, char *d);
|
char *sw_str_concat4(char *a, char *b, char *c, char *d);
|
||||||
char *sw_strdup(char *str);
|
char *sw_str_dup(char *str);
|
||||||
|
|
||||||
#endif /* GUARD_0941C997CB4D2297C8FEA1374912B5D1 */
|
#endif /* GUARD_0941C997CB4D2297C8FEA1374912B5D1 */
|
||||||
|
|
|
@ -96,7 +96,7 @@ void sw_skip_add(struct sw_skip *skip, u8 *data, u32 data_size, char *name) {
|
||||||
skip->file_count += 1;
|
skip->file_count += 1;
|
||||||
skip->files =
|
skip->files =
|
||||||
realloc(skip->files, sizeof(skip->files[0]) * skip->file_count);
|
realloc(skip->files, sizeof(skip->files[0]) * skip->file_count);
|
||||||
skip->files[skip->file_count - 1].name = sw_strdup(name);
|
skip->files[skip->file_count - 1].name = sw_str_dup(name);
|
||||||
skip->files[skip->file_count - 1].offset = off;
|
skip->files[skip->file_count - 1].offset = off;
|
||||||
skip->files[skip->file_count - 1].size = data_size;
|
skip->files[skip->file_count - 1].size = data_size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
char *sw_concat(char *a, char *b) {
|
char *sw_str_concat(char *a, char *b) {
|
||||||
char *str;
|
char *str;
|
||||||
u32 len_a, len_b;
|
u32 len_a, len_b;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ char *sw_concat(char *a, char *b) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *sw_concat3(char *a, char *b, char *c) {
|
char *sw_str_concat3(char *a, char *b, char *c) {
|
||||||
char *str;
|
char *str;
|
||||||
u32 len_a, len_b, len_c;
|
u32 len_a, len_b, len_c;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ char *sw_concat3(char *a, char *b, char *c) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *sw_concat4(char *a, char *b, char *c, char *d) {
|
char *sw_str_concat4(char *a, char *b, char *c, char *d) {
|
||||||
char *str;
|
char *str;
|
||||||
u32 len_a, len_b, len_c, len_d;
|
u32 len_a, len_b, len_c, len_d;
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ char *sw_concat4(char *a, char *b, char *c, char *d) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *sw_strdup(char *str) {
|
char *sw_str_dup(char *str) {
|
||||||
char *out;
|
char *out;
|
||||||
u32 len;
|
u32 len;
|
||||||
|
|
||||||
|
|
11
tools/skip.c
11
tools/skip.c
|
@ -80,16 +80,17 @@ void crawl(char *dst, char *part_path) {
|
||||||
char *path;
|
char *path;
|
||||||
char *new_part_path;
|
char *new_part_path;
|
||||||
|
|
||||||
dir = sw_concat(dst, "/*.*");
|
dir = sw_str_concat(dst, "/*.*");
|
||||||
find = FindFirstFile(dir, &data);
|
find = FindFirstFile(dir, &data);
|
||||||
do {
|
do {
|
||||||
if(strcmp(data.cFileName, ".") != 0 &&
|
if(strcmp(data.cFileName, ".") != 0 &&
|
||||||
strcmp(data.cFileName, "..") != 0) {
|
strcmp(data.cFileName, "..") != 0) {
|
||||||
path = sw_concat3(dst, "/", data.cFileName);
|
path = sw_str_concat3(dst, "/", data.cFileName);
|
||||||
if(part_path) {
|
if(part_path) {
|
||||||
new_part_path = sw_concat3(part_path, "/", data.cFileName);
|
new_part_path =
|
||||||
|
sw_str_concat3(part_path, "/", data.cFileName);
|
||||||
} else {
|
} else {
|
||||||
new_part_path = sw_strdup(data.cFileName);
|
new_part_path = sw_str_dup(data.cFileName);
|
||||||
}
|
}
|
||||||
crawl(path, new_part_path);
|
crawl(path, new_part_path);
|
||||||
free(path);
|
free(path);
|
||||||
|
@ -132,7 +133,7 @@ int main(int argc, char *argv[]) {
|
||||||
sw_error("argument not a directory");
|
sw_error("argument not a directory");
|
||||||
}
|
}
|
||||||
crawl(argv[2], 0);
|
crawl(argv[2], 0);
|
||||||
filename = sw_concat(argv[2], ".skip");
|
filename = sw_str_concat(argv[2], ".skip");
|
||||||
sw_skip_save(skip, filename);
|
sw_skip_save(skip, filename);
|
||||||
printf("%s created\n", filename);
|
printf("%s created\n", filename);
|
||||||
free(filename);
|
free(filename);
|
||||||
|
|
Loading…
Reference in New Issue